Hold /privacy behind a flag until counsel reads it, and fix leftover legal and email copy.
This commit is contained in:
1 parent
ead6c8f716
commit
072e5362f5
43 files changed
+548
-191
No files matched your search
@@ -2,10 +2,14 @@ import { describe, expect, test, vi } from "vitest";
|
||||
import { screen } from "@testing-library/react";
|
||||
import { renderWithProviders as render } from "../utils/test-utils";
|
||||
import PrivacyPage from "../../app/(marketing)/privacy/page";
|
||||
import TermsPage from "../../app/(marketing)/terms/page";
|
||||
import CookiesPage from "../../app/(marketing)/cookies/page";
|
||||
import LegalDocumentPage from "../../app/(marketing)/_components/LegalDocumentPage";
|
||||
import { legalPathForSlug } from "../../lib/legalSyntheticPost";
|
||||
import messages from "../../messages/en/index";
|
||||
|
||||
vi.mock("../../lib/requestSiteOrigin", () => ({
|
||||
getRequestSiteOrigin: async () => "https://communityrule.info",
|
||||
}));
|
||||
|
||||
vi.mock("../../app/components/sections/ContentBanner", () => ({
|
||||
default: ({ post, variant, updatedLabel }) => (
|
||||
<section data-testid="content-banner" data-variant={variant}>
|
||||
@@ -21,6 +25,18 @@ vi.mock("../../app/components/sections/ContentBanner", () => ({
|
||||
),
|
||||
}));
|
||||
|
||||
async function renderLegalPage(
|
||||
slug: "privacy" | "terms" | "cookies",
|
||||
page: (typeof messages.pages)[typeof slug],
|
||||
) {
|
||||
const ui = await LegalDocumentPage({
|
||||
slug,
|
||||
path: legalPathForSlug(slug),
|
||||
page,
|
||||
});
|
||||
return render(ui);
|
||||
}
|
||||
|
||||
describe("legal document pages", () => {
|
||||
test("privacy copy names Umami and cookieless counts", () => {
|
||||
const collect = messages.pages.privacy.sections.find(
|
||||
@@ -30,8 +46,32 @@ describe("legal document pages", () => {
|
||||
expect(collect?.paragraphs.join(" ")).toMatch(/sets no cookies/);
|
||||
});
|
||||
|
||||
test("privacy page covers hosting, recommendations, and campus privacy", () => {
|
||||
render(<PrivacyPage />);
|
||||
test("privacy copy does not say stakeholder or wizard", () => {
|
||||
const text = JSON.stringify(messages.pages.privacy);
|
||||
expect(text).not.toMatch(/stakeholder/i);
|
||||
expect(text).not.toMatch(/wizard/i);
|
||||
});
|
||||
|
||||
test("privacy page 404s while the flag is off", () => {
|
||||
const previous = process.env.ENABLE_PRIVACY_POLICY;
|
||||
const previousPublic = process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY;
|
||||
delete process.env.ENABLE_PRIVACY_POLICY;
|
||||
delete process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY;
|
||||
try {
|
||||
expect(() => PrivacyPage()).toThrow("NEXT_NOT_FOUND");
|
||||
} finally {
|
||||
if (previous === undefined) delete process.env.ENABLE_PRIVACY_POLICY;
|
||||
else process.env.ENABLE_PRIVACY_POLICY = previous;
|
||||
if (previousPublic === undefined) {
|
||||
delete process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY;
|
||||
} else {
|
||||
process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY = previousPublic;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("privacy page covers hosting, recommendations, and campus privacy", async () => {
|
||||
await renderLegalPage("privacy", messages.pages.privacy);
|
||||
const page = messages.pages.privacy;
|
||||
|
||||
expect(screen.getByTestId("content-banner")).toHaveAttribute(
|
||||
@@ -71,8 +111,8 @@ describe("legal document pages", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("terms page covers licenses and the templates API, not ranking", () => {
|
||||
render(<TermsPage />);
|
||||
test("terms page covers licenses and the templates API, not ranking", async () => {
|
||||
await renderLegalPage("terms", messages.pages.terms);
|
||||
const page = messages.pages.terms;
|
||||
|
||||
expect(
|
||||
@@ -105,8 +145,8 @@ describe("legal document pages", () => {
|
||||
).toHaveAttribute("href", "/api/templates");
|
||||
});
|
||||
|
||||
test("cookies settings page explains there are no optional cookies", () => {
|
||||
render(<CookiesPage />);
|
||||
test("cookies settings page explains there are no optional cookies", async () => {
|
||||
await renderLegalPage("cookies", messages.pages.cookies);
|
||||
const page = messages.pages.cookies;
|
||||
|
||||
expect(
|
||||
@@ -115,11 +155,15 @@ describe("legal document pages", () => {
|
||||
expect(
|
||||
screen.getByRole("heading", { level: 2, name: "The session cookie" }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole("heading", { level: 2, name: "The claim cookie" }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(/There are no advertising or analytics cookies to turn off/),
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByText(/cr_session/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/cr_rule_claim/)).toBeInTheDocument();
|
||||
expect(JSON.stringify(page)).not.toMatch(/magic link/i);
|
||||
expect(
|
||||
screen.getAllByRole("link", { name: "Privacy Policy" })[0],
|
||||
).toHaveAttribute("href", "/privacy");
|
||||
|
||||
Reference in new issue
Block a user