mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 16:19:01 +00:00
- SH-336: add the dispatcher-scope picker (All / My WOs / individual) for Scheduler/Admin via a new viewAllDispatchersOnDashboard role gate, a static 'My WOs' label for Dispatcher, and hide the dispatcher tables (and skip their queries) when the viewer cannot see all dispatchers. Scope drives dispatcherId on stats, workload, performance, and regions (SH-347 contract). - SH-352: add the Status Distribution module with its empty state and status drill-down. - SH-347: show Assigned/Completed counts and colour the completion rate (green >=90, amber 70-89, red <70) on Dispatcher Performance. - SH-348: drill a region bar into the board region filter; hold the unconfirmed 'Unmapped/Other' bucket off the chart. - SH-349: label Vendor Insights as all-time, company-wide. - Make the drilldown-filters effect fire only on URL change; add a deterministic clock to the status-drilldown test; add the dashboard visual regression spec and baselines.
29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { canViewAllDispatchersOnDashboard, isAdminUser } from "@/lib/auth/user-utils";
|
|
|
|
describe("isAdminUser", () => {
|
|
it("returns true when Admin appears in roles", () => {
|
|
expect(isAdminUser("Admin")).toBe(true);
|
|
expect(isAdminUser("Dispatcher,Admin")).toBe(true);
|
|
expect(isAdminUser(" admin ")).toBe(true);
|
|
});
|
|
|
|
it("returns false for non-admin roles", () => {
|
|
expect(isAdminUser("Dispatcher")).toBe(false);
|
|
expect(isAdminUser(undefined)).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("canViewAllDispatchersOnDashboard", () => {
|
|
it("grants the dashboard picker to Admin and Scheduler", () => {
|
|
expect(canViewAllDispatchersOnDashboard("Admin")).toBe(true);
|
|
expect(canViewAllDispatchersOnDashboard("Scheduler")).toBe(true);
|
|
expect(canViewAllDispatchersOnDashboard("Dispatcher, Scheduler")).toBe(true);
|
|
});
|
|
|
|
it("locks a Dispatcher (and unknown roles) to their own work orders", () => {
|
|
expect(canViewAllDispatchersOnDashboard("Dispatcher")).toBe(false);
|
|
expect(canViewAllDispatchersOnDashboard("Technician")).toBe(false);
|
|
expect(canViewAllDispatchersOnDashboard(undefined)).toBe(false);
|
|
});
|
|
});
|