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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user