mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 06:53:12 +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.
59 lines
2.2 KiB
TypeScript
59 lines
2.2 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import {
|
|
avetaPendingDrilldownSearch,
|
|
scheduledTomorrowDrilldownSearch,
|
|
workOrderDrilldownUrl,
|
|
workOrderRangeDrilldownSearch,
|
|
workOrderStatusDrilldownSearch,
|
|
} from "@/domain/dashboard/utils/work-order-drilldown-links";
|
|
|
|
describe("work-order drilldown links", () => {
|
|
afterEach(() => {
|
|
vi.useRealTimers();
|
|
});
|
|
|
|
it("schedules the tomorrow drilldown on the business clock", () => {
|
|
const search = scheduledTomorrowDrilldownSearch("2026-09-16");
|
|
|
|
expect(search.get("dateFrom")).toBe("2026-09-17");
|
|
expect(search.get("dateTo")).toBe("2026-09-17");
|
|
});
|
|
|
|
it("builds the Aveta Pending drilldown per SH-294", () => {
|
|
const search = avetaPendingDrilldownSearch("2026-09-16");
|
|
const statuses = (search.get("statuses") ?? "").split(",");
|
|
|
|
expect(search.get("dateFrom")).toBe("2026-09-16");
|
|
expect(search.get("dateTo")).toBe("2026-09-17");
|
|
expect(search.get("aveta")).toBe("1");
|
|
// `docs=No` is the completion-document status, not the Aveta document, so it
|
|
// must not be part of the Aveta Pending drilldown (SH-294 / backend#138).
|
|
expect(search.get("docs")).toBeNull();
|
|
expect(statuses).toContain("Scheduled");
|
|
expect(statuses).not.toContain("Completed");
|
|
});
|
|
|
|
it("carries the range into status drilldowns", () => {
|
|
// "today" resolves against the business clock, so pin it (midday EDT on
|
|
// 2026-09-16 → 2026-09-16 in America/New_York) to keep the test deterministic.
|
|
vi.useFakeTimers();
|
|
vi.setSystemTime(new Date("2026-09-16T16:00:00Z"));
|
|
|
|
const search = workOrderStatusDrilldownSearch("Scheduled", "today");
|
|
|
|
expect(search.get("dateFrom")).toBe("2026-09-16");
|
|
expect(search.get("dateTo")).toBe("2026-09-16");
|
|
expect(search.get("statuses")).toBe("Scheduled");
|
|
});
|
|
|
|
it("omits dates for the all-time range", () => {
|
|
expect(workOrderRangeDrilldownSearch("all-time").toString()).toBe("");
|
|
});
|
|
|
|
it("renders plain or query-bearing work order URLs", () => {
|
|
expect(workOrderDrilldownUrl(new URLSearchParams())).toBe("/workorders");
|
|
expect(workOrderDrilldownUrl(new URLSearchParams({ statuses: "Scheduled" }))).toBe(
|
|
"/workorders?statuses=Scheduled",
|
|
);
|
|
});
|
|
});
|