mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 00:02:06 +00:00
39 lines
1.3 KiB
TypeScript
39 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();
|
||
|
|
});
|
||
|
|
});
|