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
@@ -1,6 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { MAGIC_LINK_TTL_MINUTES } from "../../lib/privacyRetention";
|
||||
import { buildMagicLinkMail } from "../../lib/server/magicLinkMail";
|
||||
import {
|
||||
buildEmailChangeMail,
|
||||
buildMagicLinkMail,
|
||||
} from "../../lib/server/magicLinkMail";
|
||||
|
||||
const VERIFY_URL =
|
||||
"https://communityrule.info/api/auth/magic-link/verify?token=abc";
|
||||
@@ -32,4 +35,46 @@ describe("buildMagicLinkMail", () => {
|
||||
expect(mail.html).not.toContain("Hi ");
|
||||
expect(mail.text).not.toContain("Hi ");
|
||||
});
|
||||
|
||||
it("omits the privacy link while the policy 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 {
|
||||
const off = buildMagicLinkMail({
|
||||
verifyUrl: VERIFY_URL,
|
||||
origin: "https://communityrule.info",
|
||||
});
|
||||
expect(off.html).not.toContain("/privacy");
|
||||
expect(off.text).not.toContain("/privacy");
|
||||
expect(off.html).toContain("/about");
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildEmailChangeMail", () => {
|
||||
const mail = buildEmailChangeMail({
|
||||
verifyUrl: "https://communityrule.info/api/user/email-change/verify?token=abc",
|
||||
origin: "https://communityrule.info",
|
||||
});
|
||||
|
||||
it("matches the login email chrome with CommunityRule copy", () => {
|
||||
expect(mail.subject).toBe("Confirm your new CommunityRule email");
|
||||
expect(mail.html).toContain("background:#000000");
|
||||
expect(mail.html).toContain(">Confirm email</a>");
|
||||
expect(mail.html).toContain("CommunityRule account");
|
||||
expect(mail.text).toContain("CommunityRule account");
|
||||
expect(mail.subject).not.toMatch(/Community Rule/);
|
||||
expect(mail.html).not.toMatch(/Community Rule/);
|
||||
expect(mail.text).not.toMatch(/Community Rule/);
|
||||
});
|
||||
});
|
||||
+11
-3
@@ -100,14 +100,22 @@ describe("resolveMailFrom", () => {
|
||||
it("prefers SMTP_FROM, then CLOUDRON_MAIL_FROM", () => {
|
||||
delete process.env.SMTP_FROM;
|
||||
delete process.env.CLOUDRON_MAIL_FROM;
|
||||
expect(resolveMailFrom()).toBe("noreply@localhost");
|
||||
expect(resolveMailFrom()).toBe("CommunityRule <noreply@localhost>");
|
||||
|
||||
process.env.CLOUDRON_MAIL_FROM = "staging.app@communityrule.info";
|
||||
expect(resolveMailFrom()).toBe("staging.app@communityrule.info");
|
||||
expect(resolveMailFrom()).toBe(
|
||||
"CommunityRule <staging.app@communityrule.info>",
|
||||
);
|
||||
|
||||
process.env.SMTP_FROM = "Community Rule <hello@communityrule.info>";
|
||||
expect(resolveMailFrom()).toBe(
|
||||
"Community Rule <hello@communityrule.info>",
|
||||
"CommunityRule <hello@communityrule.info>",
|
||||
);
|
||||
});
|
||||
|
||||
it("puts CommunityRule on a bare mailbox", () => {
|
||||
delete process.env.SMTP_FROM;
|
||||
process.env.CLOUDRON_MAIL_FROM = "hello@communityrule.info";
|
||||
expect(resolveMailFrom()).toBe("CommunityRule <hello@communityrule.info>");
|
||||
});
|
||||
});
|
||||
@@ -6,6 +6,7 @@ const sendOrganizerInquiryNotificationMock = vi.fn();
|
||||
vi.mock("../../lib/server/mail", () => ({
|
||||
sendOrganizerInquiryNotification: (...args: unknown[]) =>
|
||||
sendOrganizerInquiryNotificationMock(...args),
|
||||
resolveMailFrom: () => "CommunityRule <noreply@localhost>",
|
||||
}));
|
||||
|
||||
const rateLimitKeyMock = vi.hoisted(() =>
|
||||
@@ -54,6 +55,7 @@ describe("POST /api/organizer-inquiry", () => {
|
||||
expect(body).toEqual({ ok: true });
|
||||
expect(sendOrganizerInquiryNotificationMock).toHaveBeenCalledTimes(1);
|
||||
const arg = sendOrganizerInquiryNotificationMock.mock.calls[0][0];
|
||||
expect(arg.fromEmail).toBe("CommunityRule <noreply@localhost>");
|
||||
expect(arg.visitorEmail).toBe("visitor@example.com");
|
||||
expect(arg.message).toBe("How do we run consensus meetings?");
|
||||
});
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
isPrivacyPolicyEnabled,
|
||||
privacyPolicyUrl,
|
||||
} from "../../lib/privacyPolicyEnabled";
|
||||
|
||||
const KEYS = ["ENABLE_PRIVACY_POLICY", "NEXT_PUBLIC_ENABLE_PRIVACY_POLICY"] as const;
|
||||
const ORIGINAL = Object.fromEntries(
|
||||
KEYS.map((key) => [key, process.env[key]]),
|
||||
) as Record<(typeof KEYS)[number], string | undefined>;
|
||||
|
||||
afterEach(() => {
|
||||
for (const key of KEYS) {
|
||||
const original = ORIGINAL[key];
|
||||
if (original === undefined) delete process.env[key];
|
||||
else process.env[key] = original;
|
||||
}
|
||||
});
|
||||
|
||||
describe("isPrivacyPolicyEnabled", () => {
|
||||
it("is off unless a flag is the string true", () => {
|
||||
delete process.env.ENABLE_PRIVACY_POLICY;
|
||||
delete process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY;
|
||||
expect(isPrivacyPolicyEnabled()).toBe(false);
|
||||
expect(privacyPolicyUrl("https://communityrule.info")).toBeNull();
|
||||
|
||||
process.env.ENABLE_PRIVACY_POLICY = "yes";
|
||||
expect(isPrivacyPolicyEnabled()).toBe(false);
|
||||
|
||||
process.env.ENABLE_PRIVACY_POLICY = "true";
|
||||
expect(isPrivacyPolicyEnabled()).toBe(true);
|
||||
expect(privacyPolicyUrl("https://communityrule.info/")).toBe(
|
||||
"https://communityrule.info/privacy",
|
||||
);
|
||||
|
||||
delete process.env.ENABLE_PRIVACY_POLICY;
|
||||
process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY = "true";
|
||||
expect(isPrivacyPolicyEnabled()).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -55,4 +55,24 @@ describe("buildPublicSitemap", () => {
|
||||
lastModified: updatedAt,
|
||||
});
|
||||
});
|
||||
|
||||
it("omits /privacy while the policy 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 {
|
||||
const urls = buildPublicSitemap().map((entry) => entry.url);
|
||||
expect(urls).not.toContain(sitemapUrl("/privacy"));
|
||||
expect(urls).toContain(sitemapUrl("/terms"));
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -10,7 +10,7 @@ describe("useCaseTemplateDuplicateTitle", () => {
|
||||
|
||||
it("falls back when the source title is empty", () => {
|
||||
expect(useCaseTemplateDuplicateTitle(" ")).toBe(
|
||||
"Community Rule Template (Copy)",
|
||||
"CommunityRule Template (Copy)",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -153,6 +153,7 @@ describe("POST /api/user/email-change/request", () => {
|
||||
expect(sendEmailChangeEmailMock).toHaveBeenCalledWith(
|
||||
"new@x.com",
|
||||
expect.stringContaining("/api/user/email-change/verify?token="),
|
||||
"https://x.test",
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user