Files
pleno-vue/tests/unit/self-serve-studio-vehicle-type-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

52 lines
2.5 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 vehicle type scope", () => {
it("adds a vehicle-type select bound to product query scope", () => {
const studioSource = readSource(
"src/views/dashboards/departmentDashboard/modules/self-serve/DepartmentSelfServeStudio.vue"
);
expect(studioSource).toContain("const scopedProductId = computed(() => parseScopedProduct(route.query.product));");
expect(studioSource).toContain("const scopedProductModel = computed({");
expect(studioSource).toContain("delete nextQuery.product;");
expect(studioSource).toContain('data-testid="self-serve-studio-vehicle-type-select"');
expect(studioSource).toContain('<option :value="null">All vehicle types</option>');
});
it("applies product scope filtering and defaults for new records", () => {
const studioSource = readSource(
"src/views/dashboards/departmentDashboard/modules/self-serve/DepartmentSelfServeStudio.vue"
);
expect(studioSource).toContain(
"const scopedQuestions = computed(() => questions.value.filter((entry) => matchesScopedProduct(entry)));"
);
expect(studioSource).toContain(
"const scopedConditions = computed(() => conditions.value.filter((entry) => matchesScopedProduct(entry)));"
);
expect(studioSource).toContain(
"const scopedTasks = computed(() => tasks.value.filter((entry) => matchesScopedProduct(entry)));"
);
expect(studioSource).toContain("const machineTypeId = parseNullableInt(item.machine_type_id);");
expect(studioSource).toContain("return machineTypeId === scopedProductId.value;");
expect(studioSource).not.toContain(
"if (parseNullableInt(item.machine_type_id)) {\n return true;\n }\n const product = parseIntOrZero(item.product);"
);
expect(studioSource).toContain("product: scopedProductId.value || 0,");
});
it("sorts scoped question and task source lists by order priority", () => {
const studioSource = readSource(
"src/views/dashboards/departmentDashboard/modules/self-serve/DepartmentSelfServeStudio.vue"
);
expect(studioSource).toContain("const compareByOrderPriority = (left, right) => {");
expect(studioSource).toContain(".sort(compareByOrderPriority);");
expect(studioSource).toContain("questions.value = [...questions.value].sort(compareByOrderPriority);");
});
});