mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 05:43:12 +00:00
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.
This commit is contained in:
parent
3c84d851c0
commit
33d0ab4fd6
2 changed files with 21 additions and 4 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue