// @vitest-environment jsdom // // The legal pages are written out once per language (a document, not UI strings — see LegalLayout). // What keeps the two from drifting apart is this: both languages must have the SAME sections, in the // same order, by anchor — so a section added to one (as the log sections were) cannot be // missing from the other, and a link to `/privacy#diagnostics` lands in either language. import { describe, expect, it, vi } from "vitest"; import { cleanup, render } from "@testing-library/react"; import type { ComponentType } from "react"; vi.mock("../../lib/http", () => ({ send: () => Promise.resolve({ ok: false }) })); import { PrivacyEn, PrivacyHu } from "./PrivacyPolicy"; import { TermsEn, TermsHu } from "./Terms"; const sections = (Body: ComponentType) => { const { container } = render(); const ids = [...container.querySelectorAll("h2")].map((h) => h.id); cleanup(); return ids; }; describe("legal pages", () => { it.each([ ["privacy", PrivacyEn, PrivacyHu], ["terms", TermsEn, TermsHu], ])("%s has the same sections in Hungarian and English", (_name, En, Hu) => { const en = sections(En); expect(en.every(Boolean)).toBe(true); expect(sections(Hu)).toEqual(en); }); it("the privacy policy has the section the diagnostics consent links to", () => { expect(sections(PrivacyEn)).toContain("diagnostics"); }); });