fix: restore exception details in migration reports (#8585)
Co-authored-by: Kai Wang <kw491@students.waikato.ac.nz>
This commit is contained in:
1 parent
07274cdfe1
commit
dbba23b1bb
3 files changed
+88
-7
No files matched your search
@@ -33,14 +33,21 @@
|
||||
<template #[`item.timestamp`]="{ item }">
|
||||
{{ $d(Date.parse(item.timestamp!), "short") }}
|
||||
</template>
|
||||
<template #[`expanded-item`]="{ headers, item }">
|
||||
<td
|
||||
<template #[`item.data-table-expand`]="{ item, props }">
|
||||
<v-btn
|
||||
v-if="item.exception"
|
||||
class="pa-6"
|
||||
:colspan="headers.length"
|
||||
>
|
||||
{{ item.exception }}
|
||||
</td>
|
||||
v-bind="props"
|
||||
/>
|
||||
</template>
|
||||
<template #expanded-row="{ columns, item }">
|
||||
<tr v-if="item.exception">
|
||||
<td
|
||||
class="pa-6"
|
||||
:colspan="columns.length"
|
||||
>
|
||||
{{ item.exception }}
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-container>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { flushPromises, mount } from "@vue/test-utils";
|
||||
import { afterEach, expect, test, vi } from "vitest";
|
||||
import { createVuetify } from "vuetify";
|
||||
import { VBtn, VCardText, VContainer, VDataTable, VIcon } from "vuetify/components";
|
||||
import ReportPage from "./[id].vue";
|
||||
import { i18n } from "~/tests/setup";
|
||||
import type { ReportOut } from "~/lib/api/types/reports";
|
||||
|
||||
const { getOne } = vi.hoisted(() => ({ getOne: vi.fn() }));
|
||||
|
||||
vi.mock("~/composables/api", () => ({
|
||||
useUserApi: () => ({ groupReports: { getOne } }),
|
||||
}));
|
||||
|
||||
afterEach(() => vi.unstubAllGlobals());
|
||||
|
||||
test("report entries expand to show their exception and collapse again", async () => {
|
||||
vi.stubGlobal("definePageMeta", vi.fn());
|
||||
vi.stubGlobal("useRoute", () => ({ params: { id: "report-1" } }));
|
||||
vi.stubGlobal("ResizeObserver", class {
|
||||
observe() {}
|
||||
unobserve() {}
|
||||
disconnect() {}
|
||||
});
|
||||
i18n.global.setDateTimeFormat("en-US", { short: { year: "numeric", month: "short", day: "numeric" } });
|
||||
const report: ReportOut = {
|
||||
id: "report-1",
|
||||
groupId: "group-1",
|
||||
name: "Migration report",
|
||||
category: "migration",
|
||||
entries: [
|
||||
{ id: "failed", reportId: "report-1", message: "Failed recipe", success: false, exception: "Invalid recipe data" },
|
||||
{ id: "success", reportId: "report-1", message: "Imported recipe", success: true, exception: "" },
|
||||
{ id: "no-details", reportId: "report-1", message: "No details", success: false },
|
||||
].map(entry => ({ ...entry, timestamp: "2026-09-25T12:00:00Z" })),
|
||||
};
|
||||
getOne.mockResolvedValue({ data: report });
|
||||
const wrapper = mount(ReportPage, {
|
||||
global: {
|
||||
plugins: [createVuetify({ components: { VBtn, VCardText, VContainer, VDataTable, VIcon } })],
|
||||
stubs: { BasePageTitle: true, BaseCardSectionTitle: true, VImg: true },
|
||||
mocks: {
|
||||
$globals: { icons: { checkboxMarkedCircle: "success", close: "error" } },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
await flushPromises();
|
||||
expect(getOne).toHaveBeenCalledWith("report-1");
|
||||
const rows = wrapper.findAll("tbody > tr");
|
||||
expect(rows).toHaveLength(3);
|
||||
expect(wrapper.text()).not.toContain("Invalid recipe data");
|
||||
|
||||
await rows[0].get("button").trigger("click");
|
||||
const details = wrapper.findAll("tbody > tr")[1];
|
||||
expect(details.text()).toBe("Invalid recipe data");
|
||||
expect(details.get("td").attributes("colspan")).toBe("4");
|
||||
|
||||
await rows[0].get("button").trigger("click");
|
||||
expect(wrapper.text()).not.toContain("Invalid recipe data");
|
||||
expect(wrapper.findAll("tbody > tr")).toHaveLength(3);
|
||||
expect(rows[1].find("button").exists()).toBe(false);
|
||||
expect(rows[2].find("button").exists()).toBe(false);
|
||||
}
|
||||
finally {
|
||||
wrapper.unmount();
|
||||
}
|
||||
});
|
||||
@@ -11,6 +11,11 @@ export default {
|
||||
}),
|
||||
],
|
||||
test: {
|
||||
server: {
|
||||
deps: {
|
||||
inline: ["vuetify"],
|
||||
},
|
||||
},
|
||||
globals: true,
|
||||
environment: "jsdom",
|
||||
setupFiles: ["./app/tests/setup.ts"],
|
||||
|
||||
Reference in new issue
Block a user