Home mais curta (hero, vitrine de clientes, sobre, serviços, IA resumida, depoimentos e contato), faixa de clientes e telas reais no hero, sem números do GitHub. Barra de cookies fina, WhatsApp fixo no celular, formulário com e-mail opcional e alternativa por e-mail, página /ia, eventos de e-mail, redes e currículo e conversão do Ads opcional por variável. Rodapé em 3 colunas. Remove componentes órfãos (LighthouseMetrics, Skills, Experience, contagem do GitHub).
68 lines
2.2 KiB
TypeScript
68 lines
2.2 KiB
TypeScript
/**
|
|
* @jest-environment-options {"url": "https://www.evandro.dev.br/"}
|
|
*/
|
|
import { act, render, screen } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
import type { ComponentProps } from "react";
|
|
import { openCookiePreferences } from "@/lib/analytics";
|
|
import GoogleAnalytics from "./GoogleAnalytics";
|
|
|
|
/**
|
|
* Caminho de GoogleAnalytics (expireAnalyticsCookies) quando o site roda em um subdomínio de evandro.dev.br:
|
|
* o cookie _ga é expirado no host e também no domínio raiz, cada um com seu atributo Domain.
|
|
*/
|
|
|
|
jest.mock("next/script", () => ({
|
|
__esModule: true,
|
|
default: ({
|
|
strategy: _strategy,
|
|
...props
|
|
}: ComponentProps<"script"> & { strategy?: string }) => <script {...props} />,
|
|
}));
|
|
|
|
const CONSENT_KEY = "evandro.analytics-consent.v1";
|
|
|
|
function setCookie(value: string) {
|
|
// biome-ignore lint/suspicious/noDocumentCookie: JSDOM cookie setup is the behavior boundary exercised by revocation.
|
|
document.cookie = value;
|
|
}
|
|
|
|
beforeEach(() => {
|
|
jest.replaceProperty(process.env, "NODE_ENV", "production");
|
|
localStorage.setItem(CONSENT_KEY, "granted");
|
|
});
|
|
|
|
afterEach(() => {
|
|
jest.restoreAllMocks();
|
|
localStorage.clear();
|
|
});
|
|
|
|
it("path: host is a subdomain of the site -> expires _ga on the path, on the host and on the root domain", async () => {
|
|
const user = userEvent.setup();
|
|
expect(window.location.hostname).toBe("www.evandro.dev.br");
|
|
setCookie("_ga=1; Path=/");
|
|
render(
|
|
<>
|
|
<button type="button" onClick={openCookiePreferences}>
|
|
Preferências de cookies
|
|
</button>
|
|
<GoogleAnalytics />
|
|
</>,
|
|
);
|
|
await screen.findByTestId("google-analytics-script");
|
|
const cookieWrites = jest.spyOn(document, "cookie", "set");
|
|
|
|
await user.click(
|
|
screen.getByRole("button", { name: "Preferências de cookies" }),
|
|
);
|
|
await act(async () => {});
|
|
await user.click(screen.getByRole("button", { name: "Recusar" }));
|
|
|
|
const writes = cookieWrites.mock.calls.map(([value]) => String(value));
|
|
expect(writes).toHaveLength(3);
|
|
expect(writes[0]).toMatch(/^_ga=; Max-Age=0;/);
|
|
expect(writes[0]).not.toContain("Domain=");
|
|
expect(writes[1]).toMatch(/; Domain=www\.evandro\.dev\.br$/);
|
|
expect(writes[2]).toMatch(/; Domain=evandro\.dev\.br$/);
|
|
});
|