74 lines
2.5 KiB
JavaScript
74 lines
2.5 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
getSelfServeCompletedDynamicImageStep,
|
|
getSelfServeTaskDynamicImagePresentation,
|
|
normalizeSelfServeProgramPickerTaskButtons,
|
|
} from "@/services/selfServeDynamicImage.js";
|
|
|
|
describe("selfServeDynamicImage", () => {
|
|
it("uses a selected program picker button number as thumb position", () => {
|
|
const presentation = getSelfServeTaskDynamicImagePresentation({
|
|
buttons: ["program_picker", 0],
|
|
});
|
|
|
|
expect(presentation.buttons).toEqual(["program_picker"]);
|
|
expect(presentation.normalizedButtons).toEqual(["program_picker", 0]);
|
|
expect(presentation.thumbPosition).toBe(1);
|
|
});
|
|
|
|
it("prefers configured program wheel thumb position and keeps numeric machine buttons highlighted", () => {
|
|
const presentation = getSelfServeTaskDynamicImagePresentation({
|
|
services: ["PROGRAM_PICKER"],
|
|
buttons: [2, "start"],
|
|
dynamic_images_vehicle_type: 8,
|
|
});
|
|
|
|
expect(presentation.buttons).toEqual(["program_picker", 2, "start"]);
|
|
expect(presentation.normalizedButtons).toEqual([2, "start"]);
|
|
expect(presentation.thumbPosition).toBe(8);
|
|
});
|
|
|
|
it("drops the legacy numeric wheel selector while keeping other machine buttons highlighted", () => {
|
|
const presentation = getSelfServeTaskDynamicImagePresentation({
|
|
services: ["PROGRAM_PICKER"],
|
|
buttons: [3, 1, "start"],
|
|
dynamic_images_vehicle_type: 4,
|
|
});
|
|
|
|
expect(presentation.buttons).toEqual(["program_picker", 1, "start"]);
|
|
expect(presentation.normalizedButtons).toEqual([3, 1, "start"]);
|
|
expect(presentation.thumbPosition).toBe(4);
|
|
});
|
|
|
|
it("keeps numeric buttons highlighted outside program-picker mode", () => {
|
|
const presentation = getSelfServeTaskDynamicImagePresentation({
|
|
services: ["MACHINE"],
|
|
buttons: [2, "start"],
|
|
dynamic_images_vehicle_type: 8,
|
|
});
|
|
|
|
expect(presentation.buttons).toEqual([2, "start"]);
|
|
expect(presentation.thumbPosition).toBe(8);
|
|
});
|
|
|
|
it("excludes program-picker thumb selectors from completed step count", () => {
|
|
const tasks = [
|
|
{
|
|
id: 10,
|
|
services: ["PROGRAM_PICKER"],
|
|
buttons: [2, "start"],
|
|
},
|
|
];
|
|
|
|
expect(getSelfServeCompletedDynamicImageStep(tasks, { 10: true })).toBe(2);
|
|
});
|
|
|
|
it("keeps only one numbered program button in program-picker mode", () => {
|
|
expect(normalizeSelfServeProgramPickerTaskButtons(["program_picker", 1, 2, "start"], [], 2)).toEqual([
|
|
"program_picker",
|
|
2,
|
|
"start",
|
|
]);
|
|
});
|
|
});
|