create-ailk 0.37.1 → 0.38.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 +129 -0
- package/component-catalog.json +44 -6
- package/component-catalog.md +6 -5
- package/dist/add-module.js +16 -1
- package/dist/add-route.d.ts +2 -2
- package/dist/add-route.js +18 -11
- package/dist/cli.js +52 -0
- package/dist/declined-routes.d.ts +13 -0
- package/dist/declined-routes.js +74 -0
- package/dist/derive-architecture.d.ts +0 -6
- package/dist/derive-architecture.js +9 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/language-import.d.ts +93 -0
- package/dist/language-import.js +270 -43
- package/dist/lib/import-mdx.js +1 -1
- package/dist/lib/scaffold-render-sweep.d.ts +6 -3
- package/dist/lib/scaffold-render-sweep.js +8 -4
- package/dist/migrate-content.d.ts +6 -2
- package/dist/migrate-content.js +62 -5
- package/dist/module-architecture.js +139 -103
- package/dist/paid-sections.d.ts +13 -0
- package/dist/paid-sections.js +35 -5
- package/dist/programmatic.js +6 -16
- package/dist/remove-module.js +67 -0
- package/dist/routes.d.ts +103 -0
- package/dist/routes.js +708 -0
- package/dist/site-manifest.js +1 -1
- package/dist/site-roster.d.ts +2 -1
- package/dist/site-roster.js +30 -8
- package/dist/spoke-checkout.d.ts +28 -27
- package/dist/spoke-checkout.js +71 -102
- package/dist/surfaces.d.ts +18 -0
- package/dist/surfaces.js +47 -282
- package/dist/sync-routes.d.ts +14 -1
- package/dist/sync-routes.js +86 -5
- package/dist/topology.d.ts +15 -1
- package/dist/topology.js +20 -4
- package/dist/update.d.ts +17 -2
- package/dist/update.js +480 -77
- package/package.json +3 -3
- package/templates/README.md +1 -1
- package/templates/apps/mcp/CLAUDE.md +5 -3
- package/templates/apps/web/CLAUDE.md +62 -20
- package/templates/apps/web/account.config.tsx +101 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
- package/templates/apps/web/app/[locale]/layout.tsx +45 -28
- package/templates/apps/web/app/apple-icon.tsx +72 -0
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
- package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
- package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
- package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
- package/templates/apps/web/app/og/route.tsx +155 -72
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
- package/templates/apps/web/i18n/request.ts +44 -1
- package/templates/apps/web/jest.config.cjs +13 -1
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -0
- package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
- package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
- package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
- package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
- package/templates/apps/web/lib/listings.tsx +2 -2
- package/templates/apps/web/lib/nav-label-keys.ts +16 -2
- package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
- package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
- package/templates/apps/web/lib/profile-back-link.ts +105 -32
- package/templates/apps/web/lib/served-pages.ts +95 -0
- package/templates/apps/web/lib/site-brand.tsx +3 -5
- package/templates/apps/web/messages/en.json +8 -684
- package/templates/apps/web/middleware.ts +3 -1
- package/templates/apps/web/next.config.mjs +27 -0
- package/templates/apps/web/package.json +1 -0
- package/templates/customizations.yaml +9 -0
- package/templates/package.json +3 -1
- package/templates/tools/lint-architecture.ts +164 -11
- package/versions.json +48 -47
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
- package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
- package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
- package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
- package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
- package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
- package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
- package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
- package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
- package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
- package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
- package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
- package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
- package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
- package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
- package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
- package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
- package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
- package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
- package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
- package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
- package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
- package/templates/apps/web/lib/account-config.ts +0 -678
- package/templates/apps/web/lib/checkout-config.ts +0 -16
- package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
- package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
|
@@ -1,462 +0,0 @@
|
|
|
1
|
-
/**
|
|
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).
|
|
6
|
-
*/
|
|
7
|
-
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
8
|
-
import { tmpdir } from "node:os";
|
|
9
|
-
import { join } from "node:path";
|
|
10
|
-
|
|
11
|
-
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
|
12
|
-
|
|
13
|
-
jest.mock("next-intl/server", () => {
|
|
14
|
-
const msgs: unknown = require("../../../../../messages/en.json");
|
|
15
|
-
const dig = (obj: unknown, path: string): unknown =>
|
|
16
|
-
path.split(".").reduce<unknown>(
|
|
17
|
-
(acc, k) => (acc !== null && typeof acc === "object" ? (acc as Record<string, unknown>)[k] : undefined),
|
|
18
|
-
obj,
|
|
19
|
-
);
|
|
20
|
-
return {
|
|
21
|
-
__esModule: true,
|
|
22
|
-
getTranslations: async (arg: string | { namespace?: string; locale?: string }) => {
|
|
23
|
-
const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
|
|
24
|
-
const messages = dig(msgs, ns);
|
|
25
|
-
const t = (key: string, values?: Record<string, unknown>): string => {
|
|
26
|
-
const value = dig(messages, key);
|
|
27
|
-
if (typeof value !== "string") return `${ns}.${key}`;
|
|
28
|
-
return value.replace(/\{(\w+)\}/g, (m, name: string) =>
|
|
29
|
-
values && name in values ? String(values[name]) : m,
|
|
30
|
-
);
|
|
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);
|
|
36
|
-
},
|
|
37
|
-
getLocale: jest.fn().mockResolvedValue("en"),
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const mockHeaders = jest.fn();
|
|
42
|
-
jest.mock("next/headers", () => ({
|
|
43
|
-
__esModule: true,
|
|
44
|
-
headers: (...args: unknown[]) => mockHeaders(...args),
|
|
45
|
-
cookies: jest.fn().mockResolvedValue({
|
|
46
|
-
toString: () => "session=abc",
|
|
47
|
-
get: () => undefined,
|
|
48
|
-
}),
|
|
49
|
-
}));
|
|
50
|
-
|
|
51
|
-
const mockGetSession = jest.fn();
|
|
52
|
-
// eslint-disable-next-line no-restricted-syntax -- #507: mock-internal rewrite pending; auth.ts's lazy Better-Auth singleton has no HTTP/DB boundary a unit test of the session fields can mock without standing up Prisma.
|
|
53
|
-
jest.mock("../../../../../auth", () => ({
|
|
54
|
-
__esModule: true,
|
|
55
|
-
auth: { api: { getSession: (...args: unknown[]) => mockGetSession(...args) } },
|
|
56
|
-
}));
|
|
57
|
-
|
|
58
|
-
const mockPieces = jest.fn();
|
|
59
|
-
const mockConsents = jest.fn();
|
|
60
|
-
const mockSetConsent = jest.fn();
|
|
61
|
-
const mockDeleteStoredSessions = jest.fn();
|
|
62
|
-
jest.mock("@working-theory/api-client", () => ({
|
|
63
|
-
__esModule: true,
|
|
64
|
-
waitlistSignups: { me: jest.fn() },
|
|
65
|
-
flowCheckouts: { me: jest.fn() },
|
|
66
|
-
subscription: { me: jest.fn(), portalSession: jest.fn() },
|
|
67
|
-
leads: { submit: jest.fn() },
|
|
68
|
-
member: {
|
|
69
|
-
pieces: (...args: unknown[]) => mockPieces(...args),
|
|
70
|
-
consents: (...args: unknown[]) => mockConsents(...args),
|
|
71
|
-
setConsent: (...args: unknown[]) => mockSetConsent(...args),
|
|
72
|
-
deleteStoredSessions: (...args: unknown[]) => mockDeleteStoredSessions(...args),
|
|
73
|
-
},
|
|
74
|
-
hubSignIn: { me: jest.fn() },
|
|
75
|
-
visitorForwardHeaders: () => null,
|
|
76
|
-
}));
|
|
77
|
-
|
|
78
|
-
jest.mock("next/navigation", () => ({
|
|
79
|
-
__esModule: true,
|
|
80
|
-
useRouter: () => ({ push: jest.fn(), refresh: jest.fn(), replace: jest.fn() }),
|
|
81
|
-
usePathname: () => "/account/privacy",
|
|
82
|
-
redirect: jest.fn(),
|
|
83
|
-
}));
|
|
84
|
-
|
|
85
|
-
import Page from "../privacy/page";
|
|
86
|
-
|
|
87
|
-
const SESSION = {
|
|
88
|
-
user: {
|
|
89
|
-
id: "user_1",
|
|
90
|
-
name: "Ada Lovelace",
|
|
91
|
-
email: "ada@example.com",
|
|
92
|
-
emailVerified: true,
|
|
93
|
-
createdAt: new Date("2026-09-01T00:00:00.000Z"),
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
const COOKIE_INIT = { headers: { cookie: "session=abc" } };
|
|
97
|
-
const ok = <T,>(body: T) => ({ ok: true, body });
|
|
98
|
-
const refusal = (status: number, code: string) => ({
|
|
99
|
-
ok: false,
|
|
100
|
-
status,
|
|
101
|
-
body: { ok: false, error: { code, message: code } },
|
|
102
|
-
});
|
|
103
|
-
|
|
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 }> = {}) {
|
|
113
|
-
return {
|
|
114
|
-
id: "ai_training",
|
|
115
|
-
kind: "consent" as const,
|
|
116
|
-
area: "data" as const,
|
|
117
|
-
required: false,
|
|
118
|
-
signUp: false,
|
|
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.",
|
|
121
|
-
policyHref: "/privacy",
|
|
122
|
-
policyVersion: 1,
|
|
123
|
-
state: overrides.state === undefined ? null : overrides.state,
|
|
124
|
-
effective: overrides.effective ?? false,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/** A communications purpose, which Privacy never lists. */
|
|
129
|
-
function communicationsPurpose() {
|
|
130
|
-
return {
|
|
131
|
-
...trainingPurpose(),
|
|
132
|
-
id: "newsletter",
|
|
133
|
-
area: "communications" as const,
|
|
134
|
-
description: "This site's newsletter by email",
|
|
135
|
-
statement: "Email me the newsletter.",
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
let contentRoot: string;
|
|
140
|
-
|
|
141
|
-
beforeEach(() => {
|
|
142
|
-
contentRoot = mkdtempSync(join(tmpdir(), "ailk-privacy-"));
|
|
143
|
-
process.env.AILK_CONTENT_ROOT = contentRoot;
|
|
144
|
-
writeFileSync(join(contentRoot, "_site.mdx"), '---\nsiteName: "Test"\n---\n');
|
|
145
|
-
mockHeaders.mockReset().mockResolvedValue(new Headers());
|
|
146
|
-
mockGetSession.mockReset().mockResolvedValue(SESSION);
|
|
147
|
-
mockPieces.mockReset().mockResolvedValue(ok([]));
|
|
148
|
-
mockConsents.mockReset().mockResolvedValue(ok({ purposes: [trainingPurpose(), communicationsPurpose()] }));
|
|
149
|
-
mockSetConsent.mockReset();
|
|
150
|
-
mockDeleteStoredSessions.mockReset().mockResolvedValue(ok({ deleted: 2 }));
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
afterEach(() => {
|
|
154
|
-
rmSync(contentRoot, { recursive: true, force: true });
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
async function renderPage(locale = "en"): Promise<void> {
|
|
158
|
-
render(await Page({ params: Promise.resolve({ locale }) }));
|
|
159
|
-
}
|
|
160
|
-
|
|
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", () => {
|
|
166
|
-
it("the Settings rail reads General, Security, Notifications, Privacy, Billing, Privacy current", async () => {
|
|
167
|
-
await renderPage();
|
|
168
|
-
const rail = screen.getByRole("navigation", { name: "Settings" });
|
|
169
|
-
const links = within(rail).getAllByRole("link");
|
|
170
|
-
expect(links.map((link) => link.textContent)).toEqual([
|
|
171
|
-
"General",
|
|
172
|
-
"Security",
|
|
173
|
-
"Notifications",
|
|
174
|
-
"Privacy",
|
|
175
|
-
"Billing",
|
|
176
|
-
]);
|
|
177
|
-
expect(screen.getByTestId("account-settings-rail-privacy")).toHaveAttribute("aria-current", "page");
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it("a non-default locale prefixes the rail and the policy link", async () => {
|
|
181
|
-
await renderPage("fr");
|
|
182
|
-
expect(screen.getByTestId("account-settings-rail-privacy")).toHaveAttribute("href", "/fr/account/privacy");
|
|
183
|
-
expect(screen.getByTestId("account-privacy-policy")).toHaveAttribute("href", "/fr/privacy");
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
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 () => {
|
|
189
|
-
mockConsents.mockResolvedValue(
|
|
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
|
-
}),
|
|
198
|
-
);
|
|
199
|
-
await renderPage();
|
|
200
|
-
const pane = screen.getByTestId("account-settings-privacy");
|
|
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 [
|
|
262
|
-
"account-privacy-summary",
|
|
263
|
-
"account-privacy-cookies",
|
|
264
|
-
"account-cookie-settings",
|
|
265
|
-
"account-privacy-consents",
|
|
266
|
-
"account-privacy-agreements",
|
|
267
|
-
"account-deletion",
|
|
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);
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
it("the chevron expands the row in place to the two bullets, in order, and is a disclosure button", async () => {
|
|
291
|
-
await renderPage();
|
|
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");
|
|
301
|
-
});
|
|
302
|
-
|
|
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()] }));
|
|
305
|
-
await renderPage();
|
|
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();
|
|
310
|
-
});
|
|
311
|
-
|
|
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"));
|
|
314
|
-
await renderPage();
|
|
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
|
-
);
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
|
|
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 () => {
|
|
327
|
-
await renderPage();
|
|
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();
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
it("ticking it writes the ledger through setConsentAction and shows the given date the answer carries", async () => {
|
|
333
|
-
mockSetConsent.mockResolvedValue(
|
|
334
|
-
ok({
|
|
335
|
-
purpose: trainingPurpose({
|
|
336
|
-
effective: true,
|
|
337
|
-
state: { granted: true, at: "2026-11-08T12:00:00.000Z", source: "account_settings", policyVersion: 1 },
|
|
338
|
-
}),
|
|
339
|
-
}),
|
|
340
|
-
);
|
|
341
|
-
await renderPage();
|
|
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",
|
|
347
|
-
);
|
|
348
|
-
expect(screen.getByTestId("account-privacy-data-consent-ai_training-switch")).toBeChecked();
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
it("a failed answer reverts the switch with its message", async () => {
|
|
352
|
-
mockSetConsent.mockResolvedValue(refusal(500, "internal"));
|
|
353
|
-
await renderPage();
|
|
354
|
-
fireEvent.click(screen.getByTestId("account-privacy-data-consent-ai_training-switch"));
|
|
355
|
-
await waitFor(() =>
|
|
356
|
-
expect(screen.getByTestId("account-privacy-data-consent-ai_training-error")).toBeInTheDocument(),
|
|
357
|
-
);
|
|
358
|
-
expect(screen.getByTestId("account-privacy-data-consent-ai_training-switch")).not.toBeChecked();
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
it("a data purpose a site adds is labelled by its statement and described by its description", async () => {
|
|
362
|
-
mockConsents.mockResolvedValue(
|
|
363
|
-
ok({
|
|
364
|
-
purposes: [
|
|
365
|
-
{
|
|
366
|
-
...trainingPurpose(),
|
|
367
|
-
id: "data_sharing",
|
|
368
|
-
description: "Product-usage data.",
|
|
369
|
-
statement: "Share product-usage data with us.",
|
|
370
|
-
},
|
|
371
|
-
],
|
|
372
|
-
}),
|
|
373
|
-
);
|
|
374
|
-
await renderPage();
|
|
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.",
|
|
378
|
-
);
|
|
379
|
-
expect(row).toHaveTextContent("Product-usage data.");
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
|
|
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");
|
|
389
|
-
});
|
|
390
|
-
});
|
|
391
|
-
|
|
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");
|
|
396
|
-
await act(async () => {
|
|
397
|
-
fireEvent.click(within(dialog).getByTestId("account-privacy-your-data-delete-confirm-action"));
|
|
398
|
-
});
|
|
399
|
-
}
|
|
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
|
-
|
|
414
|
-
it.each([
|
|
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 }));
|
|
420
|
-
await renderPage();
|
|
421
|
-
await confirmDelete();
|
|
422
|
-
expect(mockDeleteStoredSessions).toHaveBeenCalledWith(COOKIE_INIT);
|
|
423
|
-
await waitFor(() => expect(screen.getByRole("status")).toHaveTextContent(line));
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
it("a refusal shows the failure line as an alert", async () => {
|
|
427
|
-
mockDeleteStoredSessions.mockResolvedValue(refusal(429, "rate_limited"));
|
|
428
|
-
await renderPage();
|
|
429
|
-
await confirmDelete();
|
|
430
|
-
await waitFor(() =>
|
|
431
|
-
expect(screen.getByRole("alert")).toHaveTextContent("We couldn't delete your stored sessions. Try again in a moment."),
|
|
432
|
-
);
|
|
433
|
-
});
|
|
434
|
-
|
|
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 () => {
|
|
440
|
-
mockPieces.mockResolvedValue(refusal(404, "not_found"));
|
|
441
|
-
await renderPage();
|
|
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
|
-
);
|
|
448
|
-
});
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
describe("the standalone shape (#8430)", () => {
|
|
452
|
-
it("takes the screen as the Admin's settings do: the rail column and the pane are the page's own landmarks", async () => {
|
|
453
|
-
await renderPage();
|
|
454
|
-
const settings = screen.getByTestId("account-settings");
|
|
455
|
-
expect(settings).toHaveClass("min-h-screen");
|
|
456
|
-
const column = within(settings).getByRole("complementary");
|
|
457
|
-
expect(column.firstElementChild).toBe(screen.getByTestId("account-settings-back"));
|
|
458
|
-
expect(within(settings).getByRole("main")).toContainElement(
|
|
459
|
-
screen.getByRole("heading", { level: 1 }),
|
|
460
|
-
);
|
|
461
|
-
});
|
|
462
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
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
|
-
}
|