mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 08:03:13 +00:00
fix(work-orders): place Completed Date before Comp Doc on the board
This commit is contained in:
parent
fc3e7591dc
commit
4649fd00da
4 changed files with 132 additions and 14 deletions
|
|
@ -11,9 +11,10 @@ export const WO_TABLE_COLS = [
|
|||
{ key: "vendor", label: "VENDOR", w: 184 },
|
||||
{ key: "appt", label: "APPT TIME", w: 128 },
|
||||
{ key: "status", label: "STATUS", w: 148 },
|
||||
// SH-359: Completed Date gates the Completion Document, so it sits between Status and Comp Doc.
|
||||
{ key: "completed", label: "COMPLETED DATE", w: 130 },
|
||||
{ key: "doc", label: "COMP DOC", w: 84 },
|
||||
{ key: "uplift", label: "UPLIFT", w: 108 },
|
||||
{ key: "completed", label: "COMPLETED DATE", w: 130 },
|
||||
{ key: "actions", label: "", w: 100 },
|
||||
] as const;
|
||||
|
||||
|
|
|
|||
|
|
@ -105,6 +105,17 @@ export function WoTableRowServiceCells({
|
|||
onRequestComplete={() => handlers.onRequestComplete?.(row)}
|
||||
/>
|
||||
</td>
|
||||
<td
|
||||
className="group/cell"
|
||||
style={{ padding: "0 14px", ...mutationCellStyle }}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<DateCell
|
||||
value={row.completedDate}
|
||||
q={search}
|
||||
onSave={(date) => onPatchRow({ completedDate: date })}
|
||||
/>
|
||||
</td>
|
||||
<td style={{ padding: "0 14px" }} onClick={(e) => e.stopPropagation()}>
|
||||
<CompDocCell
|
||||
status={row.docStatus}
|
||||
|
|
@ -126,17 +137,6 @@ export function WoTableRowServiceCells({
|
|||
}
|
||||
/>
|
||||
</td>
|
||||
<td
|
||||
className="group/cell"
|
||||
style={{ padding: "0 14px", ...mutationCellStyle }}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<DateCell
|
||||
value={row.completedDate}
|
||||
q={search}
|
||||
onSave={(date) => onPatchRow({ completedDate: date })}
|
||||
/>
|
||||
</td>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,116 @@
|
|||
import { screen, within } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { WO_TABLE_COLS } from "@/app/(protected)/workorders/_components/list/table/wo-table-cols";
|
||||
import { WoTableHead } from "@/app/(protected)/workorders/_components/list/table/wo-table-head";
|
||||
import { WoTableRowServiceCells } from "@/app/(protected)/workorders/_components/list/table/wo-table-row-service-cells";
|
||||
import type { WoTableRowHandlers } from "@/app/(protected)/workorders/_components/list/table/wo-table-row";
|
||||
import type { WorkOrderTableRow } from "@/domain/work-orders/types/work-order-table-row";
|
||||
import { renderWithProviders } from "@/test/test-utils";
|
||||
|
||||
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/pm-type-cell", () => ({
|
||||
PMTypeCell: () => <span>cell:service</span>,
|
||||
}));
|
||||
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/vendor-cell", () => ({
|
||||
VendorCell: () => <span>cell:vendor</span>,
|
||||
}));
|
||||
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/appt-time-cell", () => ({
|
||||
ApptTimeCell: () => <span>cell:appt</span>,
|
||||
}));
|
||||
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/status-cell", () => ({
|
||||
StatusCell: () => <span>cell:status</span>,
|
||||
}));
|
||||
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/date-cell", () => ({
|
||||
DateCell: () => <span>cell:completed</span>,
|
||||
}));
|
||||
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/comp-doc-cell", () => ({
|
||||
CompDocCell: () => <span>cell:doc</span>,
|
||||
}));
|
||||
vi.mock("@/app/(protected)/workorders/_components/list/table/cells/uplift-cell", () => ({
|
||||
UpliftCell: () => <span>cell:uplift</span>,
|
||||
}));
|
||||
|
||||
/** SH-359: documented left-to-right data column order for the Work Orders board. */
|
||||
const DOCUMENTED_ORDER = [
|
||||
"SITE",
|
||||
"WO",
|
||||
"TYPE OF WO",
|
||||
"ASSIGNED TO",
|
||||
"SCHEDULE ON",
|
||||
"DUE DATE",
|
||||
"SERVICE",
|
||||
"VENDOR",
|
||||
"APPT TIME",
|
||||
"STATUS",
|
||||
"COMPLETED DATE",
|
||||
"COMP DOC",
|
||||
"UPLIFT",
|
||||
];
|
||||
|
||||
describe("Work Orders board column order (SH-359)", () => {
|
||||
it("renders the documented header order with grip/flag before Site and actions after Uplift", () => {
|
||||
renderWithProviders(
|
||||
<table>
|
||||
<WoTableHead />
|
||||
</table>,
|
||||
{ withAuth: false },
|
||||
);
|
||||
|
||||
const headers = screen.getAllByRole("columnheader").map((th) => th.textContent?.trim() ?? "");
|
||||
expect(headers.filter(Boolean)).toEqual(expect.arrayContaining(DOCUMENTED_ORDER));
|
||||
expect(WO_TABLE_COLS.map((col) => col.key)).toEqual([
|
||||
"grip",
|
||||
"flag",
|
||||
"site",
|
||||
"wo",
|
||||
"type",
|
||||
"assigned",
|
||||
"sched",
|
||||
"due",
|
||||
"pm",
|
||||
"vendor",
|
||||
"appt",
|
||||
"status",
|
||||
"completed",
|
||||
"doc",
|
||||
"uplift",
|
||||
"actions",
|
||||
]);
|
||||
expect(WO_TABLE_COLS.map((col) => col.label).filter(Boolean)).toEqual(DOCUMENTED_ORDER);
|
||||
});
|
||||
|
||||
it("renders row cells under the matching headers: Status, Completed Date, Comp Doc, Uplift", () => {
|
||||
const row = {
|
||||
id: 7,
|
||||
upliftSummary: { hasUplift: false, pendingCount: 0 },
|
||||
} as WorkOrderTableRow;
|
||||
renderWithProviders(
|
||||
<table>
|
||||
<tbody>
|
||||
<tr data-testid="row">
|
||||
<WoTableRowServiceCells
|
||||
row={row}
|
||||
vendors={[]}
|
||||
pmTypes={[]}
|
||||
handlers={{} as unknown as WoTableRowHandlers}
|
||||
onPatchRow={vi.fn()}
|
||||
/>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>,
|
||||
{ withAuth: false },
|
||||
);
|
||||
|
||||
const cells = within(screen.getByTestId("row"))
|
||||
.getAllByRole("cell")
|
||||
.map((td) => td.textContent);
|
||||
expect(cells).toEqual([
|
||||
"cell:service",
|
||||
"cell:vendor",
|
||||
"cell:appt",
|
||||
"cell:status",
|
||||
"cell:completed",
|
||||
"cell:doc",
|
||||
"cell:uplift",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
@ -4,10 +4,11 @@ import { expandScalarBoardOps } from "@/domain/work-orders/mappers/expand-scalar
|
|||
import { mapWorkOrderTableRow } from "@/domain/work-orders/mappers/work-order-table-row-mapper";
|
||||
|
||||
describe("COMPLETED DATE board column wiring", () => {
|
||||
it("includes COMPLETED DATE column after COMP DOC", () => {
|
||||
it("includes COMPLETED DATE column between STATUS and COMP DOC (SH-359)", () => {
|
||||
const keys = WO_TABLE_COLS.map((col) => col.key);
|
||||
expect(keys).toContain("completed");
|
||||
expect(keys.indexOf("completed")).toBeGreaterThan(keys.indexOf("doc"));
|
||||
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", () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue