From 27ddeb29037ab2fb6d52589025f11c19586d5d0a Mon Sep 17 00:00:00 2001 From: Arthur Bassi Date: Thu, 3 Sep 2026 16:10:59 -0300 Subject: [PATCH 1/2] feat(work-orders): align inline type correction with the board AAP Keep type correction on the board: Type & severity, SEV toast, and audit copy. --- .../table/cells/severity-options-list.tsx | 4 + .../list/table/cells/type-cell.tsx | 4 +- .../list/table/cells/type-severity-modal.tsx | 21 +++- .../list/table/save-existing-row-type.ts | 20 ++++ .../list/table/wo-table-row-cells.tsx | 3 +- .../utils/board-audit-action-rules.ts | 35 ++++++ .../work-orders/utils/severity-escalation.ts | 20 ++++ .../workorders/save-existing-row-type.test.ts | 42 +++++++ .../(protected)/workorders/type-cell.test.tsx | 96 ++++++++++++++++ .../use-work-order-table-mutations.test.tsx | 108 ++++++++++++++++++ .../utils/format-board-audit-action.test.ts | 22 ++++ .../utils/severity-escalation.test.ts | 32 ++++++ .../utils/table-filter-utils.test.ts | 16 +++ .../work-orders/utils/work-order-lock.test.ts | 5 + 14 files changed, 425 insertions(+), 3 deletions(-) create mode 100644 src/app/(protected)/workorders/_components/list/table/save-existing-row-type.ts create mode 100644 src/domain/work-orders/utils/severity-escalation.ts create mode 100644 src/test/app/(protected)/workorders/save-existing-row-type.test.ts create mode 100644 src/test/app/(protected)/workorders/type-cell.test.tsx create mode 100644 src/test/domain/work-orders/utils/severity-escalation.test.ts diff --git a/src/app/(protected)/workorders/_components/list/table/cells/severity-options-list.tsx b/src/app/(protected)/workorders/_components/list/table/cells/severity-options-list.tsx index d78961af..656b5baf 100644 --- a/src/app/(protected)/workorders/_components/list/table/cells/severity-options-list.tsx +++ b/src/app/(protected)/workorders/_components/list/table/cells/severity-options-list.tsx @@ -71,6 +71,10 @@ export function SeverityField({ value, onSelect }: SeverityFieldProps) { sx={{ fontSize: 12, fontWeight: 600, marginBottom: "4px" }} > Severity (from APM) + + {" "} + * + + ), +})); +vi.mock("@/app/(protected)/workorders/_components/list/table/cells/date-cell", () => ({ + DateCell: () => null, +})); +vi.mock("@/app/(protected)/workorders/_components/list/table/cells/due-date-cell", () => ({ + DueDateCell: () => null, +})); +vi.mock("@/app/(protected)/workorders/_components/list/table/cells/assigned-to-cell", () => ({ + AssignedToCell: () => null, +})); + +const row = { id: 7, woNumber: "00000024965", severity: 3 } as WorkOrderTableRow; + +describe("WoTableRowCells type persist", () => { + it("forwards type save through patch onSuccess instead of onPatchRow", () => { + const onPatch = vi.fn(); + const onPatchRow = vi.fn(); + const handlers = { onPatch } as unknown as WoTableRowHandlers; + + renderWithProviders( + + + + + + +
, + { withAuth: false }, + ); + + fireEvent.click(screen.getByRole("button", { name: "persist-type" })); + + expect(onPatchRow).not.toHaveBeenCalled(); + expect(onPatch).toHaveBeenCalledWith( + 7, + { type: "Emergency", severity: 1 }, + expect.objectContaining({ onSuccess: expect.any(Function) }), + ); + }); +}); diff --git a/src/test/app/(protected)/workorders/wo-table-row-completed-lock.test.tsx b/src/test/app/(protected)/workorders/wo-table-row-completed-lock.test.tsx index 2c02e58c..7ced9b99 100644 --- a/src/test/app/(protected)/workorders/wo-table-row-completed-lock.test.tsx +++ b/src/test/app/(protected)/workorders/wo-table-row-completed-lock.test.tsx @@ -133,4 +133,56 @@ describe("WoTableRow completed selective lock", () => { expect(screen.queryByRole("button", { name: /in progress/i })).not.toBeInTheDocument(); expect(handlers.onPatch).not.toHaveBeenCalled(); }); + + it("does not expose the type picker on a Completed row", () => { + const row = makeRow(); + renderWithProviders( + + + + +
, + { withAuth: false }, + ); + + expect(screen.queryByRole("button", { name: "Type of WO, PM" })).not.toBeInTheDocument(); + expect(screen.getByText("PM")).toBeInTheDocument(); + }); + + it("does not expose the type picker on a Canceled row", () => { + const row = makeRow({ status: "Canceled" }); + renderWithProviders( + + + + +
, + { withAuth: false }, + ); + + expect(screen.queryByRole("button", { name: "Type of WO, PM" })).not.toBeInTheDocument(); + expect(screen.getByText("PM")).toBeInTheDocument(); + }); });