mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 04:33:11 +00:00
The completed-date cell editor had no Clear control. It now offers Clear when a date is set and the row is editable, patching completedDate to an empty value, which the board PATCH persists as null. Completed and Canceled rows stay locked, matching set/change.
32 lines
1.4 KiB
TypeScript
32 lines
1.4 KiB
TypeScript
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");
|
|
});
|
|
});
|