create-ailk 0.35.1 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/component-catalog.json +51 -1
- package/component-catalog.md +8 -5
- package/dist/lib/env-catalog.js +8 -0
- package/dist/surfaces.js +66 -22
- package/dist/topology.d.ts +4 -4
- package/dist/topology.js +104 -60
- package/dist/update.d.ts +19 -1
- package/dist/update.js +293 -35
- package/package.json +3 -3
- package/templates/.env.example +38 -0
- package/templates/apps/api/.env.example +45 -0
- package/templates/apps/api/CLAUDE.md +12 -4
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -0
- package/templates/apps/mcp/CLAUDE.md +4 -2
- package/templates/apps/web/.env.example +16 -0
- package/templates/apps/web/CLAUDE.md +73 -5
- package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +2 -0
- package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +179 -0
- package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +22 -2
- package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +9 -2
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +52 -1
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +43 -0
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +108 -1
- package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +36 -3
- package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +37 -0
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +90 -33
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +9 -4
- package/templates/apps/web/app/[locale]/(authed)/__tests__/gate.test.tsx +79 -348
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +241 -66
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +242 -28
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +377 -151
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +26 -1
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +10 -5
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +17 -6
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +51 -12
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +17 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +153 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +206 -23
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +150 -188
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +235 -177
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +63 -0
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +340 -0
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +7 -5
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +20 -4
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +8 -4
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +161 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +426 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +76 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +139 -0
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +92 -24
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +32 -1
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +76 -3
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +290 -41
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +109 -11
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +43 -44
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +99 -0
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +123 -0
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +323 -73
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +199 -43
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +52 -7
- package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +8 -1
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +7 -3
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +215 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +65 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +36 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +70 -2
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +42 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +97 -53
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +122 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +215 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +73 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +12 -9
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +18 -4
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +20 -2
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +43 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +125 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +88 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +31 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +35 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +266 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +116 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +12 -0
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +154 -0
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +9 -6
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +33 -8
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +31 -52
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +44 -4
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +69 -49
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +173 -0
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +42 -4
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +102 -0
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +147 -137
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +258 -0
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +21 -22
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +34 -6
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +37 -7
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +8 -5
- package/templates/apps/web/app/[locale]/(authed)/layout.tsx +15 -13
- package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +20 -52
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +3 -2
- package/templates/apps/web/app/[locale]/layout.tsx +24 -75
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +50 -0
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +48 -7
- package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +749 -0
- package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +166 -7
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +96 -30
- package/templates/apps/web/app/api/auth/hub/continuation.ts +51 -2
- package/templates/apps/web/app/api/auth/hub/email/route.ts +111 -0
- package/templates/apps/web/app/api/auth/hub/entry-shared.ts +163 -0
- package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +86 -0
- package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +368 -0
- package/templates/apps/web/app/api/auth/hub/password/return.ts +86 -0
- package/templates/apps/web/app/api/auth/hub/password/route.ts +171 -0
- package/templates/apps/web/app/api/auth/hub/purchase/route.ts +230 -0
- package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +174 -0
- package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +60 -0
- package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +97 -0
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +738 -7
- package/templates/apps/web/app/api/hub-session/callback/route.ts +13 -47
- package/templates/apps/web/app/api/hub-session/email/route.ts +125 -0
- package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +49 -0
- package/templates/apps/web/app/api/hub-session/one-tap/route.ts +106 -0
- package/templates/apps/web/app/api/hub-session/open/route.ts +111 -0
- package/templates/apps/web/app/api/hub-session/password/return/route.ts +69 -0
- package/templates/apps/web/app/api/hub-session/password/route.ts +106 -0
- package/templates/apps/web/app/api/hub-session/sign-in/route.ts +23 -40
- package/templates/apps/web/app/api/hub-session/sign-out/route.ts +1 -10
- package/templates/apps/web/auth.ts +133 -6
- package/templates/apps/web/components/sign-out-trigger.tsx +1 -1
- package/templates/apps/web/lib/__tests__/account-config.test.ts +129 -1
- package/templates/apps/web/lib/__tests__/auth-email.test.ts +141 -0
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +445 -0
- package/templates/apps/web/lib/__tests__/auth-sms.test.ts +140 -0
- package/templates/apps/web/lib/__tests__/fixtures/tsconfig.flow.json +18 -0
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +33 -0
- package/templates/apps/web/lib/__tests__/site-header.test.ts +13 -0
- package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +19 -1
- package/templates/apps/web/lib/account-config.ts +132 -8
- package/templates/apps/web/lib/auth-email.ts +62 -6
- package/templates/apps/web/lib/auth-env.ts +13 -0
- package/templates/apps/web/lib/auth-routes.ts +11 -6
- package/templates/apps/web/lib/auth-sms.ts +180 -0
- package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +28 -0
- package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +332 -0
- package/templates/apps/web/lib/hub-session/config.ts +7 -1
- package/templates/apps/web/lib/hub-session/entry.ts +238 -0
- package/templates/apps/web/lib/hub-session/index.ts +1 -4
- package/templates/apps/web/lib/hub-session/one-tap.tsx +148 -0
- package/templates/apps/web/lib/hub-session/session.ts +120 -2
- package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +277 -0
- package/templates/apps/web/lib/offerings-pricing.ts +4 -1
- package/templates/apps/web/lib/site-header.ts +14 -1
- package/templates/apps/web/lib/telemetry-scrub.ts +11 -0
- package/templates/apps/web/lib/topology.generated.ts +39 -0
- package/templates/apps/web/messages/en.json +264 -96
- package/templates/apps/web/middleware.ts +34 -2
- package/templates/apps/web/security-headers.config.ts +21 -0
- package/versions.json +48 -48
- package/templates/apps/web/app/[locale]/(authed)/account/components/schedule-service.tsx +0 -276
- package/templates/apps/web/app/[locale]/(authed)/account/components/send-message.tsx +0 -128
- package/templates/apps/web/app/[locale]/(authed)/account/settings/__tests__/theme-modes.test.ts +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/settings/theme-modes.ts +0 -40
- package/templates/apps/web/app/[locale]/(authed)/sign-in-gate.tsx +0 -162
- package/templates/apps/web/components/signed-in-nav.tsx +0 -79
- package/templates/apps/web/lib/hub-session/__tests__/sign-in-gate.test.tsx +0 -180
- package/templates/apps/web/lib/hub-session/sign-in-gate.tsx +0 -162
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tests for /[locale]/account/privacy — User settings › Privacy (#8438
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Tests for /[locale]/account/privacy — User settings › Privacy (#8438 D14;
|
|
3
|
+
* #11164 AC-1, AC-2, AC-3 — the new lead, the expandable data-use row, the
|
|
4
|
+
* training switch and the "Your data" table in place of the Cookies section,
|
|
5
|
+
* the summary row, the agreements list and the deletion request).
|
|
5
6
|
*/
|
|
6
7
|
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
7
8
|
import { tmpdir } from "node:os";
|
|
8
9
|
import { join } from "node:path";
|
|
9
10
|
|
|
10
11
|
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
|
11
|
-
import { consentStatementText } from "@working-theory/ui/blocks";
|
|
12
|
-
import { ACCOUNT_TERMS_STATEMENT } from "@working-theory/validation";
|
|
13
12
|
|
|
14
13
|
jest.mock("next-intl/server", () => {
|
|
15
14
|
const msgs: unknown = require("../../../../../messages/en.json");
|
|
@@ -23,26 +22,29 @@ jest.mock("next-intl/server", () => {
|
|
|
23
22
|
getTranslations: async (arg: string | { namespace?: string; locale?: string }) => {
|
|
24
23
|
const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
|
|
25
24
|
const messages = dig(msgs, ns);
|
|
26
|
-
|
|
25
|
+
const t = (key: string, values?: Record<string, unknown>): string => {
|
|
27
26
|
const value = dig(messages, key);
|
|
28
27
|
if (typeof value !== "string") return `${ns}.${key}`;
|
|
29
28
|
return value.replace(/\{(\w+)\}/g, (m, name: string) =>
|
|
30
29
|
values && name in values ? String(values[name]) : m,
|
|
31
30
|
);
|
|
32
31
|
};
|
|
32
|
+
// #11164: the lead is a `t.rich` message with a `<policy>` tag, the
|
|
33
|
+
// deletion line an ICU plural.
|
|
34
|
+
const { withRich } = require("./rich-translator") as typeof import("./rich-translator");
|
|
35
|
+
return withRich(t, (key: string) => dig(messages, key), ns);
|
|
33
36
|
},
|
|
34
37
|
getLocale: jest.fn().mockResolvedValue("en"),
|
|
35
38
|
};
|
|
36
39
|
});
|
|
37
40
|
|
|
38
41
|
const mockHeaders = jest.fn();
|
|
39
|
-
const mockCookies: Record<string, string> = {};
|
|
40
42
|
jest.mock("next/headers", () => ({
|
|
41
43
|
__esModule: true,
|
|
42
44
|
headers: (...args: unknown[]) => mockHeaders(...args),
|
|
43
45
|
cookies: jest.fn().mockResolvedValue({
|
|
44
46
|
toString: () => "session=abc",
|
|
45
|
-
get: (
|
|
47
|
+
get: () => undefined,
|
|
46
48
|
}),
|
|
47
49
|
}));
|
|
48
50
|
|
|
@@ -54,9 +56,9 @@ jest.mock("../../../../../auth", () => ({
|
|
|
54
56
|
}));
|
|
55
57
|
|
|
56
58
|
const mockPieces = jest.fn();
|
|
57
|
-
const mockRequestDeletion = jest.fn();
|
|
58
59
|
const mockConsents = jest.fn();
|
|
59
60
|
const mockSetConsent = jest.fn();
|
|
61
|
+
const mockDeleteStoredSessions = jest.fn();
|
|
60
62
|
jest.mock("@working-theory/api-client", () => ({
|
|
61
63
|
__esModule: true,
|
|
62
64
|
waitlistSignups: { me: jest.fn() },
|
|
@@ -65,9 +67,9 @@ jest.mock("@working-theory/api-client", () => ({
|
|
|
65
67
|
leads: { submit: jest.fn() },
|
|
66
68
|
member: {
|
|
67
69
|
pieces: (...args: unknown[]) => mockPieces(...args),
|
|
68
|
-
requestDeletion: (...args: unknown[]) => mockRequestDeletion(...args),
|
|
69
70
|
consents: (...args: unknown[]) => mockConsents(...args),
|
|
70
71
|
setConsent: (...args: unknown[]) => mockSetConsent(...args),
|
|
72
|
+
deleteStoredSessions: (...args: unknown[]) => mockDeleteStoredSessions(...args),
|
|
71
73
|
},
|
|
72
74
|
hubSignIn: { me: jest.fn() },
|
|
73
75
|
visitorForwardHeaders: () => null,
|
|
@@ -99,15 +101,23 @@ const refusal = (status: number, code: string) => ({
|
|
|
99
101
|
body: { ok: false, error: { code, message: code } },
|
|
100
102
|
});
|
|
101
103
|
|
|
102
|
-
|
|
104
|
+
const LEAD =
|
|
105
|
+
"We believe in transparent data practices. Learn how your information is protected when using our products, and view our Privacy Policy for more details.";
|
|
106
|
+
const BULLET_1 =
|
|
107
|
+
"With your permission, we will use your communications, artifacts, and sessions to train and improve our AI models. This helps us to make AI more helpful and accurate for everyone and to develop more robust safeguards against harmful outputs.";
|
|
108
|
+
const BULLET_2 =
|
|
109
|
+
"We may conduct aggregated, anonymized analysis of data to understand how people use products and services.";
|
|
110
|
+
|
|
111
|
+
/** `ai_training` as `GET /v1/member/consents` serves it from the shipped registry. */
|
|
112
|
+
function trainingPurpose(overrides: Partial<{ effective: boolean; state: unknown }> = {}) {
|
|
103
113
|
return {
|
|
104
|
-
id:
|
|
114
|
+
id: "ai_training",
|
|
105
115
|
kind: "consent" as const,
|
|
106
116
|
area: "data" as const,
|
|
107
117
|
required: false,
|
|
108
118
|
signUp: false,
|
|
109
|
-
description: "
|
|
110
|
-
statement: "
|
|
119
|
+
description: "Use of your communications, artifacts and sessions to train and improve AI models.",
|
|
120
|
+
statement: "I allow the use of my communications, artifacts, and sessions to train and improve AI models.",
|
|
111
121
|
policyHref: "/privacy",
|
|
112
122
|
policyVersion: 1,
|
|
113
123
|
state: overrides.state === undefined ? null : overrides.state,
|
|
@@ -115,19 +125,14 @@ function dataPurpose(overrides: Partial<{ id: string; effective: boolean; state:
|
|
|
115
125
|
};
|
|
116
126
|
}
|
|
117
127
|
|
|
118
|
-
|
|
128
|
+
/** A communications purpose, which Privacy never lists. */
|
|
129
|
+
function communicationsPurpose() {
|
|
119
130
|
return {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
area:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
description: "Account terms.",
|
|
126
|
-
statement: ACCOUNT_TERMS_STATEMENT,
|
|
127
|
-
policyHref: "/working-agreement",
|
|
128
|
-
policyVersion: 2,
|
|
129
|
-
state: overrides.state === undefined ? null : overrides.state,
|
|
130
|
-
effective: false,
|
|
131
|
+
...trainingPurpose(),
|
|
132
|
+
id: "newsletter",
|
|
133
|
+
area: "communications" as const,
|
|
134
|
+
description: "This site's newsletter by email",
|
|
135
|
+
statement: "Email me the newsletter.",
|
|
131
136
|
};
|
|
132
137
|
}
|
|
133
138
|
|
|
@@ -138,12 +143,11 @@ beforeEach(() => {
|
|
|
138
143
|
process.env.AILK_CONTENT_ROOT = contentRoot;
|
|
139
144
|
writeFileSync(join(contentRoot, "_site.mdx"), '---\nsiteName: "Test"\n---\n');
|
|
140
145
|
mockHeaders.mockReset().mockResolvedValue(new Headers());
|
|
141
|
-
for (const key of Object.keys(mockCookies)) delete mockCookies[key];
|
|
142
146
|
mockGetSession.mockReset().mockResolvedValue(SESSION);
|
|
143
147
|
mockPieces.mockReset().mockResolvedValue(ok([]));
|
|
144
|
-
|
|
145
|
-
mockConsents.mockReset().mockResolvedValue(ok({ purposes: [] }));
|
|
148
|
+
mockConsents.mockReset().mockResolvedValue(ok({ purposes: [trainingPurpose(), communicationsPurpose()] }));
|
|
146
149
|
mockSetConsent.mockReset();
|
|
150
|
+
mockDeleteStoredSessions.mockReset().mockResolvedValue(ok({ deleted: 2 }));
|
|
147
151
|
});
|
|
148
152
|
|
|
149
153
|
afterEach(() => {
|
|
@@ -154,7 +158,11 @@ async function renderPage(locale = "en"): Promise<void> {
|
|
|
154
158
|
render(await Page({ params: Promise.resolve({ locale }) }));
|
|
155
159
|
}
|
|
156
160
|
|
|
157
|
-
|
|
161
|
+
/** True when `a` comes before `b` in the document. */
|
|
162
|
+
const before = (a: Element, b: Element): boolean =>
|
|
163
|
+
(a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0;
|
|
164
|
+
|
|
165
|
+
describe("the frame", () => {
|
|
158
166
|
it("the Settings rail reads General, Security, Notifications, Privacy, Billing, Privacy current", async () => {
|
|
159
167
|
await renderPage();
|
|
160
168
|
const rail = screen.getByRole("navigation", { name: "Settings" });
|
|
@@ -169,224 +177,274 @@ describe("AC-4 — the frame", () => {
|
|
|
169
177
|
expect(screen.getByTestId("account-settings-rail-privacy")).toHaveAttribute("aria-current", "page");
|
|
170
178
|
});
|
|
171
179
|
|
|
172
|
-
it("a non-default locale prefixes the rail", async () => {
|
|
180
|
+
it("a non-default locale prefixes the rail and the policy link", async () => {
|
|
173
181
|
await renderPage("fr");
|
|
174
182
|
expect(screen.getByTestId("account-settings-rail-privacy")).toHaveAttribute("href", "/fr/account/privacy");
|
|
183
|
+
expect(screen.getByTestId("account-privacy-policy")).toHaveAttribute("href", "/fr/privacy");
|
|
175
184
|
});
|
|
176
185
|
});
|
|
177
186
|
|
|
178
|
-
describe("AC-
|
|
179
|
-
it("renders the
|
|
187
|
+
describe("AC-1 — the order, the copy and the absences", () => {
|
|
188
|
+
it("renders, in order: the title and the new lead, the data-use row collapsed, the training switch row, the Your data table", async () => {
|
|
180
189
|
mockConsents.mockResolvedValue(
|
|
181
|
-
ok({
|
|
190
|
+
ok({
|
|
191
|
+
purposes: [
|
|
192
|
+
trainingPurpose({
|
|
193
|
+
effective: true,
|
|
194
|
+
state: { granted: true, at: "2026-11-08T12:00:00.000Z", source: "account_settings", policyVersion: 1 },
|
|
195
|
+
}),
|
|
196
|
+
],
|
|
197
|
+
}),
|
|
182
198
|
);
|
|
183
199
|
await renderPage();
|
|
184
200
|
const pane = screen.getByTestId("account-settings-privacy");
|
|
185
|
-
|
|
201
|
+
|
|
202
|
+
const title = within(pane).getByRole("heading", { level: 1 });
|
|
203
|
+
expect(title).toHaveTextContent("Privacy");
|
|
204
|
+
const policy = within(pane).getByTestId("account-privacy-policy");
|
|
205
|
+
expect(policy).toHaveTextContent("Privacy Policy");
|
|
206
|
+
expect(policy).toHaveAttribute("href", "/privacy");
|
|
207
|
+
expect(policy.closest("p")).toHaveTextContent(LEAD);
|
|
208
|
+
|
|
209
|
+
const trigger = within(pane).getByTestId("account-privacy-data-use-trigger");
|
|
210
|
+
expect(trigger.tagName).toBe("BUTTON");
|
|
211
|
+
expect(trigger).toHaveTextContent("How we use your data");
|
|
212
|
+
expect(trigger).toHaveAttribute("aria-expanded", "false");
|
|
213
|
+
expect(within(pane).queryByText(BULLET_1)).not.toBeInTheDocument();
|
|
214
|
+
|
|
215
|
+
const switchRow = within(pane).getByTestId("account-privacy-data-consent-ai_training");
|
|
216
|
+
expect(within(switchRow).getByTestId("account-privacy-data-consent-ai_training-label")).toHaveTextContent(
|
|
217
|
+
"Help improve our AI models",
|
|
218
|
+
);
|
|
219
|
+
expect(switchRow).toHaveTextContent(
|
|
220
|
+
"Allow the use of your communications, artifacts, and sessions to train and improve AI models.",
|
|
221
|
+
);
|
|
222
|
+
expect(within(switchRow).getByTestId("account-privacy-data-consent-ai_training-date")).toHaveTextContent(
|
|
223
|
+
"Given Nov 8, 2026",
|
|
224
|
+
);
|
|
225
|
+
expect(within(switchRow).getByRole("switch")).toBeChecked();
|
|
226
|
+
|
|
227
|
+
const table = within(pane).getByTestId("account-privacy-your-data");
|
|
228
|
+
expect(within(table).getByRole("heading", { level: 2 })).toHaveTextContent("Your data");
|
|
229
|
+
const rows = within(table).getAllByRole("row");
|
|
230
|
+
expect(rows).toHaveLength(2);
|
|
231
|
+
expect(within(table).queryByRole("columnheader")).not.toBeInTheDocument();
|
|
232
|
+
expect(rows[0]).toHaveTextContent("Export data");
|
|
233
|
+
expect(within(rows[0]!).getByTestId("account-privacy-your-data-export-button")).toHaveTextContent(
|
|
234
|
+
"Export data",
|
|
235
|
+
);
|
|
236
|
+
expect(within(rows[0]!).getByTestId("account-privacy-your-data-export-button").closest("td")).toHaveClass(
|
|
237
|
+
"text-end",
|
|
238
|
+
);
|
|
239
|
+
expect(rows[1]).toHaveTextContent("Delete stored sessions");
|
|
240
|
+
expect(rows[1]).toHaveTextContent("Permanently delete server-side copies of your stored sessions.");
|
|
241
|
+
expect(within(rows[1]!).getByTestId("account-privacy-your-data-delete-button")).toHaveTextContent("Delete");
|
|
242
|
+
expect(within(rows[1]!).getByTestId("account-privacy-your-data-delete-button").closest("td")).toHaveClass(
|
|
243
|
+
"text-end",
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
// The order.
|
|
247
|
+
expect(before(title, policy)).toBe(true);
|
|
248
|
+
expect(before(policy, trigger)).toBe(true);
|
|
249
|
+
expect(before(trigger, switchRow)).toBe(true);
|
|
250
|
+
expect(before(switchRow, table)).toBe(true);
|
|
251
|
+
// The data-use row and the switch share one card; the table is its own.
|
|
252
|
+
const cards = within(pane).getAllByTestId("account-settings-privacy-card");
|
|
253
|
+
expect(cards).toHaveLength(2);
|
|
254
|
+
expect(cards[0]).toContainElement(trigger);
|
|
255
|
+
expect(cards[0]).toContainElement(switchRow);
|
|
256
|
+
expect(cards[1]).toContainElement(table);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it("renders no Cookies section, no summary row, no agreements list and no account-deletion line or button", async () => {
|
|
260
|
+
await renderPage();
|
|
261
|
+
for (const id of [
|
|
186
262
|
"account-privacy-summary",
|
|
187
263
|
"account-privacy-cookies",
|
|
264
|
+
"account-cookie-settings",
|
|
188
265
|
"account-privacy-consents",
|
|
189
266
|
"account-privacy-agreements",
|
|
190
267
|
"account-deletion",
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
268
|
+
"account-deletion-request",
|
|
269
|
+
"account-deletion-support",
|
|
270
|
+
]) {
|
|
271
|
+
expect(screen.queryByTestId(id)).not.toBeInTheDocument();
|
|
272
|
+
}
|
|
273
|
+
for (const text of [
|
|
274
|
+
"Cookies",
|
|
275
|
+
"Cookies and your data.",
|
|
276
|
+
"How we use your data.",
|
|
277
|
+
"Read our privacy policy",
|
|
278
|
+
"Data use",
|
|
279
|
+
"Agreements accepted",
|
|
280
|
+
"Request account deletion",
|
|
281
|
+
"Ask the site owner to delete your account and its data.",
|
|
282
|
+
]) {
|
|
283
|
+
expect(screen.queryByText(text)).not.toBeInTheDocument();
|
|
284
|
+
}
|
|
285
|
+
// The communications purpose is Notifications', never listed here.
|
|
286
|
+
expect(screen.queryByTestId("account-privacy-data-consent-newsletter")).not.toBeInTheDocument();
|
|
287
|
+
expect(screen.getAllByRole("switch")).toHaveLength(1);
|
|
203
288
|
});
|
|
204
|
-
});
|
|
205
289
|
|
|
206
|
-
|
|
207
|
-
it("links to the site's privacy policy", async () => {
|
|
290
|
+
it("the chevron expands the row in place to the two bullets, in order, and is a disclosure button", async () => {
|
|
208
291
|
await renderPage();
|
|
209
|
-
|
|
292
|
+
const trigger = screen.getByTestId("account-privacy-data-use-trigger");
|
|
293
|
+
fireEvent.click(trigger);
|
|
294
|
+
expect(trigger).toHaveAttribute("aria-expanded", "true");
|
|
295
|
+
const content = screen.getByTestId("account-privacy-data-use-content");
|
|
296
|
+
expect(within(content).getAllByRole("listitem").map((li) => li.textContent)).toEqual([BULLET_1, BULLET_2]);
|
|
297
|
+
expect(screen.getByTestId("account-privacy-data-use")).toContainElement(content);
|
|
298
|
+
expect(before(trigger, content)).toBe(true);
|
|
299
|
+
fireEvent.click(trigger);
|
|
300
|
+
expect(trigger).toHaveAttribute("aria-expanded", "false");
|
|
210
301
|
});
|
|
211
|
-
});
|
|
212
302
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
["accepted", "Accepted"],
|
|
216
|
-
["declined", "Declined"],
|
|
217
|
-
])("reads %s as %s", async (value, label) => {
|
|
218
|
-
mockCookies["ailk-consent"] = value;
|
|
303
|
+
it("with no data purpose declared, the switch list shows its one line under the data-use row", async () => {
|
|
304
|
+
mockConsents.mockResolvedValue(ok({ purposes: [communicationsPurpose()] }));
|
|
219
305
|
await renderPage();
|
|
220
|
-
expect(
|
|
306
|
+
expect(screen.getByTestId("account-privacy-data-consent-empty")).toHaveTextContent(
|
|
307
|
+
"This site asks for no data-use consents.",
|
|
308
|
+
);
|
|
309
|
+
expect(screen.getByTestId("account-privacy-your-data")).toBeInTheDocument();
|
|
221
310
|
});
|
|
222
311
|
|
|
223
|
-
it("
|
|
312
|
+
it("a failed consents read keeps the lead, the data-use row and the table, and shows the one line in place of the switch", async () => {
|
|
313
|
+
mockConsents.mockResolvedValue(refusal(503, "tenant_unresolved"));
|
|
224
314
|
await renderPage();
|
|
225
|
-
expect(
|
|
315
|
+
expect(screen.getByTestId("account-privacy-policy")).toBeInTheDocument();
|
|
316
|
+
expect(screen.getByTestId("account-privacy-data-use-trigger")).toBeInTheDocument();
|
|
317
|
+
expect(screen.getByTestId("account-privacy-your-data")).toBeInTheDocument();
|
|
318
|
+
expect(screen.queryByRole("switch")).not.toBeInTheDocument();
|
|
319
|
+
expect(screen.getByTestId("account-privacy-unavailable")).toHaveTextContent(
|
|
320
|
+
"Your consent choices can't be shown right now.",
|
|
321
|
+
);
|
|
226
322
|
});
|
|
323
|
+
});
|
|
227
324
|
|
|
228
|
-
|
|
325
|
+
describe("AC-2 — Help improve our AI models is a registry area: data consent, off until ticked", () => {
|
|
326
|
+
it("renders off with no date line when the person has no row, and off is `effective: false`", async () => {
|
|
229
327
|
await renderPage();
|
|
230
|
-
expect(screen.getByTestId("account-
|
|
328
|
+
expect(screen.getByTestId("account-privacy-data-consent-ai_training-switch")).not.toBeChecked();
|
|
329
|
+
expect(screen.queryByTestId("account-privacy-data-consent-ai_training-date")).not.toBeInTheDocument();
|
|
231
330
|
});
|
|
232
|
-
});
|
|
233
331
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
mockConsents.mockResolvedValue(
|
|
332
|
+
it("ticking it writes the ledger through setConsentAction and shows the given date the answer carries", async () => {
|
|
333
|
+
mockSetConsent.mockResolvedValue(
|
|
237
334
|
ok({
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}),
|
|
243
|
-
],
|
|
335
|
+
purpose: trainingPurpose({
|
|
336
|
+
effective: true,
|
|
337
|
+
state: { granted: true, at: "2026-11-08T12:00:00.000Z", source: "account_settings", policyVersion: 1 },
|
|
338
|
+
}),
|
|
244
339
|
}),
|
|
245
340
|
);
|
|
246
341
|
await renderPage();
|
|
247
|
-
|
|
248
|
-
expect(
|
|
249
|
-
|
|
342
|
+
fireEvent.click(screen.getByTestId("account-privacy-data-consent-ai_training-switch"));
|
|
343
|
+
await waitFor(() => expect(mockSetConsent).toHaveBeenCalledTimes(1));
|
|
344
|
+
expect(mockSetConsent).toHaveBeenCalledWith({ purposeId: "ai_training", granted: true, locale: "en" }, COOKIE_INIT);
|
|
345
|
+
expect(await screen.findByTestId("account-privacy-data-consent-ai_training-date")).toHaveTextContent(
|
|
346
|
+
"Given Nov 8, 2026",
|
|
250
347
|
);
|
|
348
|
+
expect(screen.getByTestId("account-privacy-data-consent-ai_training-switch")).toBeChecked();
|
|
251
349
|
});
|
|
252
350
|
|
|
253
|
-
it("
|
|
254
|
-
mockConsents.mockResolvedValue(ok({ purposes: [dataPurpose({ effective: true })] }));
|
|
351
|
+
it("a failed answer reverts the switch with its message", async () => {
|
|
255
352
|
mockSetConsent.mockResolvedValue(refusal(500, "internal"));
|
|
256
353
|
await renderPage();
|
|
257
|
-
fireEvent.click(screen.getByTestId("account-privacy-data-consent-
|
|
354
|
+
fireEvent.click(screen.getByTestId("account-privacy-data-consent-ai_training-switch"));
|
|
258
355
|
await waitFor(() =>
|
|
259
|
-
expect(screen.getByTestId("account-privacy-data-consent-
|
|
356
|
+
expect(screen.getByTestId("account-privacy-data-consent-ai_training-error")).toBeInTheDocument(),
|
|
260
357
|
);
|
|
261
|
-
expect(screen.getByTestId("account-privacy-data-consent-
|
|
262
|
-
expect(mockSetConsent).toHaveBeenCalledWith({ purposeId: "data_sharing", granted: false, locale: "en" }, COOKIE_INIT);
|
|
358
|
+
expect(screen.getByTestId("account-privacy-data-consent-ai_training-switch")).not.toBeChecked();
|
|
263
359
|
});
|
|
264
360
|
|
|
265
|
-
it("
|
|
266
|
-
await renderPage();
|
|
267
|
-
expect(screen.getByTestId("account-privacy-data-consent-empty")).toHaveTextContent(
|
|
268
|
-
"This site asks for no other data-use consents.",
|
|
269
|
-
);
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
describe("AC-4 — account-privacy-agreements (read-only)", () => {
|
|
274
|
-
it("an accepted agreement shows its version and date, read-only", async () => {
|
|
361
|
+
it("a data purpose a site adds is labelled by its statement and described by its description", async () => {
|
|
275
362
|
mockConsents.mockResolvedValue(
|
|
276
363
|
ok({
|
|
277
364
|
purposes: [
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
365
|
+
{
|
|
366
|
+
...trainingPurpose(),
|
|
367
|
+
id: "data_sharing",
|
|
368
|
+
description: "Product-usage data.",
|
|
369
|
+
statement: "Share product-usage data with us.",
|
|
370
|
+
},
|
|
281
371
|
],
|
|
282
372
|
}),
|
|
283
373
|
);
|
|
284
374
|
await renderPage();
|
|
285
|
-
const row = screen.getByTestId("account-privacy-
|
|
286
|
-
expect(within(row).
|
|
287
|
-
|
|
288
|
-
expect(within(row).queryByRole("switch")).not.toBeInTheDocument();
|
|
289
|
-
expect(within(row).queryByRole("button")).not.toBeInTheDocument();
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
it("an agreement with no grant shows None yet", async () => {
|
|
293
|
-
mockConsents.mockResolvedValue(ok({ purposes: [agreementPurpose()] }));
|
|
294
|
-
await renderPage();
|
|
295
|
-
expect(screen.getByTestId("account-privacy-agreement-account_terms-accepted")).toHaveTextContent("None yet");
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
// #8765 D11 / AC-5 (#8761) — the statement renders with its three links.
|
|
299
|
-
it.each(["en", "fr"])(
|
|
300
|
-
"%s: the statement is the Contact sentence with no markdown, linking Terms, Privacy Policy and Working Agreement",
|
|
301
|
-
async (locale) => {
|
|
302
|
-
mockConsents.mockResolvedValue(ok({ purposes: [agreementPurpose()] }));
|
|
303
|
-
await renderPage(locale);
|
|
304
|
-
const statement = screen.getByTestId("account-privacy-agreement-account_terms-statement");
|
|
305
|
-
expect(statement.textContent).toBe(consentStatementText(ACCOUNT_TERMS_STATEMENT));
|
|
306
|
-
expect(statement.textContent).not.toContain("[");
|
|
307
|
-
expect(statement.textContent).not.toContain("](");
|
|
308
|
-
const prefix = locale === "en" ? "" : `/${locale}`;
|
|
309
|
-
const links = (["terms", "privacy", "working_agreement"] as const).map((key) => {
|
|
310
|
-
const link = within(statement).getByTestId(`consent-policy-link-${key}`);
|
|
311
|
-
return [link.textContent, link.getAttribute("href")];
|
|
312
|
-
});
|
|
313
|
-
expect(links).toEqual([
|
|
314
|
-
["Terms", `${prefix}/terms`],
|
|
315
|
-
["Privacy Policy", `${prefix}/privacy`],
|
|
316
|
-
["Working Agreement", `${prefix}/working-agreement`],
|
|
317
|
-
]);
|
|
318
|
-
},
|
|
319
|
-
);
|
|
320
|
-
|
|
321
|
-
it("no retired card policy link renders, and the policy link is the summary's, to /privacy", async () => {
|
|
322
|
-
mockConsents.mockResolvedValue(ok({ purposes: [agreementPurpose()] }));
|
|
323
|
-
await renderPage();
|
|
324
|
-
expect(
|
|
325
|
-
document.querySelector('[data-testid^="account-agreements-prompt-"][data-testid$="-policy"]'),
|
|
326
|
-
).toBeNull();
|
|
327
|
-
const policyLinks = screen.getAllByText("Read our privacy policy");
|
|
328
|
-
expect(policyLinks).toHaveLength(1);
|
|
329
|
-
expect(within(screen.getByTestId("account-privacy-summary")).getByTestId("account-privacy-policy")).toHaveAttribute(
|
|
330
|
-
"href",
|
|
331
|
-
"/privacy",
|
|
375
|
+
const row = screen.getByTestId("account-privacy-data-consent-data_sharing");
|
|
376
|
+
expect(within(row).getByTestId("account-privacy-data-consent-data_sharing-label")).toHaveTextContent(
|
|
377
|
+
"Share product-usage data with us.",
|
|
332
378
|
);
|
|
379
|
+
expect(row).toHaveTextContent("Product-usage data.");
|
|
333
380
|
});
|
|
334
381
|
});
|
|
335
382
|
|
|
336
|
-
describe("AC-
|
|
337
|
-
it("
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
expect(
|
|
341
|
-
expect(
|
|
342
|
-
expect(screen.getByTestId("account-deletion")).toBeInTheDocument();
|
|
343
|
-
expect(screen.queryByTestId("account-privacy-consents")).not.toBeInTheDocument();
|
|
344
|
-
expect(screen.queryByTestId("account-privacy-agreements")).not.toBeInTheDocument();
|
|
345
|
-
expect(screen.getByTestId("account-privacy-unavailable")).toHaveTextContent(
|
|
346
|
-
"Your consent choices can't be shown right now.",
|
|
347
|
-
);
|
|
383
|
+
describe("AC-3 — Export data", () => {
|
|
384
|
+
it("the Export data button links this site's own download route for the person's records", async () => {
|
|
385
|
+
await renderPage("fr");
|
|
386
|
+
const button = screen.getByTestId("account-privacy-your-data-export-button");
|
|
387
|
+
expect(button).toHaveAttribute("href", "/fr/account/privacy/export");
|
|
388
|
+
expect(button).toHaveAttribute("download");
|
|
348
389
|
});
|
|
349
390
|
});
|
|
350
391
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
392
|
+
describe("AC-3 — Delete stored sessions", () => {
|
|
393
|
+
async function confirmDelete(): Promise<void> {
|
|
394
|
+
fireEvent.click(screen.getByTestId("account-privacy-your-data-delete-button"));
|
|
395
|
+
const dialog = await screen.findByRole("alertdialog");
|
|
355
396
|
await act(async () => {
|
|
356
|
-
fireEvent.click(
|
|
397
|
+
fireEvent.click(within(dialog).getByTestId("account-privacy-your-data-delete-confirm-action"));
|
|
357
398
|
});
|
|
358
399
|
}
|
|
359
400
|
|
|
401
|
+
it("asks for confirmation, names where an account-deletion request lives, and calls nothing until confirmed", async () => {
|
|
402
|
+
await renderPage();
|
|
403
|
+
fireEvent.click(screen.getByTestId("account-privacy-your-data-delete-button"));
|
|
404
|
+
const dialog = await screen.findByRole("alertdialog");
|
|
405
|
+
expect(dialog).toHaveTextContent("Delete stored sessions?");
|
|
406
|
+
expect(dialog).toHaveTextContent("To ask for your account and its data to be deleted, contact support.");
|
|
407
|
+
expect(within(dialog).getByTestId("account-privacy-your-data-account-deletion")).toHaveAttribute(
|
|
408
|
+
"href",
|
|
409
|
+
"/account/support",
|
|
410
|
+
);
|
|
411
|
+
expect(mockDeleteStoredSessions).not.toHaveBeenCalled();
|
|
412
|
+
});
|
|
413
|
+
|
|
360
414
|
it.each([
|
|
361
|
-
[
|
|
362
|
-
[
|
|
363
|
-
|
|
364
|
-
|
|
415
|
+
[2, "Deleted 2 stored sessions."],
|
|
416
|
+
[1, "Deleted 1 stored session."],
|
|
417
|
+
[0, "There were no stored sessions to delete."],
|
|
418
|
+
])("confirming deletes through the member route and reports %i as %s", async (deleted, line) => {
|
|
419
|
+
mockDeleteStoredSessions.mockResolvedValue(ok({ deleted }));
|
|
365
420
|
await renderPage();
|
|
366
|
-
await
|
|
367
|
-
expect(
|
|
421
|
+
await confirmDelete();
|
|
422
|
+
expect(mockDeleteStoredSessions).toHaveBeenCalledWith(COOKIE_INIT);
|
|
368
423
|
await waitFor(() => expect(screen.getByRole("status")).toHaveTextContent(line));
|
|
369
|
-
expect(screen.queryByTestId("account-deletion-request")).not.toBeInTheDocument();
|
|
370
424
|
});
|
|
371
425
|
|
|
372
|
-
it("a refusal shows
|
|
373
|
-
|
|
426
|
+
it("a refusal shows the failure line as an alert", async () => {
|
|
427
|
+
mockDeleteStoredSessions.mockResolvedValue(refusal(429, "rate_limited"));
|
|
374
428
|
await renderPage();
|
|
375
|
-
await
|
|
429
|
+
await confirmDelete();
|
|
376
430
|
await waitFor(() =>
|
|
377
|
-
expect(screen.getByRole("alert")).toHaveTextContent("
|
|
431
|
+
expect(screen.getByRole("alert")).toHaveTextContent("We couldn't delete your stored sessions. Try again in a moment."),
|
|
378
432
|
);
|
|
379
|
-
expect(screen.getByTestId("account-deletion-request")).toBeEnabled();
|
|
380
433
|
});
|
|
381
|
-
});
|
|
382
434
|
|
|
383
|
-
|
|
384
|
-
|
|
435
|
+
// A single site whose build answers no member route (a 404 from the pieces
|
|
436
|
+
// read) still files Support into its own operator inbox, so the pointer
|
|
437
|
+
// stays; the hub-mode spoke that must show none (`via: "none"`,
|
|
438
|
+
// SEC-7894-11) is `AccountDataTable`'s `supportHref: null` case.
|
|
439
|
+
it("a single site with no member API still points an account-deletion request at Support", async () => {
|
|
385
440
|
mockPieces.mockResolvedValue(refusal(404, "not_found"));
|
|
386
441
|
await renderPage();
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
expect(
|
|
442
|
+
fireEvent.click(screen.getByTestId("account-privacy-your-data-delete-button"));
|
|
443
|
+
const dialog = await screen.findByRole("alertdialog");
|
|
444
|
+
expect(within(dialog).getByTestId("account-privacy-your-data-account-deletion")).toHaveAttribute(
|
|
445
|
+
"href",
|
|
446
|
+
"/account/support",
|
|
447
|
+
);
|
|
390
448
|
});
|
|
391
449
|
});
|
|
392
450
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `t.rich` the way next-intl renders it, for the inline `next-intl/server`
|
|
3
|
+
* mocks of this area's suites (#11175): a `<tag>chunks</tag>` in the message
|
|
4
|
+
* renders the node the tag's function returns for those chunks; `{name}` its
|
|
5
|
+
* value; an ICU `{name, plural, …}` block its matching case with `#` the
|
|
6
|
+
* count (#11164's deletion line). `t.markup` renders the same message as a
|
|
7
|
+
* string, each tag's function given the chunks. `require`d inside a
|
|
8
|
+
* `jest.mock` factory, so it holds no test-file state.
|
|
9
|
+
*/
|
|
10
|
+
import { createElement, Fragment, type ReactNode } from "react";
|
|
11
|
+
|
|
12
|
+
type Translate = (key: string, values?: Record<string, unknown>) => string;
|
|
13
|
+
type Rich = (key: string, values?: Record<string, unknown>) => ReactNode;
|
|
14
|
+
type Markup = (key: string, values?: Record<string, unknown>) => string;
|
|
15
|
+
|
|
16
|
+
/** Resolve every `{name, plural, =0 {…} one {…} other {…}}` block in `value`. */
|
|
17
|
+
function plural(value: string, values?: Record<string, unknown>): string {
|
|
18
|
+
return value.replace(
|
|
19
|
+
/\{(\w+), plural,((?:\s*(?:=\d+|zero|one|two|few|many|other)\s*\{[^{}]*\})+)\s*\}/g,
|
|
20
|
+
(_match, name: string, options: string) => {
|
|
21
|
+
const count = Number(values?.[name]);
|
|
22
|
+
const cases = new Map<string, string>();
|
|
23
|
+
for (const [, selector, text] of options.matchAll(/(=\d+|\w+)\s*\{([^{}]*)\}/g)) {
|
|
24
|
+
cases.set(selector!, text!);
|
|
25
|
+
}
|
|
26
|
+
const text =
|
|
27
|
+
cases.get(`=${count}`) ?? (count === 1 ? cases.get("one") : undefined) ?? cases.get("other") ?? "";
|
|
28
|
+
return text.replace(/#/g, String(count));
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function withRich(
|
|
34
|
+
t: Translate,
|
|
35
|
+
lookup: (key: string) => unknown,
|
|
36
|
+
ns: string,
|
|
37
|
+
): Translate & { rich: Rich; markup: Markup } {
|
|
38
|
+
const translate: Translate = (key, values) => plural(t(key, values), values);
|
|
39
|
+
const rich: Rich = (key, values) => {
|
|
40
|
+
const value = lookup(key);
|
|
41
|
+
if (typeof value !== "string") return `${ns}.${key}`;
|
|
42
|
+
return plural(value, values)
|
|
43
|
+
.split(/(<\w+>[^<]*<\/\w+>|\{\w+\})/)
|
|
44
|
+
.map((part, i) => {
|
|
45
|
+
const tag = /^<(\w+)>([^<]*)<\/\1>$/.exec(part);
|
|
46
|
+
const fn = tag ? values?.[tag[1]!] : undefined;
|
|
47
|
+
if (typeof fn === "function") {
|
|
48
|
+
return createElement(Fragment, { key: i }, fn(tag![2] === "" ? [] : [tag![2]]));
|
|
49
|
+
}
|
|
50
|
+
const name = /^\{(\w+)\}$/.exec(part)?.[1];
|
|
51
|
+
return name && values && name in values ? String(values[name]) : part;
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const markup: Markup = (key, values) => {
|
|
55
|
+
const value = lookup(key);
|
|
56
|
+
if (typeof value !== "string") return `${ns}.${key}`;
|
|
57
|
+
return plural(value, values).replace(/<(\w+)>([^<]*)<\/\1>/g, (_match, tag: string, inner: string) => {
|
|
58
|
+
const fn = values?.[tag];
|
|
59
|
+
return typeof fn === "function" ? String(fn(inner)) : inner;
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
return Object.assign(translate, { rich, markup });
|
|
63
|
+
}
|