import { render, screen } from "@testing-library/react"; import NotFound, { metadata } from "./not-found"; describe("not-found", () => { it("has no canonical (the home one does not apply to a 404) and no generic robots tag of its own", () => { // o Next já escreve no 404: repeti-lo duplicaria a tag expect(metadata.alternates).toEqual({ canonical: null }); expect(metadata.robots).not.toHaveProperty("index"); expect(metadata.robots).not.toHaveProperty("follow"); }); it("has its own Open Graph and Twitter card, with no url (the home one does not apply to a page that does not exist)", () => { expect(metadata.openGraph).toEqual({ locale: "pt_BR", title: "Página não encontrada", description: "A página que você procura não existe ou foi movida.", siteName: "Evandro.dev.br", type: "website", }); expect(metadata.openGraph).not.toHaveProperty("url"); expect(metadata.twitter).toMatchObject({ card: "summary_large_image", title: "Página não encontrada", description: "A página que você procura não existe ou foi movida.", }); expect(metadata.twitter).not.toHaveProperty("url"); }); it("keeps Googlebot out, since the root layout lets it index", () => { expect(metadata.robots).toEqual({ googleBot: { index: false, follow: false }, }); }); it("explains the problem and offers a way back, in Portuguese", () => { render(); expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("404"); expect( screen.getByRole("heading", { level: 2, name: "Página não encontrada" }), ).toBeVisible(); expect( screen.getByRole("link", { name: "Voltar ao início" }), ).toHaveAttribute("href", "/"); expect(screen.getByRole("link", { name: "Ver os cases" })).toHaveAttribute( "href", "/cases", ); }); it("uses no lime: the lime is only for the contact action", () => { const { container } = render(); expect(container.innerHTML).not.toMatch(/slash|ccff00/i); }); });