import { render, screen, within } from "@testing-library/react"; import AiPage, { metadata } from "./page"; it("uses its own title without the site suffix being added twice", () => { expect(metadata.title).toEqual({ absolute: "Começou um sistema com IA? Revisão e continuidade | Evandro Fonseca Junior", }); expect(metadata).toMatchObject({ description: expect.any(String), alternates: { canonical: "https://evandro.dev.br/ia" }, }); }); it("keeps the full AI content, with the cited incidents summarized only here", () => { render(); expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent( "Começou um sistema com IA? Dá para partir daí.", ); for (const heading of [ "Se a IA cria um sistema, por que contratar um desenvolvedor?", "O que casos documentados ensinam", "E a LGPD?", ]) { expect(screen.getByRole("heading", { name: heading })).toBeInTheDocument(); } for (const incident of [/Lovable/, /Replit/, /Base44/]) { expect(screen.getByRole("heading", { name: incident })).toBeInTheDocument(); } expect( screen.getByRole("link", { name: "Reportagem da Semafor (em inglês)" }), ).toHaveAttribute("rel", "noopener noreferrer"); }); it("offers WhatsApp conversations about reviewing an AI-built system", () => { render(); const links = screen .getAllByRole("link") .filter((link) => link.getAttribute("href")?.startsWith("https://wa.me/")); expect(links.map((link) => link.textContent)).toEqual([ "Falar sobre meu sistema", "Avaliar meu projeto", ]); for (const link of links) { const text = new URL(link.getAttribute("href") ?? "").searchParams.get( "text", ); // a mensagem tem de formar uma frase: "Quero conversar sobre a revisão de um sistema feito com IA." expect(text).toContain( "Quero conversar sobre a revisão de um sistema feito com IA.", ); } }); it("has breadcrumb navigation back to the home", () => { render(); const breadcrumb = screen.getByRole("navigation", { name: "Breadcrumb" }); expect( within(breadcrumb).getByRole("link", { name: "Início" }), ).toHaveAttribute("href", "/"); expect(within(breadcrumb).getByText("IA no desenvolvimento")).toHaveAttribute( "aria-current", "page", ); });