Privacy notice: built-in text up to date, review flow, acceptance (1.48.1)

The built-in notice now covers volunteer rosters, event series, season
passes, webhooks, how people agree to it, and the provider-notices
storage item. Sites with their own published version see what changed
in the editor (sections marked, use new text per section or all, add
missing sections, "Done - hide this"). Account activation asks for
agreement to the terms and notice; anyone who never accepted is asked
once after login. The cookie button shows above any cookie section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 13:15:57 +02:00
co-authored by Claude Opus 5.5
parent aa79168660
commit adb6e11000
27 changed files with 368 additions and 44 deletions
+1
View File
@@ -11,6 +11,7 @@ export type Seed = {
course: { sessions: { id: string; label: string }[]; ticketId: string; qrCode: string };
unsubscribeToken: string;
newsPromptUser: { id: string; token: string };
noticeFirstUser: { id: string; token: string };
retention: { toWarn: string; toAnonymise: string };
};
+47 -1
View File
@@ -11,7 +11,7 @@ test.describe("privacy notice, operators and access log (POPIA)", () => {
// A version that needs accepting is published below; accept it for every seeded account
// afterwards so later test files don't meet the prompt.
test.afterAll(async ({ request }) => {
const tokens = [...(["admin", "supervisor", "staff", "user"] as Role[]).map(r => seed().users[r].token), seed().newsPromptUser.token];
const tokens = [...(["admin", "supervisor", "staff", "user"] as Role[]).map(r => seed().users[r].token), seed().newsPromptUser.token, seed().noticeFirstUser.token];
for (const token of tokens) {
await request.post(`${API}/api/privacy/me/notice/accept`, { headers: { Authorization: `Bearer ${token}` } });
}
@@ -55,6 +55,52 @@ test.describe("privacy notice, operators and access log (POPIA)", () => {
await api(page, "admin", "DELETE", `/api/privacy/operators/${op.id}`);
});
test("after publishing its own version, the editor points out new built-in text", async ({ page }) => {
// The published version came from the built-in text; put an older wording back in one changed
// section so it shows as having new text.
const draft = await api<Draft>(page, "admin", "GET", "/api/privacy/notice/draft");
const sections = draft.sections.map(s => (s.id === "changes" ? { ...s, body: "We may update this notice from time to time." } : s));
await api(page, "admin", "PUT", "/api/privacy/notice/draft", { sections });
await loginAs(page, "admin");
await page.goto("/dashboard/admin/privacy?tab=notice");
const banner = page.getByTestId("builtin-updates");
await expect(banner).toContainText("The built-in privacy notice has been updated");
await expect(banner).toContainText("How people agree to the notice");
const marked = page.getByTestId("section-has-new-text");
await expect(marked).toHaveCount(1);
await marked.getByText("New built-in text for this section — show it").click();
await marked.getByRole("button", { name: "Use the new text" }).click();
await expect(page.getByTestId("section-has-new-text")).toHaveCount(0);
await page.getByRole("button", { name: "Save draft" }).click();
await expect(page.getByText("Draft saved.")).toBeVisible();
await banner.getByRole("button", { name: "Done — hide this" }).click();
await expect(page.getByTestId("builtin-updates")).toHaveCount(0);
await page.reload();
await expect(page.getByLabel("1. Introduction text")).toBeVisible();
await expect(page.getByTestId("builtin-updates")).toHaveCount(0);
await api(page, "admin", "DELETE", "/api/privacy/notice/draft");
});
test("someone who never accepted the notice is asked once, after login", async ({ page }) => {
await page.addInitScript(token => localStorage.setItem("hope_events_token", token), seed().noticeFirstUser.token);
await page.goto("/dashboard/user");
const dialog = page.getByRole("dialog", { name: "Our privacy notice" });
await expect(dialog).toBeVisible();
await expect(dialog).toContainText("It explains what we keep about you");
await dialog.getByRole("button", { name: "I accept" }).click();
await expect(dialog).toBeHidden();
await page.reload();
await expect(page.getByText("My Events").first()).toBeVisible();
await expect(page.getByRole("dialog", { name: "Our privacy notice" })).toHaveCount(0);
});
test("the cookie button stays on a published notice", async ({ page }) => {
await page.goto("/legal/privacy");
await expect(page.getByRole("button", { name: "Change my cookie choice" })).toBeVisible();
});
test("a significant change is accepted once, after login", async ({ page }) => {
const draft = await api<Draft>(page, "admin", "GET", "/api/privacy/notice/draft");
// Re-acceptance needs a summary of what changed.
+9 -4
View File
@@ -48,10 +48,10 @@ async function seed(url) {
});
const password = await hashPassword('E2e-password-123');
// Opted in to news and already asked (newsAskedAt), so the one-time news question
// doesn't cover the dashboards in every test.
// Opted in to news and already asked (newsAskedAt), and accepted the built-in privacy notice
// (version 0), so neither one-time question covers the dashboards in every test.
const mk = (role, name, email, phoneNumber) => prisma.user.create({
data: { name, email, phoneNumber, role, password, isActive: true, updatedAt: new Date(), newsEmail: true, newsWhatsApp: true, newsAskedAt: new Date() },
data: { name, email, phoneNumber, role, password, isActive: true, updatedAt: new Date(), newsEmail: true, newsWhatsApp: true, newsAskedAt: new Date(), noticeVersionAccepted: 0 },
});
const users = {
admin: await mk('admin', 'Ada Admin', 'admin@e2e.test', '0820000001'),
@@ -195,7 +195,12 @@ async function seed(url) {
course: { sessions: course.sessions.map(s => ({ id: s.id, label: s.label })), ticketId: ticket.id, qrCode: ticket.qrCode },
// An account that has never answered the news question (asked once after login).
newsPromptUser: await (async () => {
const u = await prisma.user.create({ data: { name: 'Nomsa New', email: 'prompt@e2e.test', role: 'user', password, isActive: true, updatedAt: new Date(), newsEmail: true } });
const u = await prisma.user.create({ data: { name: 'Nomsa New', email: 'prompt@e2e.test', role: 'user', password, isActive: true, updatedAt: new Date(), newsEmail: true, noticeVersionAccepted: 0 } });
return { id: u.id, token: generateToken(u.id, u.role, 0) };
})(),
// An account made for someone (never accepted the privacy notice): asked once after login.
noticeFirstUser: await (async () => {
const u = await prisma.user.create({ data: { name: 'Pieter Placed', email: 'placed@e2e.test', role: 'user', password, isActive: true, updatedAt: new Date(), newsEmail: true, newsAskedAt: new Date() } });
return { id: u.id, token: generateToken(u.id, u.role, 0) };
})(),
// Retention: two accounts untouched for six years — one not yet warned, one warned 40 days