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", () => { it("includes COMPLETED DATE column between STATUS and COMP DOC", () => { const keys = WO_TABLE_COLS.map((col) => col.key); expect(keys).toContain("completed"); expect(keys.indexOf("completed")).toBe(keys.indexOf("status") + 1); expect(keys.indexOf("completed")).toBeLessThan(keys.indexOf("doc")); }); it("expands completedDate patch to board field op", () => { const ops = expandScalarBoardOps({ completedDate: "2026-07-30" }); expect(ops).toEqual([{ field: "completedDate", value: "2026-07-30" }]); }); 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: "" }]); }); 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"); }); });