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("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",
);
});
});