shoc-frontend-new/src/test/app/(protected)/workorders/comp-doc-cell-service-gate.test.tsx

30 lines
1,003 B
TypeScript
Raw Normal View History

import { render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { CompDocCell } from "@/app/(protected)/workorders/_components/list/table/cells/comp-doc-cell";
describe("CompDocCell service gate", () => {
it("shows a disabled placeholder when no service is selected", () => {
const onOpen = vi.fn();
render(<CompDocCell status="No" woType="PM" pm="" onOpen={onOpen} onOpenMedia={vi.fn()} />);
expect(screen.getByText("Select service")).toBeInTheDocument();
expect(screen.queryByRole("button", { name: /draft|view doc|n\/n/i })).not.toBeInTheDocument();
});
it("opens CompDoc when a service is selected", () => {
const onOpen = vi.fn();
render(
<CompDocCell
status="No"
woType="PM"
pm="HVAC Inspection"
onOpen={onOpen}
onOpenMedia={vi.fn()}
/>,
);
screen.getByRole("button", { name: /draft/i }).click();
expect(onOpen).toHaveBeenCalledTimes(1);
});
});