import { render, screen } from "@testing-library/react"; import { setNavigation } from "@/__mocks__/next/navigation"; import { CaseCapabilitiesSection } from "./CaseCapabilitiesSection"; /** * Testes de caminhos-base de CaseCapabilitiesSection: com itens (a lista sob o título do cliente ou do laboratório, sem * botão de contato: o fecho do case vem logo depois e é o único convite, para não haver dois "Chamar no WhatsApp" * seguidos) e sem itens (a seção não aparece, tenha o case site no ar ou captura ou não). */ beforeEach(() => { setNavigation({ pathname: "/cases" }); }); const capabilities = [ "O dono muda os preços sem pedir a ninguém.", "O cliente pede pelo WhatsApp com a mensagem pronta.", ]; describe("CaseCapabilitiesSection", () => { it("path: items -> the list under the client title, with no contact button of its own", () => { const { container } = render( , ); expect( screen.getByRole("heading", { level: 2, name: "O que o cliente passou a poder fazer", }), ).toBeVisible(); for (const item of capabilities) { expect(screen.getByText(item)).toBeVisible(); } // o botão "Chamar no WhatsApp" é do fecho do case (CaseContactSection), não desta seção expect(screen.queryByRole("link")).toBeNull(); expect(container.querySelectorAll("a")).toHaveLength(0); }); it("path: a laboratory case with items -> the title does not talk about a client", () => { render( , ); expect( screen.getByRole("heading", { level: 2, name: "O que dá para fazer com ele", }), ).toBeVisible(); expect(screen.queryByText(/o cliente passou a poder fazer/i)).toBeNull(); }); it("path: no items -> renders nothing, with no button on its own even when the case has a capture or a site", () => { const { container } = render( , ); expect(container).toBeEmptyDOMElement(); }); it("path: an empty list of items -> renders nothing", () => { const { container } = render( , ); expect(container).toBeEmptyDOMElement(); }); });