- C1 (issue 1): over target follows VISUAL ticket hours, not the timer. - C2 (issue 24): a Q.C. reject always needs a reason; accept needs an NCR number after a reject without one. - C3 (issue 25): an incomplete unit ITP blocks filing. - C4 (issue 27): prints open the print dialog on the page, no new tab. - C5 (issue 31): filing is blocked while VISUAL shows a work order open; the feed sets vclosed on VISUAL packets. - C6 (issue 8): the data book leaves out the history pages. - C7 (issue 18): the supervisor approves each received short; accept and filing wait for it. - C8 (issue 23): per-department checklists, edited by the department supervisor or Admin, frozen at START. - C9 (issue 32): Q.C. and Clerical may run the stamp check. - C10 (issue 33): the PM screen and reports are for PS-ProjectMgmt and Admin only. - C11 (issue 36): the Stall screen lists the packets assigned to the welder, at the supervisor's stall. Migration 0011. Docs: PLAN (also issue 9 confirmed, issue 4 asked), POLICY, SECURITY, SCHEMA, FEED, README, CHANGELOG. Co-Authored-By: Claude Opus 5.5 <[email protected]>
51 lines
2.2 KiB
TypeScript
51 lines
2.2 KiB
TypeScript
import { fireEvent, screen, waitFor, within } from "@testing-library/react";
|
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { LAST_SCREEN_KEY } from "../auth/roles";
|
|
import { memoryStorage } from "../screens/supervisor/memoryStorage";
|
|
import { DEPARTMENTS, makeMe, renderApp } from "../test/auth";
|
|
import { mockFetch } from "../test/fetchMock";
|
|
|
|
const LOU = makeMe({ roles: ["shop:03:lead"], screens: ["supervisor", "stall"], user: { sam_account: "lead.lou", display_name: "Lou Lead" } });
|
|
|
|
function routes() {
|
|
return {
|
|
"/api/auth/me": { body: LOU },
|
|
"/api/departments": { body: DEPARTMENTS },
|
|
"/api/shop/board": { body: {} },
|
|
"/api/stall/mine": { body: { mine: [], submitted: [] } },
|
|
"/api/projects": { body: [] },
|
|
};
|
|
}
|
|
|
|
beforeEach(() => {
|
|
vi.stubGlobal("localStorage", memoryStorage());
|
|
});
|
|
|
|
describe("RoleSwitcher", () => {
|
|
it("lands on the first screen, and remembers the screen picked", async () => {
|
|
mockFetch(routes());
|
|
renderApp("/");
|
|
const nav = await screen.findByRole("navigation", { name: "Screens" });
|
|
await waitFor(() => expect(within(nav).getByRole("button", { name: "Supervisor" })).toHaveAttribute("aria-pressed", "true"));
|
|
fireEvent.click(within(nav).getByRole("button", { name: "Weld Stall" }));
|
|
expect(window.localStorage.getItem(LAST_SCREEN_KEY)).toBe("stall");
|
|
expect(await screen.findByText("Your supervisor assigns packets to you.")).toBeInTheDocument();
|
|
});
|
|
|
|
it("lands on the remembered screen when it is still allowed", async () => {
|
|
window.localStorage.setItem(LAST_SCREEN_KEY, "stall");
|
|
mockFetch(routes());
|
|
renderApp("/");
|
|
const nav = await screen.findByRole("navigation", { name: "Screens" });
|
|
await waitFor(() => expect(within(nav).getByRole("button", { name: "Weld Stall" })).toHaveAttribute("aria-pressed", "true"));
|
|
});
|
|
|
|
it("ignores a remembered screen the user no longer has", async () => {
|
|
window.localStorage.setItem(LAST_SCREEN_KEY, "warehouse");
|
|
mockFetch(routes());
|
|
renderApp("/");
|
|
const nav = await screen.findByRole("navigation", { name: "Screens" });
|
|
await waitFor(() => expect(within(nav).getByRole("button", { name: "Supervisor" })).toHaveAttribute("aria-pressed", "true"));
|
|
});
|
|
});
|