54 lines
2.6 KiB
JavaScript
54 lines
2.6 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", () => {
|
|
const studioSource = () =>
|
|
readSource("src/views/dashboards/departmentDashboard/modules/self-serve/DepartmentSelfServeStudio.vue");
|
|
|
|
it("renders a vehicle type toolbar filter bound to product scope", () => {
|
|
const source = studioSource();
|
|
|
|
expect(source).toContain("vehicle_type_id: normalizeScopeValue(");
|
|
expect(source).toContain('data-testid="studio-filter-vehicle-type"');
|
|
expect(source).toContain('<option value="" disabled>Select vehicle type</option>');
|
|
expect(source).toContain(':value="vehicleTypeFilterValue(vehicleType)"');
|
|
});
|
|
|
|
it("applies vehicle type scope filtering and defaults for new records", () => {
|
|
const source = studioSource();
|
|
|
|
expect(source).toContain(
|
|
'matchesScopeFilter(node, "vehicle_type", normalizeFilterValue(filters.value.vehicle_type_id))'
|
|
);
|
|
expect(source).toContain("const isSelectedScopeAnchorNode = (node) => {");
|
|
expect(source).toContain('["lane", "vehicle_type"].includes(kind)');
|
|
expect(source).toContain("if (isSelectedScopeAnchorNode(node)) {");
|
|
expect(source).toContain(
|
|
'const conditionNodes = computed(() => filteredListNodes.value.filter((node) => node.data?.kind === "condition"));'
|
|
);
|
|
expect(source).toContain(
|
|
'const taskNodes = computed(() => filteredListNodes.value.filter((node) => node.data?.kind === "task"));'
|
|
);
|
|
expect(source).toContain("product: parseNullableInt(filters.value.vehicle_type_id) || 0");
|
|
expect(source).toContain('return kind === "vehicle_type"');
|
|
expect(source).toContain(": firstFilterValue(raw.product, raw.product_id, raw.vehicle_type_id);");
|
|
});
|
|
|
|
it("uses toolbar lane and vehicle type filters as the simulator scope", () => {
|
|
const source = studioSource();
|
|
|
|
expect(source).toContain("const selectedSimulatorLaneId = computed(() => firstPositiveInt(");
|
|
expect(source).toContain("filters.value.lane_id");
|
|
expect(source).toContain("const selectedSimulatorVehicleTypeId = computed(() => (");
|
|
expect(source).toContain("vehicleTypeMatchesFilter(vehicleType, selectedValue)");
|
|
expect(source).toContain("lane_id: laneId");
|
|
expect(source).toContain("vehicle_type_id: selectedSimulatorVehicleTypeId.value");
|
|
expect(source).toContain('data-testid="studio-simulator-scope"');
|
|
expect(source).not.toContain('v-model="simulatorForm.lane_id"');
|
|
expect(source).not.toContain('v-model="simulatorForm.vehicle_type_id"');
|
|
});
|
|
});
|