Add task attachment management to Self-Serve Studio. Extend graph, path outcomes, and flow logic. Update E2E/unit tests with attachment creation, upload, download, deletion flows, and related validations.

This commit is contained in:
Jeppe Bundgaard
2026-04-29 14:41:29 +02:00
parent 9641f67e3a
commit a15d6841c5
28 changed files with 2459 additions and 213 deletions
+41
View File
@@ -6,6 +6,7 @@ const mocks = vi.hoisted(() => ({
fetchSelfServeData: vi.fn(),
syncVehicleAnswer: vi.fn(),
clearVehicleAnswers: vi.fn(),
downloadAttachment: vi.fn(),
swalFire: vi.fn(),
getLanes: vi.fn(),
getVehicleTypeOptions: vi.fn(),
@@ -78,6 +79,7 @@ vi.mock("@/composables/useSelfServeLogic", () => ({
syncVehicleAnswer: mocks.syncVehicleAnswer,
clearVehicleAnswers: mocks.clearVehicleAnswers,
evaluateCondition: mocks.evaluateCondition,
downloadAttachment: mocks.downloadAttachment,
}),
}));
@@ -89,6 +91,7 @@ describe("SelfServeTryModal", () => {
mocks.fetchSelfServeData.mockReset();
mocks.syncVehicleAnswer.mockReset();
mocks.clearVehicleAnswers.mockReset();
mocks.downloadAttachment.mockReset();
mocks.swalFire.mockReset();
mocks.getLanes.mockReset();
mocks.getVehicleTypeOptions.mockReset();
@@ -146,6 +149,44 @@ describe("SelfServeTryModal", () => {
expect(mocks.fetchSelfServeData).toHaveBeenCalledWith(9, 3, 3, "AB12345");
});
it("passes simulator task attachment downloads to self-serve logic", async () => {
const attachment = {
id: 201,
content: { other: "manual.pdf" },
download_link: "https://cdn.example.test/manual.pdf",
};
mocks.activeTasks.value = [
{
id: 5,
task: "Prepare",
attachments: [attachment],
},
];
const wrapper = mountWithApp(SelfServeTryModal, {
props: {
departmentId: 9,
laneId: 3,
},
global: {
stubs: {
SelfServeQuestionCards: true,
SelfServeTaskList: {
props: ["tasks"],
emits: ["download-attachment"],
template:
"<button data-testid='emit-task-download' @click=\"$emit('download-attachment', tasks[0].id, tasks[0].attachments[0].id, tasks[0].attachments[0])\">download</button>",
},
},
},
});
await flushPromises();
await wrapper.get("[data-testid='emit-task-download']").trigger("click");
expect(mocks.downloadAttachment).toHaveBeenCalledWith(5, 201, attachment);
});
it("syncs answers with the selected vehicle type context", async () => {
mocks.visibleQuestions.value = [{ id: 77, question: "Question 77" }];
mocks.currentQuestion.value = null;