Files
pleno-vue/tests/unit/self-serve-questions-step.spec.js
T
Jeppe Bundgaard f619487f6f Implement automatic table Excel exports with unit tests:
- Add `AutoTableExportService` for dynamic Excel export button generation and visible row extraction.
- Integrate auto-export initialization in `main.js` for legacy non-paginated tables.
- Extend `PaginationDisplay.vue` with support for paginated Excel export.
- Add export functionality to vehicle views and dependencies, including full-table export handling.
- Add tests for `TableExcelExportService.js`, export workflows, and normalization logic.
- Enhance localization with `download_excel` translation key.
2026-03-18 12:46:40 +01:00

77 lines
2.8 KiB
JavaScript

// @vitest-environment jsdom
import { describe, expect, it } from "vitest";
import SelfServeQuestionsStep from "@/components/displays/selfServe/SelfServeQuestionsStep.vue";
import { mountWithApp } from "./helpers/mountWithApp.js";
describe("SelfServeQuestionsStep", () => {
const baseProps = {
isLoading: false,
loadingQuestionId: null,
loadingAnswerValue: null,
visibleQuestions: [
{ id: 11, question: "Is the trailer closed?" },
],
answers: { 11: true },
editAnswers: true,
showDebug: true,
conditions: [
{ id: 21, name: "Closed trailer" },
],
rules: [
{ id: 31, condition_id: 21, type: "IS_TRUE", name: "Question 11 is true" },
],
evaluateCondition: () => true,
evaluateRule: () => true,
isQuestionVisible: () => true,
getConditionById: () => ({ id: 21, name: "Closed trailer" }),
getRuleTypeLabel: () => "Is true",
};
it("renders question cards, emits answers, and exposes debug controls", async () => {
const wrapper = mountWithApp(SelfServeQuestionsStep, {
props: baseProps,
});
expect(wrapper.get('[data-testid="self-serve-debug-panel"]').text()).toContain("Closed trailer");
await wrapper.get('[data-testid="self-serve-toggle-debug"]').trigger("click");
await wrapper.get('[data-testid="self-serve-toggle-edit"]').trigger("click");
await wrapper.get('[data-testid="self-serve-question-11-no"]').trigger("click");
expect(wrapper.emitted("toggle-debug")).toHaveLength(1);
expect(wrapper.emitted("toggle-edit")).toHaveLength(1);
expect(wrapper.emitted("answer-question")).toEqual([[11, false]]);
});
it("shows the full loading state only when no questions are available yet", () => {
const wrapper = mountWithApp(SelfServeQuestionsStep, {
props: {
...baseProps,
isLoading: true,
visibleQuestions: [],
showDebug: false,
},
});
expect(wrapper.text()).toContain("self_wash.loading_data");
expect(wrapper.find('[data-testid="self-serve-question-cards"]').exists()).toBe(false);
});
it("keeps the question list visible and only locks the question being synced", () => {
const wrapper = mountWithApp(SelfServeQuestionsStep, {
props: {
...baseProps,
isLoading: true,
loadingQuestionId: 11,
loadingAnswerValue: true,
},
});
expect(wrapper.find('[data-testid="self-serve-question-cards"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="self-serve-question-11-yes"]').classes()).toContain("is-loading");
expect(wrapper.find('[data-testid="self-serve-question-11-no"]').classes()).not.toContain("is-loading");
expect(wrapper.find('[data-testid="self-serve-question-11-yes"]').attributes("disabled")).toBeDefined();
expect(wrapper.find('[data-testid="self-serve-question-11-no"]').attributes("disabled")).toBeDefined();
});
});