2026-08-10 17:12:11 -03:00
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
|
import { WO_TABLE_COLS } from "@/app/(protected)/workorders/_components/list/table/wo-table-cols";
|
|
|
|
|
import { expandScalarBoardOps } from "@/domain/work-orders/mappers/expand-scalar-board-ops";
|
|
|
|
|
import { mapWorkOrderTableRow } from "@/domain/work-orders/mappers/work-order-table-row-mapper";
|
|
|
|
|
|
|
|
|
|
describe("COMPLETED DATE board column wiring", () => {
|
2026-09-16 15:05:25 -03:00
|
|
|
it("includes COMPLETED DATE column between STATUS and COMP DOC", () => {
|
2026-08-10 17:12:11 -03:00
|
|
|
const keys = WO_TABLE_COLS.map((col) => col.key);
|
|
|
|
|
expect(keys).toContain("completed");
|
2026-09-16 13:21:48 -03:00
|
|
|
expect(keys.indexOf("completed")).toBe(keys.indexOf("status") + 1);
|
|
|
|
|
expect(keys.indexOf("completed")).toBeLessThan(keys.indexOf("doc"));
|
2026-08-10 17:12:11 -03:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("expands completedDate patch to board field op", () => {
|
|
|
|
|
const ops = expandScalarBoardOps({ completedDate: "2026-07-30" });
|
|
|
|
|
expect(ops).toEqual([{ field: "completedDate", value: "2026-07-30" }]);
|
|
|
|
|
});
|
|
|
|
|
|
2026-09-24 20:44:03 -03:00
|
|
|
it("expands a clearing completedDate patch to an empty-string board field op (SH-390)", () => {
|
|
|
|
|
const ops = expandScalarBoardOps({ completedDate: "" });
|
|
|
|
|
expect(ops).toEqual([{ field: "completedDate", value: "" }]);
|
|
|
|
|
});
|
|
|
|
|
|
2026-08-10 17:12:11 -03:00
|
|
|
it("maps completedDate returned by a board GET row", () => {
|
|
|
|
|
const row = mapWorkOrderTableRow({
|
|
|
|
|
id: 42,
|
|
|
|
|
completedDate: "2026-07-30T00:00:00Z",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(row.completedDate).toBe("2026-07-30");
|
|
|
|
|
});
|
|
|
|
|
});
|