shoc-frontend-new/src/test/app/(protected)/workorders/status-cell-past-due-copy.test.tsx
Arthur Bassi 9cc9bc4dfb feat(work-orders): align inline lifecycle transitions with AAP
Use the prototype status list and gates on the board and wizard.
Auto-derive Scheduled or Pending from a concrete schedule date.
2026-09-02 15:11:31 -03:00

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();
});
});