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.
Files changed (230) hide show
  1. package/README.md +129 -0
  2. package/component-catalog.json +44 -6
  3. package/component-catalog.md +6 -5
  4. package/dist/add-module.js +16 -1
  5. package/dist/add-route.d.ts +2 -2
  6. package/dist/add-route.js +18 -11
  7. package/dist/cli.js +52 -0
  8. package/dist/declined-routes.d.ts +13 -0
  9. package/dist/declined-routes.js +74 -0
  10. package/dist/derive-architecture.d.ts +0 -6
  11. package/dist/derive-architecture.js +9 -15
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +3 -0
  14. package/dist/language-import.d.ts +93 -0
  15. package/dist/language-import.js +270 -43
  16. package/dist/lib/import-mdx.js +1 -1
  17. package/dist/lib/scaffold-render-sweep.d.ts +6 -3
  18. package/dist/lib/scaffold-render-sweep.js +8 -4
  19. package/dist/migrate-content.d.ts +6 -2
  20. package/dist/migrate-content.js +62 -5
  21. package/dist/module-architecture.js +139 -103
  22. package/dist/paid-sections.d.ts +13 -0
  23. package/dist/paid-sections.js +35 -5
  24. package/dist/programmatic.js +6 -16
  25. package/dist/remove-module.js +67 -0
  26. package/dist/routes.d.ts +103 -0
  27. package/dist/routes.js +708 -0
  28. package/dist/site-manifest.js +1 -1
  29. package/dist/site-roster.d.ts +2 -1
  30. package/dist/site-roster.js +30 -8
  31. package/dist/spoke-checkout.d.ts +28 -27
  32. package/dist/spoke-checkout.js +71 -102
  33. package/dist/surfaces.d.ts +18 -0
  34. package/dist/surfaces.js +47 -282
  35. package/dist/sync-routes.d.ts +14 -1
  36. package/dist/sync-routes.js +86 -5
  37. package/dist/topology.d.ts +15 -1
  38. package/dist/topology.js +20 -4
  39. package/dist/update.d.ts +17 -2
  40. package/dist/update.js +480 -77
  41. package/package.json +3 -3
  42. package/templates/README.md +1 -1
  43. package/templates/apps/mcp/CLAUDE.md +5 -3
  44. package/templates/apps/web/CLAUDE.md +62 -20
  45. package/templates/apps/web/account.config.tsx +101 -0
  46. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
  47. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
  48. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
  49. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
  50. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
  51. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
  52. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
  53. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
  54. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
  55. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
  56. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
  57. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
  58. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
  59. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
  60. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
  61. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
  62. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
  63. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
  64. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
  65. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
  66. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
  67. package/templates/apps/web/app/[locale]/layout.tsx +45 -28
  68. package/templates/apps/web/app/apple-icon.tsx +72 -0
  69. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
  70. package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
  71. package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
  72. package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
  73. package/templates/apps/web/app/og/route.tsx +155 -72
  74. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
  75. package/templates/apps/web/i18n/request.ts +44 -1
  76. package/templates/apps/web/jest.config.cjs +13 -1
  77. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
  78. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -0
  79. package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
  80. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
  81. package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
  82. package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
  83. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
  84. package/templates/apps/web/lib/listings.tsx +2 -2
  85. package/templates/apps/web/lib/nav-label-keys.ts +16 -2
  86. package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
  87. package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
  88. package/templates/apps/web/lib/profile-back-link.ts +105 -32
  89. package/templates/apps/web/lib/served-pages.ts +95 -0
  90. package/templates/apps/web/lib/site-brand.tsx +3 -5
  91. package/templates/apps/web/messages/en.json +8 -684
  92. package/templates/apps/web/middleware.ts +3 -1
  93. package/templates/apps/web/next.config.mjs +27 -0
  94. package/templates/apps/web/package.json +1 -0
  95. package/templates/customizations.yaml +9 -0
  96. package/templates/package.json +3 -1
  97. package/templates/tools/lint-architecture.ts +164 -11
  98. package/versions.json +48 -47
  99. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
  100. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
  101. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
  102. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
  103. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
  104. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
  105. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
  106. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
  107. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
  108. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
  109. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
  110. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
  111. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
  112. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
  113. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
  114. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
  115. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
  116. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
  117. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
  118. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
  119. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
  120. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
  121. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
  122. package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
  123. package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
  124. package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
  125. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
  126. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
  127. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
  128. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
  129. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
  130. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
  131. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
  132. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
  133. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
  134. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
  135. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
  136. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
  137. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
  138. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
  139. package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
  140. package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
  141. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
  142. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
  143. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
  144. package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
  145. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
  146. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
  147. package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
  148. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
  149. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
  150. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
  151. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
  152. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
  153. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
  154. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
  155. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
  156. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
  157. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
  158. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
  159. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
  160. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
  161. package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
  162. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
  163. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
  164. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
  165. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
  166. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
  167. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
  168. package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
  169. package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
  170. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
  171. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
  172. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
  173. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
  174. package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
  175. package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
  176. package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
  177. package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
  178. package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
  179. package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
  180. package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
  181. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
  182. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
  183. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
  184. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
  185. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
  186. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
  187. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
  188. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
  189. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
  190. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
  191. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
  192. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
  193. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
  194. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
  195. package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
  196. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
  197. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
  198. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
  199. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
  200. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
  201. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
  202. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
  203. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
  204. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
  205. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
  206. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
  207. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
  208. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
  209. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
  210. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
  211. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
  212. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
  213. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
  214. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
  215. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
  216. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
  217. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
  218. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
  219. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
  220. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
  221. package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
  222. package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
  223. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
  224. package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
  225. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
  226. package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
  227. package/templates/apps/web/lib/account-config.ts +0 -678
  228. package/templates/apps/web/lib/checkout-config.ts +0 -16
  229. package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
  230. package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
