shoc-frontend-new/src/test/app/(protected)/workorders/comp-doc-cell-service-gate.test.tsx
Arthur Bassi 3004d039aa fix(work-orders): address SH-116 CompDoc review blockers
Gate CompDoc on selected service, use real pm titles only,
make Address editable via location update, and wire media
to the board API with categories instead of blob state.
2026-07-30 09:04:03 -03:00

29 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);
});
});