import { render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { SignoffSection } from "@/app/v/[token]/dispatch/_components/signoff-section"; function renderSection(overrides: Partial> = {}) { return render( , ); } describe("SignoffSection", () => { it("shows status-neutral locked copy when submission is locked", () => { renderSection({ submissionLocked: true }); expect(screen.getByText(/Signoff is unavailable for this dispatch/i)).toBeInTheDocument(); expect(screen.queryByText(/refused/i)).not.toBeInTheDocument(); expect(screen.queryByRole("button", { name: "Submit Signoff" })).not.toBeInTheDocument(); }); it("shows the submission form when unlocked", () => { renderSection(); expect(screen.getByRole("button", { name: "Submit Signoff" })).toBeInTheDocument(); }); it("shows an existing signoff even while locked", () => { renderSection({ signoffType: "vendor", nameLabel: "Your name", submissionLocked: true, existing: [{ signoffType: "vendor", name: "Grace Hopper", signatureMethod: "typed" }], }); expect(screen.getByText("Grace Hopper")).toBeInTheDocument(); expect(screen.queryByText(/Signoff is unavailable/i)).not.toBeInTheDocument(); expect(screen.queryByRole("button", { name: "Submit Signoff" })).not.toBeInTheDocument(); }); });