Files
pleno-vue/tests/unit/self-serve-studio-question-scope.spec.js
T
Jeppe Bundgaard b39b458f4f Add .prettierrc.json and refactor test files for improved formatting consistency:
- Introduced `.prettierrc.json` to enforce consistent code formatting across the project.
- Updated unit and e2e test files to address formatting issues, improve readability, and ensure alignment with the new Prettier configuration.
2026-04-13 09:13:27 +02:00

45 lines
2.1 KiB
JavaScript

import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
const readSource = (relativePath) => readFileSync(join(process.cwd(), relativePath), "utf8");
describe("self-serve studio question scope", () => {
it("renders legacy scope selectors for question lane and vehicle", () => {
const studioSource = readSource(
"src/views/dashboards/departmentDashboard/modules/self-serve/DepartmentSelfServeStudio.vue"
);
expect(studioSource).toContain("v-if=\"questionForm.scope_mode === 'legacy'\"");
expect(studioSource).toContain('v-model="questionForm.lane"');
expect(studioSource).toContain('v-model="questionForm.product"');
expect(studioSource).toContain("Select lane");
expect(studioSource).toContain("Select vehicle type");
expect(studioSource).toContain('v-for="entry in lanes"');
});
it("guards question submission for legacy Department/Lane/Vehicle scope", () => {
const studioSource = readSource(
"src/views/dashboards/departmentDashboard/modules/self-serve/DepartmentSelfServeStudio.vue"
);
expect(studioSource).toContain("Question text is required.");
expect(studioSource).toContain("Question description is required.");
expect(studioSource).toContain("Department is required for Department/Lane/Vehicle scope.");
expect(studioSource).toContain("Lane is required for Department/Lane/Vehicle scope.");
expect(studioSource).toContain("Vehicle type is required for Department/Lane/Vehicle scope.");
expect(studioSource).toContain("if (payload.lane <= 0)");
expect(studioSource).toContain("if (payload.product <= 0)");
});
it("renders and submits question order priority", () => {
const studioSource = readSource(
"src/views/dashboards/departmentDashboard/modules/self-serve/DepartmentSelfServeStudio.vue"
);
expect(studioSource).toContain('<label class="label">Order Priority</label>');
expect(studioSource).toContain('v-model="questionForm.order_priority"');
expect(studioSource).toContain("order_priority: parseIntOrZero(questionForm.value.order_priority)");
});
});