@@ -1,406 +0,0 @@
1
- /**
2
- * Tests for /[locale]/account/security — User settings › Security (#8339
3
- * D8; #8431 D2, D3, AC-2, AC-3, AC-4).
4
- *
5
- * - the frame with Security current (#8339);
6
- * - AC-2: a site or hub that can email a password link shows the Password
7
- * row from the session's own accounts, and its button requests a link
8
- * for the person's own address with the server-built `redirectTo`; a
9
- * seam rendered before #8431 degrades to the sentence;
10
- * - AC-3: any other site shows one sentence naming the deployment's
11
- * methods, never a provider list;
12
- * - AC-4 (site half): Log out signs out through Better Auth and lands on
13
- * the sign-in page, and a failed log-out navigates nowhere. The spoke
14
- * half is hub-mode.test.tsx's.
15
- */
16
- import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
17
- import { tmpdir } from "node:os";
18
- import { join } from "node:path";
19
-
20
- import { act, fireEvent, render, screen, within } from "@testing-library/react";
21
-
22
- jest.mock("next-intl/server", () => {
23
- const msgs: unknown = require("../../../../../messages/en.json");
24
- const dig = (obj: unknown, path: string): unknown =>
25
- path.split(".").reduce<unknown>(
26
- (acc, k) => (acc !== null && typeof acc === "object" ? (acc as Record<string, unknown>)[k] : undefined),
27
- obj,
28
- );
29
- return {
30
- __esModule: true,
31
- getTranslations: async (arg: string | { namespace?: string; locale?: string }) => {
32
- const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
33
- const messages = dig(msgs, ns);
34
- return (key: string, values?: Record<string, unknown>): string => {
35
- const value = dig(messages, key);
36
- if (typeof value !== "string") return `${ns}.${key}`;
37
- return value.replace(/\{(\w+)\}/g, (m, name: string) =>
38
- values && name in values ? String(values[name]) : m,
39
- );
40
- };
41
- },
42
- };
43
- });
44
-
45
- jest.mock("next/headers", () => ({
46
- __esModule: true,
47
- headers: jest.fn().mockResolvedValue(new Headers()),
48
- cookies: jest.fn().mockResolvedValue({ toString: () => "session=abc" }),
49
- }));
50
-
51
- const mockGetSession = jest.fn();
52
- const mockListUserAccounts = jest.fn();
53
- // 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.
54
- jest.mock("../../../../../auth", () => ({
55
- __esModule: true,
56
- auth: {
57
- api: {
58
- getSession: (...args: unknown[]) => mockGetSession(...args),
59
- listUserAccounts: (...args: unknown[]) => mockListUserAccounts(...args),
60
- },
61
- },
62
- }));
63
-
64
- /** `stale: true` serves the seam as one rendered before #8431 — no accounts reader (D2b). */
65
- const mockSeam = { stale: false };
66
- // eslint-disable-next-line no-restricted-syntax -- #507: the seam is generated per build (#7894 D8); a seam rendered before #8431 (D2b) is the boundary under test, and no env or HTTP surface selects it.
67
- jest.mock("../../../../../lib/topology.generated", () => {
68
- const real = jest.requireActual("../../../../../lib/topology.generated") as Record<string, unknown>;
69
- return {
70
- ...real,
71
- __esModule: true,
72
- get readOwnAccounts(): unknown {
73
- return mockSeam.stale ? undefined : real.readOwnAccounts;
74
- },
75
- };
76
- });
77
-
78
- jest.mock("@working-theory/api-client", () => ({
79
- __esModule: true,
80
- waitlistSignups: { me: jest.fn() },
81
- flowCheckouts: { me: jest.fn() },
82
- subscription: { me: jest.fn(), portalSession: jest.fn() },
83
- leads: { submit: jest.fn() },
84
- member: { pieces: jest.fn().mockResolvedValue({ ok: true, body: [] }) },
85
- hubSignIn: { me: jest.fn() },
86
- visitorForwardHeaders: () => null,
87
- }));
88
-
89
- const mockRequestPasswordReset = jest.fn();
90
- const mockSignOut = jest.fn();
91
- jest.mock("better-auth/react", () => ({
92
- __esModule: true,
93
- createAuthClient: () => ({
94
- requestPasswordReset: (...args: unknown[]) => mockRequestPasswordReset(...args),
95
- signOut: (...args: unknown[]) => mockSignOut(...args),
96
- }),
97
- }));
98
-
99
- const mockPush = jest.fn();
100
- const mockRefresh = jest.fn();
101
- jest.mock("next/navigation", () => ({
102
- __esModule: true,
103
- useRouter: () => ({ push: mockPush, refresh: mockRefresh, replace: jest.fn() }),
104
- usePathname: () => "/account/security",
105
- redirect: jest.fn(),
106
- }));
107
-
108
- import Page from "../security/page";
109
-
110
- const SESSION = {
111
- user: {
112
- id: "user_1",
113
- name: "Ada Lovelace",
114
- email: "ada@example.com",
115
- emailVerified: true,
116
- createdAt: new Date("2026-09-01T00:00:00.000Z"),
117
- },
118
- };
119
-
120
- const BASE_URL = "https://site.example.com";
121
- const ENV = process.env;
122
- const ENV_KEYS = [
123
- "GOOGLE_CLIENT_ID",
124
- "GOOGLE_CLIENT_SECRET",
125
- "GITHUB_CLIENT_ID",
126
- "GITHUB_CLIENT_SECRET",
127
- "AUTH_EMAIL_SERVER",
128
- "AUTH_EMAIL_FROM",
129
- "AUTH_EMAIL_WEBHOOK_SECRET",
130
- "AILK_AUTH_PASSWORD_RESET",
131
- "BETTER_AUTH_URL",
132
- "BETTER_AUTH_SECRET",
133
- ] as const;
134
-
135
- let contentRoot: string;
136
-
137
- beforeEach(() => {
138
- process.env = { ...ENV };
139
- for (const key of ENV_KEYS) delete process.env[key];
140
- contentRoot = mkdtempSync(join(tmpdir(), "ailk-security-"));
141
- process.env.AILK_CONTENT_ROOT = contentRoot;
142
- writeFileSync(join(contentRoot, "_site.mdx"), '---\nsiteName: "Test"\n---\n');
143
- mockGetSession.mockReset().mockResolvedValue(SESSION);
144
- mockListUserAccounts.mockReset().mockResolvedValue([]);
145
- mockRequestPasswordReset.mockReset().mockResolvedValue({ data: { status: true }, error: null });
146
- mockSignOut.mockReset().mockResolvedValue({ data: { success: true }, error: null });
147
- mockPush.mockReset();
148
- mockRefresh.mockReset();
149
- mockSeam.stale = false;
150
- });
151
-
152
- afterEach(() => {
153
- rmSync(contentRoot, { recursive: true, force: true });
154
- process.env = ENV;
155
- });
156
-
157
- async function renderPage(locale = "en"): Promise<void> {
158
- render(await Page({ params: Promise.resolve({ locale }) }));
159
- }
160
-
161
- /** The five `resetSendConfigured()` conjuncts (C1). */
162
- function enableReset(): void {
163
- process.env.AILK_AUTH_PASSWORD_RESET = "true";
164
- process.env.AUTH_EMAIL_SERVER = "smtp://x";
165
- process.env.AUTH_EMAIL_FROM = "site@example.com";
166
- process.env.AUTH_EMAIL_WEBHOOK_SECRET = "w".repeat(32);
167
- process.env.BETTER_AUTH_URL = BASE_URL;
168
- process.env.BETTER_AUTH_SECRET = "s".repeat(32);
169
- }
170
-
171
- function enableGoogle(): void {
172
- process.env.GOOGLE_CLIENT_ID = "id";
173
- process.env.GOOGLE_CLIENT_SECRET = "secret";
174
- }
175
-
176
- function enableGitHub(): void {
177
- process.env.GITHUB_CLIENT_ID = "id";
178
- process.env.GITHUB_CLIENT_SECRET = "secret";
179
- }
180
-
181
- describe("the frame (D7, D8)", () => {
182
- it("renders in the settings frame with Security current", async () => {
183
- await renderPage();
184
- expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("Security");
185
- expect(screen.getByTestId("account-settings-back")).toHaveAttribute("href", "/account");
186
- expect(screen.getByTestId("account-settings-rail-security")).toHaveAttribute("aria-current", "page");
187
- expect(screen.getByTestId("account-settings-rail-general")).not.toHaveAttribute("aria-current");
188
- });
189
- });
190
-
191
- describe("the standalone shape (#8430)", () => {
192
- it("takes the screen as the Admin's settings do: the rail column and the pane are the page's own landmarks", async () => {
193
- await renderPage();
194
- const settings = screen.getByTestId("account-settings");
195
- expect(settings).toHaveClass("min-h-screen");
196
- const column = within(settings).getByRole("complementary");
197
- expect(column.firstElementChild).toBe(screen.getByTestId("account-settings-back"));
198
- expect(column).toContainElement(screen.getByTestId("account-settings-rail"));
199
- expect(within(settings).getByRole("main")).toContainElement(
200
- screen.getByRole("heading", { level: 1 }),
201
- );
202
- });
203
- });
204
-
205
- describe("AC-2 — a site or hub that can email a password link", () => {
206
- beforeEach(enableReset);
207
-
208
- it("with no password: Not set, the create note and Set password — read from the session's own accounts", async () => {
209
- await renderPage();
210
- expect(screen.getByRole("heading", { level: 2 })).toHaveTextContent("Sign-in methods");
211
- expect(screen.getByTestId("account-security-password-status")).toHaveTextContent("Not set");
212
- expect(screen.getByTestId("account-security-password-note")).toHaveTextContent(
213
- "We'll email ada@example.com a secure link to create your password.",
214
- );
215
- expect(screen.getByTestId("account-security-password-request")).toHaveTextContent("Set password");
216
- expect(mockListUserAccounts).toHaveBeenCalledTimes(1);
217
- expect(mockListUserAccounts.mock.calls[0]?.[0]).toEqual({ headers: expect.any(Headers) });
218
- expect(document.querySelector('input[type="password"]')).toBeNull();
219
- expect(screen.getByTestId("account-security-log-out")).toBeInTheDocument();
220
- });
221
-
222
- it("with a credential account: Set, the change note and Change password", async () => {
223
- mockListUserAccounts.mockResolvedValue([{ providerId: "google" }, { providerId: "credential" }]);
224
- await renderPage();
225
- expect(screen.getByTestId("account-security-password-status")).toHaveTextContent("Set");
226
- expect(screen.getByTestId("account-security-password-note")).toHaveTextContent(
227
- "We'll email ada@example.com a secure link to change your password.",
228
- );
229
- expect(screen.getByTestId("account-security-password-request")).toHaveTextContent("Change password");
230
- });
231
-
232
- it("a failed accounts read renders the error row in the block's place, with Log out still rendered", async () => {
233
- const errorSpy = jest.spyOn(console, "error").mockImplementation(() => {});
234
- mockListUserAccounts.mockRejectedValue(new TypeError("db down"));
235
- await renderPage();
236
- expect(within(screen.getByTestId("account-signin-method")).getByTestId("inbox-error")).toHaveTextContent(
237
- "We couldn't check your password settings.",
238
- );
239
- expect(screen.queryByTestId("account-security-password")).not.toBeInTheDocument();
240
- expect(screen.getByTestId("account-security-log-out")).toBeInTheDocument();
241
- expect(errorSpy.mock.calls.map((args) => args.join(" "))).toEqual([
242
- "[account] read failed source=security-password errName=TypeError",
243
- ]);
244
- errorSpy.mockRestore();
245
- });
246
-
247
- it.each([
248
- ["en", `${BASE_URL}/reset-password`],
249
- ["fr", `${BASE_URL}/fr/reset-password`],
250
- ])("Set password (%s) requests a link for the session's own address with the server-built redirectTo", async (locale, redirectTo) => {
251
- await renderPage(locale);
252
- await act(async () => {
253
- fireEvent.click(screen.getByTestId("account-security-password-request"));
254
- });
255
- expect(mockRequestPasswordReset).toHaveBeenCalledTimes(1);
256
- expect(mockRequestPasswordReset).toHaveBeenCalledWith({ email: "ada@example.com", redirectTo });
257
- expect(screen.getByTestId("account-security-password-sent")).toBeInTheDocument();
258
- });
259
-
260
- it("a refused request shows the error, not the sent line", async () => {
261
- mockRequestPasswordReset.mockResolvedValue({ data: null, error: { status: 429 } });
262
- await renderPage();
263
- await act(async () => {
264
- fireEvent.click(screen.getByTestId("account-security-password-request"));
265
- });
266
- expect(screen.getByTestId("account-security-password-error")).toBeInTheDocument();
267
- expect(screen.queryByTestId("account-security-password-sent")).not.toBeInTheDocument();
268
- });
269
-
270
- it("with Google configured as well, no provider list renders", async () => {
271
- enableGoogle();
272
- await renderPage();
273
- expect(screen.getByTestId("account-security-password")).toBeInTheDocument();
274
- expect(screen.queryByText(/Google/)).not.toBeInTheDocument();
275
- });
276
-
277
- it("a seam rendered before #8431 (no accounts reader) degrades to the sentence, never the error row (D2b)", async () => {
278
- mockSeam.stale = true;
279
- await renderPage();
280
- // The five reset conjuncts include the email link's four, so a site that
281
- // can email a password link always offers the email link too.
282
- expect(screen.getByTestId("account-security-sentence")).toHaveTextContent(
283
- "You sign in with a link sent to ada@example.com or your email and password.",
284
- );
285
- expect(screen.queryByTestId("account-security-password")).not.toBeInTheDocument();
286
- expect(screen.queryByTestId("inbox-error")).not.toBeInTheDocument();
287
- expect(screen.getByTestId("account-security-log-out")).toBeInTheDocument();
288
- expect(mockListUserAccounts).not.toHaveBeenCalled();
289
- });
290
- });
291
-
292
- describe("AC-3 — a site that cannot email a password link shows one sentence", () => {
293
- it.each([
294
- ["Google alone", [enableGoogle], "You sign in with Google."],
295
- ["Google and GitHub", [enableGoogle, enableGitHub], "You sign in with Google or GitHub."],
296
- [
297
- "the email link alone",
298
- [
299
- () => {
300
- process.env.AUTH_EMAIL_WEBHOOK_SECRET = "w".repeat(32);
301
- process.env.AUTH_EMAIL_FROM = "site@example.com";
302
- process.env.BETTER_AUTH_URL = BASE_URL;
303
- process.env.BETTER_AUTH_SECRET = "s".repeat(32);
304
- },
305
- ],
306
- "You sign in with a link sent to ada@example.com.",
307
- ],
308
- [
309
- "the password method without the reset flag",
310
- [
311
- () => {
312
- process.env.AUTH_EMAIL_SERVER = "smtp://x";
313
- process.env.AUTH_EMAIL_FROM = "site@example.com";
314
- },
315
- ],
316
- "You sign in with your email and password.",
317
- ],
318
- ])("%s", async (_label, arrange, sentence) => {
319
- for (const step of arrange) step();
320
- await renderPage();
321
- expect(screen.getByTestId("account-security-sentence")).toHaveTextContent(sentence);
322
- expect(screen.queryByText("You're signed in as ada@example.com.")).not.toBeInTheDocument();
323
- expect(screen.queryByTestId("account-security-password")).not.toBeInTheDocument();
324
- expect(screen.queryByText("Sign-in methods")).not.toBeInTheDocument();
325
- expect(screen.queryByText("Available")).not.toBeInTheDocument();
326
- expect(mockListUserAccounts).not.toHaveBeenCalled();
327
- expect(screen.getByTestId("account-security-log-out")).toBeInTheDocument();
328
- });
329
-
330
- it("with no configured method it names the signed-in address (C5)", async () => {
331
- await renderPage();
332
- expect(screen.getByTestId("account-security-sentence")).toHaveTextContent(
333
- "You're signed in as ada@example.com.",
334
- );
335
- });
336
-
337
- it("the old Sign-in keys are gone and every added key carries its D5 value", () => {
338
- const msgs = require("../../../../../messages/en.json") as {
339
- account: { settings: { signIn: Record<string, unknown>; security: Record<string, unknown> } };
340
- };
341
- const { signIn, security } = msgs.account.settings;
342
- expect(Object.keys(signIn)).toEqual(["lead"]);
343
- expect(security).toEqual({
344
- title: "Security",
345
- methodsHeading: "Sign-in methods",
346
- passwordLabel: "Password",
347
- passwordSet: "Set",
348
- passwordNotSet: "Not set",
349
- setHint: "Add a password so you can also sign in with your email and password.",
350
- changeHint: "Change the password you sign in with.",
351
- setNote: "We'll email {email} a secure link to create your password.",
352
- changeNote: "We'll email {email} a secure link to change your password.",
353
- setButton: "Set password",
354
- changeButton: "Change password",
355
- sending: "Sending…",
356
- sent: "Link sent. It works once, for an hour. Saving a password signs you out everywhere.",
357
- sendFailed: "We couldn't send the email. Try again in a few minutes.",
358
- logOut: "Log out",
359
- logOutFailed: "Log out didn't finish. Try again.",
360
- signsInWith: "You sign in with {methods}.",
361
- signedInAs: "You're signed in as {email}.",
362
- methods: {
363
- google: "Google",
364
- github: "GitHub",
365
- magicLink: "a link sent to {email}",
366
- password: "your email and password",
367
- },
368
- passwordUnavailable: "We couldn't check your password settings.",
369
- });
370
- });
371
- });
372
-
373
- describe("AC-4 — Log out on a site", () => {
374
- it.each([
375
- ["en", "/sign-in"],
376
- ["fr", "/fr/sign-in"],
377
- ])("(%s) signs out through Better Auth once and lands on the sign-in page", async (locale, href) => {
378
- enableGoogle();
379
- await renderPage(locale);
380
- await act(async () => {
381
- fireEvent.click(screen.getByTestId("account-security-log-out"));
382
- });
383
- expect(mockSignOut).toHaveBeenCalledTimes(1);
384
- expect(mockPush).toHaveBeenCalledWith(href);
385
- expect(mockRefresh).toHaveBeenCalledTimes(1);
386
- });
387
-
388
- it("a refused sign-out navigates nowhere and shows the error", async () => {
389
- mockSignOut.mockResolvedValue({ data: null, error: { status: 500 } });
390
- await renderPage();
391
- await act(async () => {
392
- fireEvent.click(screen.getByTestId("account-security-log-out"));
393
- });
394
- expect(mockPush).not.toHaveBeenCalled();
395
- expect(screen.getByTestId("account-security-log-out-error")).toBeInTheDocument();
396
- });
397
-
398
- it.each([
399
- ["password", enableReset],
400
- ["sentence", enableGoogle],
401
- ])("the %s variant has no 'other devices' control", async (_label, arrange) => {
402
- arrange();
403
- await renderPage();
404
- expect(screen.queryByText(/other devices/i)).toBeNull();
405
- });
406
- });
@@ -1,93 +0,0 @@
1
- /**
2
- * Tests for /[locale]/account/settings — now a redirect to User settings ›
3
- * General (#8232, spec docs/specs/8232-member-settings-account-general-and-spec.md
4
- * D8, D15; AC-6).
5
- *
6
- * The one-page, anchored settings of #7430 split into `/account/general`
7
- * and `/account/billing`; its General, Security, Notifications, Privacy and
8
- * Billing cases moved to `general.test.tsx` and `billing.test.tsx`, rewritten
9
- * for D2–D9. A `#billing` fragment never reaches the server, so the server
10
- * redirect is to General and `BillingAnchor` forwards the fragment there
11
- * (`general.test.tsx` § AC-6).
12
- *
13
- * #8441 — `SETTINGS_ROUTES` (settings-frame.tsx) is the one list of User
14
- * settings' routes: the tabs read it, and so does `isSettingsPath`, the
15
- * exact, locale-aware membership test the account frame takes the settings
16
- * routes out of its shell with (layout.test.tsx renders each route).
17
- */
18
-
19
- const mockRedirect = jest.fn();
20
- jest.mock("next/navigation", () => ({
21
- __esModule: true,
22
- redirect: (...args: unknown[]) => mockRedirect(...args),
23
- }));
24
-
25
- import Page from "../settings/page";
26
- import { isSettingsPath, memberSettingsFrame, SETTINGS_ROUTES, type Translate } from "../settings-frame";
27
-
28
- beforeEach(() => {
29
- mockRedirect.mockReset();
30
- });
31
-
32
- describe("AC-6 — /account/settings redirects to /account/general (D8)", () => {
33
- it("redirects the default locale to /account/general", async () => {
34
- await Page({ params: Promise.resolve({ locale: "en" }) });
35
- expect(mockRedirect).toHaveBeenCalledTimes(1);
36
- expect(mockRedirect).toHaveBeenCalledWith("/account/general");
37
- });
38
-
39
- it("keeps a non-default locale", async () => {
40
- await Page({ params: Promise.resolve({ locale: "fr" }) });
41
- expect(mockRedirect).toHaveBeenCalledWith("/fr/account/general");
42
- });
43
- });
44
-
45
- describe("the one list of User settings' routes (#8441; #8438 D14 adds Privacy)", () => {
46
- it("names the five tabs, in the reference's order", () => {
47
- expect(SETTINGS_ROUTES.map(({ key, path }) => [key, path])).toEqual([
48
- ["general", "/account/general"],
49
- ["security", "/account/security"],
50
- ["notifications", "/account/notifications"],
51
- ["privacy", "/account/privacy"],
52
- ["billing", "/account/billing"],
53
- ]);
54
- });
55
-
56
- it.each(["en", "fr"])("the settings frame's tabs are that list, in %s", (locale) => {
57
- const t: Translate = (key) => key;
58
- const { tabs } = memberSettingsFrame(locale, t, "security");
59
- expect(tabs.map(({ key, href, label }) => [key, href, label])).toEqual(
60
- SETTINGS_ROUTES.map(({ key, path, titleKey }) => [
61
- key,
62
- locale === "en" ? path : `/${locale}${path}`,
63
- titleKey,
64
- ]),
65
- );
66
- });
67
- });
68
-
69
- describe("isSettingsPath — an exact, locale-aware match (#8441)", () => {
70
- it.each(SETTINGS_ROUTES.map(({ path }) => path))("%s is a settings route, bare or prefixed", (path) => {
71
- expect(isSettingsPath(path, "en")).toBe(true);
72
- expect(isSettingsPath(`/fr${path}`, "fr")).toBe(true);
73
- });
74
-
75
- it.each([
76
- ["/account", "en"],
77
- ["/account/settings", "en"],
78
- ["/account/support", "en"],
79
- ["/account/artifacts", "en"],
80
- // A sub-route stays inside the shell unless it is listed.
81
- ["/account/billing/history", "en"],
82
- ["/fr/account/billing/history", "fr"],
83
- ["/account/general/", "en"],
84
- ["/account/generalx", "en"],
85
- // Only the request's own locale is a prefix.
86
- ["/fr/account/general", "en"],
87
- ["/de/account/general", "fr"],
88
- ["/frx/account/general", "fr"],
89
- ["", "en"],
90
- ])("%s (locale %s) is not", (path, locale) => {
91
- expect(isSettingsPath(path, locale)).toBe(false);
92
- });
93
- });