From 33d0ab4fd6fe36c107623093bb6c83af34ea117e Mon Sep 17 00:00:00 2001 From: Codex Review Integration Date: Fri, 18 Sep 2026 13:02:11 -0300 Subject: [PATCH] test(uplifts): scope modal permission and date assertions to what they prove The permission spec asserts the work order renders from the queue item and, separately, that only the approved-on-WO breakdown degrades to Unavailable. The Requested At assertion derives the local calendar day so it holds in every runner time zone. --- .../uplift-detail-modal-permissions.test.tsx | 15 ++++++++++++--- .../uplifts/uplift-detail-modal.test.tsx | 10 +++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/test/app/(protected)/uplifts/uplift-detail-modal-permissions.test.tsx b/src/test/app/(protected)/uplifts/uplift-detail-modal-permissions.test.tsx index 533f3151..a2ab1b9c 100644 --- a/src/test/app/(protected)/uplifts/uplift-detail-modal-permissions.test.tsx +++ b/src/test/app/(protected)/uplifts/uplift-detail-modal-permissions.test.tsx @@ -128,10 +128,19 @@ describe("UpliftDetailModal permission failures (Dispatcher 403)", () => { expect(within(workOrder).getByText("Gateway Plumbing · Tom Tech")).toBeInTheDocument(); expect(within(workOrder).getByText("Apr 10, 2026")).toBeInTheDocument(); expect(within(workOrder).queryByText("Unavailable")).not.toBeInTheDocument(); + expect(toastMocks.error).not.toHaveBeenCalled(); + }); - await waitFor(() => { - expect(screen.getAllByText("Unavailable").length).toBeGreaterThanOrEqual(3); - }); + it("marks the approved-on-WO breakdown unavailable without a toast and keeps Revoke admin-only", async () => { + renderWithGovernedClient(); + + const request = screen.getByRole("region", { name: "Uplift request" }); + for (const label of ["Auto-approved (within allowance)", "Admin-approved", "Total"]) { + const row = within(request).getByText(label).parentElement as HTMLElement; + await waitFor(() => { + expect(within(row).getByText("Unavailable")).toBeInTheDocument(); + }); + } const revoke = screen.getByRole("button", { name: "Revoke" }); expect(revoke).toBeDisabled(); diff --git a/src/test/app/(protected)/uplifts/uplift-detail-modal.test.tsx b/src/test/app/(protected)/uplifts/uplift-detail-modal.test.tsx index ef1b683b..4c999d2b 100644 --- a/src/test/app/(protected)/uplifts/uplift-detail-modal.test.tsx +++ b/src/test/app/(protected)/uplifts/uplift-detail-modal.test.tsx @@ -135,7 +135,15 @@ describe("UpliftDetailModal", () => { const request = section("Uplift request"); expect(fieldValue(request, "Requested By")).toBe("Gateway"); - expect(fieldValue(request, "Requested At")).toMatch(/^Jan 15, 2026 · \d{1,2}:\d{2} [AP]M$/u); + // The instant renders in the viewer's zone, so the calendar day is derived, not fixed. + const localDay = new Date(baseItem.requestedAt).toLocaleDateString("en-US", { + month: "short", + day: "numeric", + year: "numeric", + }); + expect(fieldValue(request, "Requested At")).toMatch( + new RegExp(`^${localDay} · \\d{1,2}:\\d{2} [AP]M$`, "u"), + ); expect(screen.getByTestId("uplift-justification")).toHaveTextContent( "Scope grew after inspection", );