mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 05:22:04 +00:00
30 lines
1,003 B
TypeScript
30 lines
1,003 B
TypeScript
|
|
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);
|
||
|
|
});
|
||
|
|
});
|