mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 16:19:01 +00:00
Use the prototype status list and gates on the board and wizard. Auto-derive Scheduled or Pending from a concrete schedule date.
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { fireEvent, render, screen } from "@testing-library/react";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { StatusCell } from "@/app/(protected)/workorders/_components/list/table/cells/status-cell";
|
|
import type { WorkOrderTableRow } from "@/domain/work-orders/types/work-order-table-row";
|
|
|
|
const pastDueRow = {
|
|
id: "wo-1",
|
|
status: "Scheduled",
|
|
dispatcherId: "",
|
|
dispatcherName: "",
|
|
company: "",
|
|
vendorId: "",
|
|
tech: "",
|
|
completedDate: "",
|
|
woNumber: "",
|
|
pm: "",
|
|
docStatus: "",
|
|
mediaCount: 0,
|
|
type: "PM",
|
|
isPastDue: true,
|
|
scheduledOn: "2026-06-01",
|
|
dueDate: "2026-08-01",
|
|
} as WorkOrderTableRow;
|
|
|
|
describe("StatusCell Past Due copy", () => {
|
|
it("directs the dispatcher to update Schedule On, not Due Date", () => {
|
|
render(<StatusCell wo={pastDueRow} onChangeStatus={vi.fn()} onOpenSlideOver={vi.fn()} />);
|
|
|
|
const trigger = screen.getByRole("button", { name: /past due/i });
|
|
expect(trigger.getAttribute("title") ?? "").toContain("Reschedule to unlock status updates");
|
|
expect(trigger.getAttribute("title") ?? "").not.toMatch(/due date/i);
|
|
|
|
fireEvent.click(trigger);
|
|
|
|
expect(
|
|
screen.getByText(/a new date must be scheduled before the status can be updated/i),
|
|
).toBeTruthy();
|
|
expect(screen.getByRole("button", { name: /reschedule/i })).toBeTruthy();
|
|
expect(screen.queryByText(/due date/i)).toBeNull();
|
|
});
|
|
});
|