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,375 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for /[locale]/account/notifications — User settings › Notifications
|
|
3
|
-
* (#8339 D8; #8438 D15, AC-8; #11163 AC-1). Always renders (decision A): one
|
|
4
|
-
* `ConsentSwitchList` of the registry's `area: "communications"` purposes,
|
|
5
|
-
* or one empty line with none declared. The cookie-settings link moved to
|
|
6
|
-
* Privacy (#8438 D14) — this tab no longer renders it. #11163: the three
|
|
7
|
-
* shipped purposes render as Email notifications · Onboarding · Marketing —
|
|
8
|
-
* a title, a line and a switch, never the consent statement — over the
|
|
9
|
-
* always-sent line.
|
|
10
|
-
*/
|
|
11
|
-
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
12
|
-
import { tmpdir } from "node:os";
|
|
13
|
-
import { join } from "node:path";
|
|
14
|
-
|
|
15
|
-
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
|
16
|
-
|
|
17
|
-
jest.mock("next-intl/server", () => {
|
|
18
|
-
const msgs: unknown = require("../../../../../messages/en.json");
|
|
19
|
-
const dig = (obj: unknown, path: string): unknown =>
|
|
20
|
-
path.split(".").reduce<unknown>(
|
|
21
|
-
(acc, k) => (acc !== null && typeof acc === "object" ? (acc as Record<string, unknown>)[k] : undefined),
|
|
22
|
-
obj,
|
|
23
|
-
);
|
|
24
|
-
return {
|
|
25
|
-
__esModule: true,
|
|
26
|
-
getTranslations: async (arg: string | { namespace?: string; locale?: string }) => {
|
|
27
|
-
const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
|
|
28
|
-
const messages = dig(msgs, ns);
|
|
29
|
-
return (key: string, values?: Record<string, unknown>): string => {
|
|
30
|
-
const value = dig(messages, key);
|
|
31
|
-
if (typeof value !== "string") return `${ns}.${key}`;
|
|
32
|
-
return value.replace(/\{(\w+)\}/g, (m, name: string) =>
|
|
33
|
-
values && name in values ? String(values[name]) : m,
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
getLocale: jest.fn().mockResolvedValue("en"),
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
jest.mock("next/headers", () => ({
|
|
42
|
-
__esModule: true,
|
|
43
|
-
headers: jest.fn().mockResolvedValue(new Headers()),
|
|
44
|
-
cookies: jest.fn().mockResolvedValue({ toString: () => "session=abc", get: () => undefined }),
|
|
45
|
-
}));
|
|
46
|
-
|
|
47
|
-
const mockGetSession = jest.fn();
|
|
48
|
-
// 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.
|
|
49
|
-
jest.mock("../../../../../auth", () => ({
|
|
50
|
-
__esModule: true,
|
|
51
|
-
auth: { api: { getSession: (...args: unknown[]) => mockGetSession(...args) } },
|
|
52
|
-
}));
|
|
53
|
-
|
|
54
|
-
const mockConsents = jest.fn();
|
|
55
|
-
const mockSetConsent = jest.fn();
|
|
56
|
-
jest.mock("@working-theory/api-client", () => ({
|
|
57
|
-
__esModule: true,
|
|
58
|
-
waitlistSignups: { me: jest.fn() },
|
|
59
|
-
flowCheckouts: { me: jest.fn() },
|
|
60
|
-
subscription: { me: jest.fn(), portalSession: jest.fn() },
|
|
61
|
-
leads: { submit: jest.fn() },
|
|
62
|
-
member: {
|
|
63
|
-
pieces: jest.fn().mockResolvedValue({ ok: true, body: [] }),
|
|
64
|
-
consents: (...args: unknown[]) => mockConsents(...args),
|
|
65
|
-
setConsent: (...args: unknown[]) => mockSetConsent(...args),
|
|
66
|
-
},
|
|
67
|
-
hubSignIn: { me: jest.fn() },
|
|
68
|
-
visitorForwardHeaders: () => null,
|
|
69
|
-
}));
|
|
70
|
-
|
|
71
|
-
jest.mock("next/navigation", () => ({
|
|
72
|
-
__esModule: true,
|
|
73
|
-
useRouter: () => ({ push: jest.fn(), refresh: jest.fn(), replace: jest.fn() }),
|
|
74
|
-
usePathname: () => "/account/notifications",
|
|
75
|
-
redirect: jest.fn(),
|
|
76
|
-
}));
|
|
77
|
-
|
|
78
|
-
import {
|
|
79
|
-
EMAIL_NOTIFICATIONS_PURPOSE_ID,
|
|
80
|
-
NEWSLETTER_PURPOSE_ID,
|
|
81
|
-
NEWSLETTER_TERMS_STATEMENT,
|
|
82
|
-
ONBOARDING_PURPOSE_ID,
|
|
83
|
-
} from "@working-theory/validation";
|
|
84
|
-
|
|
85
|
-
import Page from "../notifications/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
|
-
|
|
97
|
-
const ok = <T,>(body: T) => ({ ok: true, body });
|
|
98
|
-
|
|
99
|
-
function communicationsPurpose(
|
|
100
|
-
overrides: Partial<{
|
|
101
|
-
id: string;
|
|
102
|
-
kind: "consent" | "preference";
|
|
103
|
-
effective: boolean;
|
|
104
|
-
state: { granted: boolean; at: string; source: string; policyVersion: number } | null;
|
|
105
|
-
}> = {},
|
|
106
|
-
) {
|
|
107
|
-
return {
|
|
108
|
-
id: overrides.id ?? "marketing_email",
|
|
109
|
-
kind: overrides.kind ?? "consent",
|
|
110
|
-
area: "communications" as const,
|
|
111
|
-
required: false,
|
|
112
|
-
signUp: false,
|
|
113
|
-
description: "Product news and offers.",
|
|
114
|
-
statement: "Receive product news and offers by email.",
|
|
115
|
-
policyHref: "/privacy",
|
|
116
|
-
policyVersion: 1,
|
|
117
|
-
state: overrides.state === undefined ? null : overrides.state,
|
|
118
|
-
effective: overrides.effective ?? false,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* The three rows `GET /v1/member/consents` serves from the shipped registry
|
|
124
|
-
* (#11163 AC-2), as the route answers them for a caller with no row yet:
|
|
125
|
-
* the two preferences effective on, the newsletter consent effective off.
|
|
126
|
-
*/
|
|
127
|
-
function shippedCommunicationsPurposes() {
|
|
128
|
-
return [
|
|
129
|
-
{
|
|
130
|
-
...communicationsPurpose({ id: EMAIL_NOTIFICATIONS_PURPOSE_ID, kind: "preference", effective: true }),
|
|
131
|
-
description: "Updates about your work here: messages, deliverables and requests.",
|
|
132
|
-
statement: "Email me updates about my work here: messages, deliverables and requests.",
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
...communicationsPurpose({ id: ONBOARDING_PURPOSE_ID, kind: "preference", effective: true }),
|
|
136
|
-
description: "Getting-started steps after your first sign-in.",
|
|
137
|
-
statement: "Email me getting-started steps after my first sign-in.",
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
...communicationsPurpose({ id: NEWSLETTER_PURPOSE_ID, kind: "consent", effective: false }),
|
|
141
|
-
description: "This site's newsletter by email",
|
|
142
|
-
statement: NEWSLETTER_TERMS_STATEMENT,
|
|
143
|
-
},
|
|
144
|
-
];
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
let contentRoot: string;
|
|
148
|
-
|
|
149
|
-
beforeEach(() => {
|
|
150
|
-
contentRoot = mkdtempSync(join(tmpdir(), "ailk-notifications-"));
|
|
151
|
-
process.env.AILK_CONTENT_ROOT = contentRoot;
|
|
152
|
-
writeFileSync(join(contentRoot, "_site.mdx"), '---\nsiteName: "Test"\n---\n');
|
|
153
|
-
mockGetSession.mockReset().mockResolvedValue(SESSION);
|
|
154
|
-
mockConsents.mockReset().mockResolvedValue(ok({ purposes: [] }));
|
|
155
|
-
mockSetConsent.mockReset();
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
afterEach(() => {
|
|
159
|
-
rmSync(contentRoot, { recursive: true, force: true });
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
async function renderPage(locale = "en"): Promise<void> {
|
|
163
|
-
render(await Page({ params: Promise.resolve({ locale }) }));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
describe("the frame (D7, D8)", () => {
|
|
167
|
-
it("renders in the settings frame with Notifications current", async () => {
|
|
168
|
-
await renderPage();
|
|
169
|
-
expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("Notifications");
|
|
170
|
-
expect(screen.getByTestId("account-settings-back")).toHaveAttribute("href", "/account");
|
|
171
|
-
expect(screen.getByTestId("account-settings-rail-notifications")).toHaveAttribute("aria-current", "page");
|
|
172
|
-
expect(screen.getByTestId("account-settings-rail-privacy")).not.toHaveAttribute("aria-current");
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
describe("the standalone shape (#8430)", () => {
|
|
177
|
-
it("takes the screen as the Admin's settings do: the rail column and the pane are the page's own landmarks", async () => {
|
|
178
|
-
await renderPage();
|
|
179
|
-
const settings = screen.getByTestId("account-settings");
|
|
180
|
-
expect(settings).toHaveClass("min-h-screen");
|
|
181
|
-
const column = within(settings).getByRole("complementary");
|
|
182
|
-
expect(column.firstElementChild).toBe(screen.getByTestId("account-settings-back"));
|
|
183
|
-
expect(column).toContainElement(screen.getByTestId("account-settings-rail"));
|
|
184
|
-
expect(within(settings).getByRole("main")).toContainElement(
|
|
185
|
-
screen.getByRole("heading", { level: 1 }),
|
|
186
|
-
);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
describe("AC-8 — always present, one empty line with no communications purposes declared", () => {
|
|
191
|
-
it("renders exactly one account-notifications-empty line and no cookie link", async () => {
|
|
192
|
-
await renderPage();
|
|
193
|
-
expect(screen.getByTestId("account-notifications-empty")).toHaveTextContent(
|
|
194
|
-
"There's nothing to set here yet.",
|
|
195
|
-
);
|
|
196
|
-
expect(screen.getByTestId("account-notifications-foot")).toHaveTextContent(
|
|
197
|
-
"Receipts, sign-in links and security notices are always sent.",
|
|
198
|
-
);
|
|
199
|
-
expect(screen.queryByTestId("account-cookie-settings")).not.toBeInTheDocument();
|
|
200
|
-
expect(screen.queryByTestId("account-notifications")).not.toBeInTheDocument();
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it("the tab link is present in the frame regardless", async () => {
|
|
204
|
-
await renderPage();
|
|
205
|
-
expect(screen.getByTestId("account-settings-rail-notifications")).toBeInTheDocument();
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
describe("#11163 AC-1 — the three rows: Email notifications · Onboarding · Marketing", () => {
|
|
210
|
-
beforeEach(() => {
|
|
211
|
-
mockConsents.mockResolvedValue(ok({ purposes: shippedCommunicationsPurposes() }));
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it("renders exactly three switch rows in registry order, each a title, a one-line description and a switch", async () => {
|
|
215
|
-
await renderPage();
|
|
216
|
-
const list = screen.getByTestId("account-notifications");
|
|
217
|
-
const rows = within(list).getAllByTestId(/^account-notifications-[a-z_]+$/);
|
|
218
|
-
expect(rows.map((row) => row.getAttribute("data-testid"))).toEqual([
|
|
219
|
-
"account-notifications-email_notifications",
|
|
220
|
-
"account-notifications-onboarding",
|
|
221
|
-
"account-notifications-newsletter",
|
|
222
|
-
]);
|
|
223
|
-
expect(within(list).getAllByRole("switch")).toHaveLength(3);
|
|
224
|
-
|
|
225
|
-
const titles = rows.map((row) => within(row).getByTestId(/-label$/).textContent);
|
|
226
|
-
expect(titles).toEqual(["Email notifications", "Onboarding", "Marketing"]);
|
|
227
|
-
expect(within(rows[0]!).getByText("Updates about your work here: messages, deliverables and requests.")).toBeInTheDocument();
|
|
228
|
-
expect(within(rows[1]!).getByText("Getting-started steps after your first sign-in.")).toBeInTheDocument();
|
|
229
|
-
expect(within(rows[2]!).getByText("This site's newsletter and offers by email.")).toBeInTheDocument();
|
|
230
|
-
for (const row of rows) {
|
|
231
|
-
expect(within(row).getByRole("switch")).toHaveAccessibleName(
|
|
232
|
-
within(row).getByTestId(/-label$/).textContent!,
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
it("defaults on · on · off with no row, and shows no date line until a state exists", async () => {
|
|
238
|
-
await renderPage();
|
|
239
|
-
expect(screen.getByTestId("account-notifications-email_notifications-switch")).toBeChecked();
|
|
240
|
-
expect(screen.getByTestId("account-notifications-onboarding-switch")).toBeChecked();
|
|
241
|
-
expect(screen.getByTestId("account-notifications-newsletter-switch")).not.toBeChecked();
|
|
242
|
-
expect(screen.queryAllByTestId(/^account-notifications-[a-z_]+-date$/)).toHaveLength(0);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it("renders the date line beneath a row once a state exists", async () => {
|
|
246
|
-
const [emailRow, onboarding, newsletter] = shippedCommunicationsPurposes();
|
|
247
|
-
mockConsents.mockResolvedValue(
|
|
248
|
-
ok({
|
|
249
|
-
purposes: [
|
|
250
|
-
{
|
|
251
|
-
...emailRow!,
|
|
252
|
-
effective: false,
|
|
253
|
-
state: { granted: false, at: "2026-11-01T12:00:00.000Z", source: "account_settings", policyVersion: 1 },
|
|
254
|
-
},
|
|
255
|
-
onboarding!,
|
|
256
|
-
newsletter!,
|
|
257
|
-
],
|
|
258
|
-
}),
|
|
259
|
-
);
|
|
260
|
-
await renderPage();
|
|
261
|
-
expect(screen.getByTestId("account-notifications-email_notifications-switch")).not.toBeChecked();
|
|
262
|
-
expect(screen.getByTestId("account-notifications-email_notifications-date")).toHaveTextContent(
|
|
263
|
-
"Withdrawn Nov 1, 2026",
|
|
264
|
-
);
|
|
265
|
-
expect(screen.queryByTestId("account-notifications-onboarding-date")).not.toBeInTheDocument();
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it("renders the always-sent line under the rows, inside the same card", async () => {
|
|
269
|
-
await renderPage();
|
|
270
|
-
const foot = screen.getByTestId("account-notifications-foot");
|
|
271
|
-
expect(foot).toHaveTextContent("Receipts, sign-in links and security notices are always sent.");
|
|
272
|
-
const list = screen.getByTestId("account-notifications");
|
|
273
|
-
expect(list.compareDocumentPosition(foot) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
274
|
-
expect(screen.getByTestId("account-settings-notifications-card")).toContainElement(foot);
|
|
275
|
-
expect(screen.getByTestId("account-settings-notifications-card")).toContainElement(list);
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
it("renders no consent statement and no markdown on any row", async () => {
|
|
279
|
-
await renderPage();
|
|
280
|
-
const pane = screen.getByTestId("account-settings-notifications");
|
|
281
|
-
for (const purpose of shippedCommunicationsPurposes()) {
|
|
282
|
-
expect(within(pane).queryByText(purpose.statement)).not.toBeInTheDocument();
|
|
283
|
-
}
|
|
284
|
-
expect(pane.textContent).not.toMatch(/\[[^\]]+\]\([^)]+\)/);
|
|
285
|
-
expect(pane.textContent).not.toContain("I accept");
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it("titles a purpose this app does not name by its registry description", async () => {
|
|
289
|
-
mockConsents.mockResolvedValue(
|
|
290
|
-
ok({ purposes: [communicationsPurpose({ id: "partner_offers", kind: "consent", effective: false })] }),
|
|
291
|
-
);
|
|
292
|
-
await renderPage();
|
|
293
|
-
expect(screen.getByTestId("account-notifications-partner_offers-label")).toHaveTextContent(
|
|
294
|
-
"Product news and offers.",
|
|
295
|
-
);
|
|
296
|
-
expect(screen.queryByText("Receive product news and offers by email.")).not.toBeInTheDocument();
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
describe("AC-8 — a declared communications preference defaults on with no row", () => {
|
|
301
|
-
it("renders one switch, on", async () => {
|
|
302
|
-
mockConsents.mockResolvedValue(
|
|
303
|
-
ok({ purposes: [communicationsPurpose({ kind: "preference", effective: true, state: null })] }),
|
|
304
|
-
);
|
|
305
|
-
await renderPage();
|
|
306
|
-
expect(screen.queryByTestId("account-notifications-empty")).not.toBeInTheDocument();
|
|
307
|
-
expect(screen.getByTestId("account-notifications-marketing_email-switch")).toBeChecked();
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
describe("AC-8 — a declared communications consent defaults off with no row", () => {
|
|
312
|
-
it("renders one switch, off", async () => {
|
|
313
|
-
mockConsents.mockResolvedValue(
|
|
314
|
-
ok({ purposes: [communicationsPurpose({ kind: "consent", effective: false, state: null })] }),
|
|
315
|
-
);
|
|
316
|
-
await renderPage();
|
|
317
|
-
expect(screen.getByTestId("account-notifications-marketing_email-switch")).not.toBeChecked();
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
it("toggling calls setConsentAction through member.setConsent", async () => {
|
|
321
|
-
mockConsents.mockResolvedValue(
|
|
322
|
-
ok({ purposes: [communicationsPurpose({ kind: "consent", effective: false, state: null })] }),
|
|
323
|
-
);
|
|
324
|
-
mockSetConsent.mockResolvedValue(
|
|
325
|
-
ok({
|
|
326
|
-
purpose: communicationsPurpose({
|
|
327
|
-
kind: "consent",
|
|
328
|
-
effective: true,
|
|
329
|
-
state: { granted: true, at: "2026-10-12T12:00:00.000Z", source: "account_settings", policyVersion: 1 },
|
|
330
|
-
}),
|
|
331
|
-
}),
|
|
332
|
-
);
|
|
333
|
-
await renderPage();
|
|
334
|
-
fireEvent.click(screen.getByTestId("account-notifications-marketing_email-switch"));
|
|
335
|
-
await waitFor(() => expect(mockSetConsent).toHaveBeenCalledTimes(1));
|
|
336
|
-
expect(mockSetConsent).toHaveBeenCalledWith(
|
|
337
|
-
{ purposeId: "marketing_email", granted: true, locale: "en" },
|
|
338
|
-
expect.objectContaining({ headers: expect.objectContaining({ cookie: "session=abc" }) }),
|
|
339
|
-
);
|
|
340
|
-
expect(await screen.findByTestId("account-notifications-marketing_email-date")).toHaveTextContent(
|
|
341
|
-
"Given Oct 12, 2026",
|
|
342
|
-
);
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
describe("the Privacy tab's data purposes (#11164 AC-2)", () => {
|
|
347
|
-
it("does not list a `data` purpose: the training switch is Privacy's alone", async () => {
|
|
348
|
-
mockConsents.mockResolvedValue(
|
|
349
|
-
ok({
|
|
350
|
-
purposes: [
|
|
351
|
-
...shippedCommunicationsPurposes(),
|
|
352
|
-
{
|
|
353
|
-
...communicationsPurpose({ id: "ai_training", kind: "consent", effective: false }),
|
|
354
|
-
area: "data" as const,
|
|
355
|
-
description: "Use of your communications, artifacts and sessions to train and improve AI models.",
|
|
356
|
-
statement: "I allow the use of my communications, artifacts, and sessions to train and improve AI models.",
|
|
357
|
-
},
|
|
358
|
-
],
|
|
359
|
-
}),
|
|
360
|
-
);
|
|
361
|
-
await renderPage();
|
|
362
|
-
expect(screen.getAllByRole("switch")).toHaveLength(3);
|
|
363
|
-
expect(screen.queryByTestId("account-notifications-ai_training")).not.toBeInTheDocument();
|
|
364
|
-
expect(screen.queryByText("Help improve our AI models")).not.toBeInTheDocument();
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
describe("a failed consents read", () => {
|
|
369
|
-
it("shows the unavailable line, not a broken switch list", async () => {
|
|
370
|
-
mockConsents.mockResolvedValue({ ok: false, status: 503, body: null });
|
|
371
|
-
await renderPage();
|
|
372
|
-
expect(screen.getByTestId("account-notifications-unavailable")).toBeInTheDocument();
|
|
373
|
-
expect(screen.queryByTestId("account-notifications-empty")).not.toBeInTheDocument();
|
|
374
|
-
});
|
|
375
|
-
});
|