shoc-frontend-new/src/test/app/(protected)/workorders/status-cell-past-due-copy.test.tsx
Arthur Bassi 8d1a3340a8 fix(work-orders): align Past Due overlay and copy to Schedule On (SH-185)
Dispatchers were told to change Due Date, which cannot clear Past Due.
Drive the table overlay from Schedule On and match the 422 contract.
2026-08-18 09:20:18 -03:00

38 lines
1.3 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: "",
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 (SH-185)", () => {
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("Schedule On");
expect(trigger.getAttribute("title") ?? "").not.toMatch(/due date/i);
fireEvent.click(trigger);
expect(screen.getByText(/update schedule on before the status can be updated/i)).toBeTruthy();
expect(screen.getByRole("button", { name: /update schedule on/i })).toBeTruthy();
expect(screen.queryByText(/due date/i)).toBeNull();
});
});