58 lines
2.0 KiB
TypeScript
58 lines
2.0 KiB
TypeScript
import { render, screen, within } from "@testing-library/react";
|
|
import PrivacyPage, { metadata } from "./page";
|
|
|
|
it("publishes factual privacy content and a breadcrumb-only JSON-LD graph", () => {
|
|
const { container } = render(<PrivacyPage />);
|
|
|
|
expect(
|
|
screen.getByRole("heading", { level: 1, name: /privacidade/i }),
|
|
).toBeVisible();
|
|
expect(screen.getByText(/evandro\.analytics-consent\.v1/)).toBeVisible();
|
|
expect(screen.getAllByText(/WhatsApp/).length).toBeGreaterThan(0);
|
|
expect(screen.getByText(/nenhuma tag do Google é carregada/i)).toBeVisible();
|
|
expect(screen.getByText(/2026-09-04/)).toBeVisible();
|
|
|
|
const breadcrumb = screen.getByRole("navigation", { name: "Breadcrumb" });
|
|
const breadcrumbLinks = within(breadcrumb).getAllByRole("link");
|
|
expect(breadcrumbLinks.map((link) => link.textContent)).toEqual([
|
|
"Início",
|
|
"Privacidade",
|
|
]);
|
|
expect(breadcrumbLinks[0]).toHaveAttribute("href", "/");
|
|
expect(breadcrumbLinks[1]).toHaveAttribute("href", "/privacidade");
|
|
expect(breadcrumbLinks[1]).toHaveAttribute("aria-current", "page");
|
|
|
|
const scripts = container.querySelectorAll<HTMLScriptElement>(
|
|
'script[type="application/ld+json"]',
|
|
);
|
|
expect(scripts).toHaveLength(1);
|
|
const jsonLd = JSON.parse(scripts[0]?.textContent ?? "{}");
|
|
expect(jsonLd["@graph"]).toHaveLength(1);
|
|
expect(jsonLd["@graph"][0]["@type"]).toBe("BreadcrumbList");
|
|
expect(JSON.stringify(jsonLd)).not.toMatch(
|
|
/Person|Organization|LocalBusiness|ProfessionalService|Service/,
|
|
);
|
|
expect(jsonLd["@graph"][0].itemListElement).toEqual([
|
|
{
|
|
"@type": "ListItem",
|
|
position: 1,
|
|
name: "Início",
|
|
item: "https://evandro.dev.br",
|
|
},
|
|
{
|
|
"@type": "ListItem",
|
|
position: 2,
|
|
name: "Privacidade",
|
|
item: "https://evandro.dev.br/privacidade",
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("uses privacy-specific canonical metadata", () => {
|
|
expect(metadata).toMatchObject({
|
|
title: expect.stringMatching(/privacidade/i),
|
|
description: expect.any(String),
|
|
alternates: { canonical: "https://evandro.dev.br/privacidade" },
|
|
});
|
|
});
|