mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 06:32:05 +00:00
37 lines
1.2 KiB
TypeScript
37 lines
1.2 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 incompleteRow = {
|
|
id: "wo-1",
|
|
status: "Scheduled",
|
|
dispatcherId: "",
|
|
dispatcherName: "",
|
|
company: "",
|
|
tech: "",
|
|
completedDate: "",
|
|
woNumber: "",
|
|
pm: "",
|
|
docStatus: "",
|
|
mediaCount: 0,
|
|
type: "PM",
|
|
} as WorkOrderTableRow;
|
|
|
|
describe("StatusCell closability gate", () => {
|
|
it("does not submit Completed when required work-order data is missing", () => {
|
|
const onChangeStatus = vi.fn();
|
|
|
|
render(
|
|
<StatusCell wo={incompleteRow} onChangeStatus={onChangeStatus} onOpenSlideOver={vi.fn()} />,
|
|
);
|
|
|
|
fireEvent.click(screen.getByRole("button", { name: /scheduled/i }));
|
|
const completed = screen.getByRole("button", { name: /^completed$/i });
|
|
|
|
expect(completed.hasAttribute("disabled")).toBe(true);
|
|
expect(completed.getAttribute("title") ?? "").toContain("Missing:");
|
|
fireEvent.click(completed);
|
|
expect(onChangeStatus).not.toHaveBeenCalledWith("Completed");
|
|
});
|
|
});
|