Removes the now-removed XL Vask Selvvask AI autopilot and MiniMax UI from the Superuser → Fakturaer → Periode → Selvvask surface. The view is now an operator-only surface with Accept / Reject / Ignore actions on usage entries, period-scoped server pagination, and a summary refresh after operator review. Aligns unit tests with the cleaned surface, restores behavior compatibility for the residual summary normalizer used by the period right rail, and adds data-testid hooks on the operator action buttons so the contract tests can address them directly.
91 lines
2.4 KiB
JavaScript
91 lines
2.4 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
filterUsageOrdersByAttachment,
|
|
isUsageOrderAttachedToOrder,
|
|
} from "@/components/displays/department/pos/sync/xlvaskUsageFilters.js";
|
|
|
|
describe("xlvask usage filters", () => {
|
|
it("detects when a generated usage row is attached to an existing order", () => {
|
|
const attachedObject = {
|
|
wash_id: 101,
|
|
duplicates: [
|
|
{ id: 1, wash_id: 45 },
|
|
{ id: 2, wash_id: 101 },
|
|
],
|
|
};
|
|
|
|
const unattachedObject = {
|
|
wash_id: 202,
|
|
duplicates: [{ id: 3, wash_id: 45 }],
|
|
};
|
|
|
|
expect(isUsageOrderAttachedToOrder(attachedObject)).toBe(true);
|
|
expect(isUsageOrderAttachedToOrder(unattachedObject)).toBe(false);
|
|
});
|
|
|
|
it("keeps all rows when the unattached-only switch is disabled", () => {
|
|
const sourceRows = [
|
|
{ id: 1, wash_id: 10, duplicates: [{ wash_id: 10 }] },
|
|
{ id: 2, wash_id: 20, duplicates: [{ wash_id: 99 }] },
|
|
{ id: 3, wash_id: 30 },
|
|
];
|
|
|
|
expect(filterUsageOrdersByAttachment(sourceRows, false)).toEqual(sourceRows);
|
|
});
|
|
|
|
it("treats linked and duplicate wash_ids as attached", () => {
|
|
expect(
|
|
isUsageOrderAttachedToOrder({
|
|
wash_id: "wash-1",
|
|
linked_order_id: 17,
|
|
duplicates: [],
|
|
})
|
|
).toBe(true);
|
|
|
|
expect(
|
|
isUsageOrderAttachedToOrder({
|
|
wash_id: "wash-2",
|
|
duplicates: [{ wash_id: "wash-2" }],
|
|
})
|
|
).toBe(true);
|
|
|
|
expect(
|
|
isUsageOrderAttachedToOrder({
|
|
wash_id: "wash-3",
|
|
duplicates: [],
|
|
})
|
|
).toBe(false);
|
|
});
|
|
|
|
it("treats direct linked order metadata as attached", () => {
|
|
expect(
|
|
isUsageOrderAttachedToOrder({
|
|
wash_id: "wash-1",
|
|
linked_order_id: 61355,
|
|
duplicates: [],
|
|
})
|
|
).toBe(true);
|
|
|
|
expect(
|
|
isUsageOrderAttachedToOrder({
|
|
wash_id: "wash-2",
|
|
linked_order_id: null,
|
|
duplicates: [],
|
|
})
|
|
).toBe(false);
|
|
});
|
|
|
|
it("returns only rows not attached to existing orders when enabled", () => {
|
|
const sourceRows = [
|
|
{ id: 1, wash_id: 10, duplicates: [{ wash_id: 10 }] },
|
|
{ id: 2, wash_id: 20, duplicates: [{ wash_id: 99 }] },
|
|
{ id: 3, wash_id: 30, duplicates: [] },
|
|
];
|
|
|
|
expect(filterUsageOrdersByAttachment(sourceRows, true)).toEqual([
|
|
{ id: 2, wash_id: 20, duplicates: [{ wash_id: 99 }] },
|
|
{ id: 3, wash_id: 30, duplicates: [] },
|
|
]);
|
|
});
|
|
});
|