Files
pleno-vue/tests/unit/self-serve-studio-vehicle-type-scope.spec.js
T
Jeppe Bundgaard 7368c476f1 Add task priority, gate type normalization, and vehicle type logic to self-serve functionalities:
- Introduced task order priority, dynamic image thumb position, and improved task gate type handling in the self-serve studio.
- Enhanced task payload normalization with nullable fields and parameter verification.
- Updated UI with order priority controls, dynamic images configuration, and machine type-specific scoping options.
- Added and refined unit tests for task sorting, form controls, and validation rules.
2026-03-26 11:35:24 +01:00

35 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 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("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);");
});
});