- 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.
35 lines
2.1 KiB
JavaScript
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);");
|
|
});
|
|
});
|