create-ailk 0.37.0 → 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 (232) hide show
  1. package/README.md +149 -2
  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 +7 -2
  6. package/dist/add-route.js +28 -13
  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 +28 -1
  36. package/dist/sync-routes.js +144 -11
  37. package/dist/template-record.d.ts +11 -0
  38. package/dist/template-record.js +18 -0
  39. package/dist/topology.d.ts +15 -1
  40. package/dist/topology.js +20 -4
  41. package/dist/update.d.ts +31 -2
  42. package/dist/update.js +627 -99
  43. package/package.json +3 -3
  44. package/templates/README.md +1 -1
  45. package/templates/apps/mcp/CLAUDE.md +5 -3
  46. package/templates/apps/web/CLAUDE.md +62 -20
  47. package/templates/apps/web/account.config.tsx +101 -0
  48. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
  49. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
  50. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
  51. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
  52. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
  53. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
  54. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
  55. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
  56. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
  57. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
  58. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
  59. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
  60. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
  61. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
  62. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
  63. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
  64. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
  65. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
  66. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
  67. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
  68. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
  69. package/templates/apps/web/app/[locale]/layout.tsx +45 -28
  70. package/templates/apps/web/app/apple-icon.tsx +72 -0
  71. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
  72. package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
  73. package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
  74. package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
  75. package/templates/apps/web/app/og/route.tsx +155 -72
  76. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
  77. package/templates/apps/web/i18n/request.ts +44 -1
  78. package/templates/apps/web/jest.config.cjs +13 -1
  79. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
  80. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -0
  81. package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
  82. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
  83. package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
  84. package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
  85. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
  86. package/templates/apps/web/lib/listings.tsx +2 -2
  87. package/templates/apps/web/lib/nav-label-keys.ts +16 -2
  88. package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
  89. package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
  90. package/templates/apps/web/lib/profile-back-link.ts +105 -32
  91. package/templates/apps/web/lib/served-pages.ts +95 -0
  92. package/templates/apps/web/lib/site-brand.tsx +3 -5
  93. package/templates/apps/web/messages/en.json +8 -684
  94. package/templates/apps/web/middleware.ts +3 -1
  95. package/templates/apps/web/next.config.mjs +27 -0
  96. package/templates/apps/web/package.json +1 -0
  97. package/templates/customizations.yaml +9 -0
  98. package/templates/package.json +3 -1
  99. package/templates/tools/lint-architecture.ts +164 -11
  100. package/versions.json +48 -47
  101. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
  102. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
  103. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
  104. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
  105. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
  106. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
  107. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
  108. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
  109. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
  110. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
  111. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
  112. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
  113. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
  114. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
  115. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
  116. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
  117. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
  118. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
  119. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
  120. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
  121. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
  122. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
  123. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
  124. package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
  125. package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
  126. package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
  127. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
  128. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
  129. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
  130. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
  131. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
  132. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
  133. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
  134. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
  135. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
  136. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
  137. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
  138. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
  139. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
  140. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
  141. package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
  142. package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
  143. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
  144. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
  145. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
  146. package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
  147. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
  148. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
  149. package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
  150. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
  151. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
  152. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
  153. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
  154. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
  155. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
  156. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
  157. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
  158. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
  159. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
  160. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
  161. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
  162. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
  163. package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
  164. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
  165. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
  166. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
  167. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
  168. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
  169. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
  170. package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
  171. package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
  172. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
  173. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
  174. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
  175. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
  176. package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
  177. package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
  178. package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
  179. package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
  180. package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
  181. package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
  182. package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
  183. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
  184. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
  185. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
  186. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
  187. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
  188. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
  189. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
  190. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
  191. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
  192. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
  193. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
  194. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
  195. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
  196. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
  197. package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
  198. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
  199. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
  200. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
  201. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
  202. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
  203. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
  204. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
  205. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
  206. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
  207. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
  208. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
  209. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
  210. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
  211. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
  212. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
  213. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
  214. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
  215. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
  216. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
  217. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
  218. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
  219. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
  220. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
  221. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
  222. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
  223. package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
  224. package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
  225. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
  226. package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
  227. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
  228. package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
  229. package/templates/apps/web/lib/account-config.ts +0 -678
  230. package/templates/apps/web/lib/checkout-config.ts +0 -16
  231. package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
  232. package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
@@ -1,264 +0,0 @@
1
- /**
2
- * Tests for /[locale]/account/inbox/[kind]/[id] — one Inbox item (#7430,
3
- * spec 7423 U4; D8's detail contract).
4
- *
5
- * Covers:
6
- * 1. A known kind + id renders the shared `InboxItemFrame` through the
7
- * kind's own `renderDetail`: a back link to the Inbox, the kind as the
8
- * caption, the item's title as the `<h1>`, and the kind's fields.
9
- * 2. An unknown kind, or an id the kind did not load, is a not-found —
10
- * never an empty frame.
11
- * 3. A failed read renders an error with Retry (D12's posture).
12
- * 4. A message whose `action` is `onboarding` has an Open onboarding
13
- * action to the locale's `/account/onboarding`; a message with no
14
- * action has none (#8515 D6, AC-4).
15
- * 5. #11152 — a conversation kind's item page links to the member thread
16
- * page (Open conversation); a stacked kind's does not.
17
- *
18
- * The `purchase` kind reads `member.purchases` (#8231 D5); the `message`
19
- * kind reads `member.messages`.
20
- */
21
- import { fireEvent, render, screen, within } from "@testing-library/react";
22
-
23
- jest.mock("next-intl/server", () => {
24
- const msgs: unknown = require("../../../../../messages/en.json");
25
- const dig = (obj: unknown, path: string): unknown =>
26
- path.split(".").reduce<unknown>(
27
- (acc, k) => (acc !== null && typeof acc === "object" ? (acc as Record<string, unknown>)[k] : undefined),
28
- obj,
29
- );
30
- return {
31
- __esModule: true,
32
- getTranslations: async (arg: string | { namespace?: string; locale?: string }) => {
33
- const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
34
- const messages = dig(msgs, ns);
35
- return (key: string, values?: Record<string, unknown>): string => {
36
- const value = dig(messages, key);
37
- if (typeof value !== "string") return `${ns}.${key}`;
38
- return value.replace(/\{(\w+)\}/g, (m, name: string) =>
39
- values && name in values ? String(values[name]) : m,
40
- );
41
- };
42
- },
43
- };
44
- });
45
-
46
- jest.mock("next/headers", () => ({
47
- __esModule: true,
48
- headers: jest.fn().mockResolvedValue(new Headers()),
49
- cookies: jest.fn().mockResolvedValue({ toString: () => "session=abc" }),
50
- }));
51
-
52
- const mockGetSession = 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: { api: { getSession: (...args: unknown[]) => mockGetSession(...args) } },
57
- }));
58
-
59
- const mockSignupMe = jest.fn();
60
- const mockMemberPurchases = jest.fn();
61
- const mockMemberMessages = jest.fn();
62
- jest.mock("@working-theory/api-client", () => ({
63
- __esModule: true,
64
- waitlistSignups: { me: (...args: unknown[]) => mockSignupMe(...args) },
65
- subscription: { me: jest.fn() },
66
- member: {
67
- purchases: (...args: unknown[]) => mockMemberPurchases(...args),
68
- messages: (...args: unknown[]) => mockMemberMessages(...args),
69
- },
70
- }));
71
-
72
- const mockNotFound = jest.fn(() => {
73
- throw new Error("NEXT_NOT_FOUND");
74
- });
75
- const mockRefresh = jest.fn();
76
- jest.mock("next/navigation", () => ({
77
- __esModule: true,
78
- notFound: () => mockNotFound(),
79
- useRouter: () => ({ push: jest.fn(), refresh: mockRefresh }),
80
- usePathname: () => "/account/inbox/purchase/fc_done",
81
- }));
82
-
83
- import Page from "../inbox/[kind]/[id]/page";
84
-
85
- const SESSION = {
86
- user: { id: "user_1", name: "Ada", email: "ada@example.com", emailVerified: true },
87
- };
88
-
89
- const PURCHASE = {
90
- id: "fc_done",
91
- offering: "pro",
92
- amountMinor: 4900,
93
- currency: "usd",
94
- period: "monthly",
95
- purchasedAt: "2026-09-04T10:00:00.000Z",
96
- };
97
-
98
- const MESSAGE = {
99
- id: "int_plain",
100
- subject: "Hello",
101
- body: "A note.",
102
- file: null,
103
- action: null,
104
- createdAt: "2026-10-14T09:00:00.000Z",
105
- readAt: null,
106
- };
107
- const MESSAGES = [
108
- MESSAGE,
109
- {
110
- ...MESSAGE,
111
- id: "int_onboarding",
112
- subject: "Your onboarding questions",
113
- body: "Open this message in your account and choose Open onboarding.",
114
- action: "onboarding",
115
- },
116
- ];
117
-
118
- beforeEach(() => {
119
- mockGetSession.mockReset().mockResolvedValue(SESSION);
120
- mockMemberPurchases.mockReset().mockResolvedValue({ ok: true, body: { items: [PURCHASE] } });
121
- mockMemberMessages.mockReset().mockResolvedValue({ ok: true, body: { items: MESSAGES } });
122
- mockSignupMe.mockReset();
123
- mockNotFound.mockClear();
124
- mockRefresh.mockReset();
125
- });
126
-
127
- async function renderItem(kind: string, id: string, locale = "en"): Promise<void> {
128
- const element = await Page({ params: Promise.resolve({ locale, kind, id }) });
129
- render(element);
130
- }
131
-
132
- describe("one Inbox item", () => {
133
- it("renders the kind's detail inside the shared item frame", async () => {
134
- await renderItem("purchase", "fc_done");
135
- expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("pro");
136
- expect(screen.getByText("Inbox").closest("a")).toHaveAttribute("href", "/account");
137
- // #11149 — the records read Orders on both sides of the seam.
138
- expect(screen.getAllByText("My orders").length).toBeGreaterThan(0);
139
- const fields = screen.getByTestId("account-item-fields");
140
- expect(within(fields).getByText("Amount")).toBeInTheDocument();
141
- expect(within(fields).getByText("Period")).toBeInTheDocument();
142
- expect(within(fields).getByText("monthly")).toBeInTheDocument();
143
- });
144
-
145
- it("decodes an encoded id segment", async () => {
146
- mockMemberPurchases.mockResolvedValue({ ok: true, body: { items: [{ ...PURCHASE, id: "fc done" }] } });
147
- await renderItem("purchase", "fc%20done");
148
- expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("pro");
149
- });
150
-
151
- it("a non-default locale's back link returns to that locale's Inbox", async () => {
152
- await renderItem("purchase", "fc_done", "fr");
153
- expect(screen.getByText("Inbox").closest("a")).toHaveAttribute("href", "/fr/account");
154
- });
155
-
156
- it("an unknown kind is a not-found", async () => {
157
- await expect(renderItem("nope", "fc_done")).rejects.toThrow("NEXT_NOT_FOUND");
158
- expect(mockMemberPurchases).not.toHaveBeenCalled();
159
- });
160
-
161
- it("an id the kind did not load is a not-found", async () => {
162
- await expect(renderItem("purchase", "fc_other")).rejects.toThrow("NEXT_NOT_FOUND");
163
- });
164
-
165
- it("a failed read renders an error with Retry, not a not-found", async () => {
166
- mockMemberPurchases.mockResolvedValue({ ok: false, status: 500, body: {} });
167
- await renderItem("purchase", "fc_done");
168
- expect(mockNotFound).not.toHaveBeenCalled();
169
- expect(screen.getByTestId("inbox-error")).toHaveTextContent("We couldn't load this item.");
170
- fireEvent.click(screen.getByTestId("inbox-retry"));
171
- expect(mockRefresh).toHaveBeenCalledTimes(1);
172
- });
173
- });
174
-
175
- describe("#11152 AC-1 — the message kind's item page links to the thread", () => {
176
- it("a message carries Open conversation to the locale's /account/inbox/thread, before its own actions", async () => {
177
- await renderItem("message", "int_onboarding", "fr");
178
- const desk = screen.getByTestId("account-item-head-actions");
179
- const actions = within(desk).getAllByRole("link");
180
- expect(actions.map((a) => a.textContent)).toEqual(["Open conversation", "Open onboarding"]);
181
- expect(within(desk).getByTestId("account-item-action-thread-desk")).toHaveAttribute(
182
- "href",
183
- "/fr/account/inbox/thread",
184
- );
185
- expect(screen.getByTestId("account-item-action-thread-mobile")).toHaveAttribute(
186
- "href",
187
- "/fr/account/inbox/thread",
188
- );
189
- });
190
-
191
- it("a stacked kind's item page carries no thread link", async () => {
192
- await renderItem("purchase", "fc_done");
193
- expect(screen.queryByTestId("account-item-action-thread-desk")).not.toBeInTheDocument();
194
- });
195
- });
196
-
197
- describe("#11007 AC-3a-9 — a message renders through the chat layout", () => {
198
- it("the message is a start-side MessageBubble under RecordHeader, captioned with when it was sent", async () => {
199
- await renderItem("message", "int_plain");
200
- const frame = screen.getByTestId("account-item");
201
- const header = within(frame).getByTestId("account-item-header");
202
- expect(within(header).getByRole("heading", { level: 1 })).toHaveTextContent("Hello");
203
- const back = within(header).getByTestId("account-item-back");
204
- expect(back).toHaveAttribute("href", "/account");
205
- expect(back).toHaveAttribute("data-back-link");
206
- expect(back).toHaveAccessibleName("Inbox");
207
-
208
- const conversation = within(frame).getByTestId("account-item-conversation");
209
- const bubble = within(conversation).getByTestId("account-item-message");
210
- expect(bubble).toHaveAttribute("data-side", "start");
211
- expect(bubble).toHaveTextContent("A note.");
212
- // The caption is from the account messages: "Sent · <when>".
213
- expect(bubble).toHaveTextContent(/^Sent · /);
214
- // No stacked head card or fields list.
215
- expect(screen.queryByTestId("account-item-fields")).not.toBeInTheDocument();
216
- expect(screen.queryByText("My messages")).not.toBeInTheDocument();
217
- });
218
-
219
- it("an attached file is the bubble's note, from the account messages", async () => {
220
- mockMemberMessages.mockResolvedValue({
221
- ok: true,
222
- body: { items: [{ ...MESSAGE, file: { filename: "plan.pdf" } }] },
223
- });
224
- await renderItem("message", "int_plain");
225
- expect(screen.getByTestId("account-item-message")).toHaveTextContent("File · plan.pdf");
226
- expect(screen.getByTestId("account-item-action-file-desk")).toHaveTextContent(
227
- "Download plan.pdf",
228
- );
229
- });
230
-
231
- it("the purchase kind keeps its stacked layout and fields", async () => {
232
- await renderItem("purchase", "fc_done");
233
- expect(screen.queryByTestId("account-item-header")).not.toBeInTheDocument();
234
- expect(screen.queryByTestId("account-item-conversation")).not.toBeInTheDocument();
235
- expect(screen.getByTestId("account-item-fields")).toBeInTheDocument();
236
- expect(screen.getByTestId("account-item-back")).toHaveAttribute("data-back-link");
237
- });
238
- });
239
-
240
- describe("a message's onboarding action (#8515 D6, AC-4)", () => {
241
- it("an onboarding message links to the locale's onboarding page", async () => {
242
- await renderItem("message", "int_onboarding", "fr");
243
- const links = screen
244
- .getAllByRole("link", { name: "Open onboarding" })
245
- .map((link) => link.getAttribute("href"));
246
- expect(links.length).toBeGreaterThan(0);
247
- expect(links.every((href) => href === "/fr/account/onboarding")).toBe(true);
248
- expect(screen.getByTestId("account-item-action-onboarding-desk")).toHaveAttribute(
249
- "href",
250
- "/fr/account/onboarding",
251
- );
252
- // The body stays plain text.
253
- expect(
254
- screen.getByText("Open this message in your account and choose Open onboarding.").closest("a"),
255
- ).toBeNull();
256
- });
257
-
258
- it("a message with no action has no onboarding link", async () => {
259
- await renderItem("message", "int_plain", "fr");
260
- expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("Hello");
261
- expect(screen.queryByRole("link", { name: "Open onboarding" })).not.toBeInTheDocument();
262
- expect(screen.queryByTestId("account-item-action-onboarding-desk")).not.toBeInTheDocument();
263
- });
264
- });
@@ -1,167 +0,0 @@
1
- /**
2
- * The account layout hands the generated seam's sign-out wiring to the client
3
- * frame (#8465): a client component cannot import `topology.generated.ts`, so
4
- * the server layout reads `SIGN_OUT_ENDPOINT` and passes it, with the home as
5
- * the landing after a sign-out (#11095 D4), as props. Also pins that the Help center
6
- * href is rendered only for an https URL (the #8467 review's Low finding).
7
- */
8
- import { render } from "@testing-library/react";
9
- import { localeHref } from "@working-theory/ui";
10
- import type { ReactElement } from "react";
11
-
12
- jest.mock("next-intl/server", () => ({
13
- __esModule: true,
14
- getTranslations: async (arg: { namespace?: string }) => (key: string) =>
15
- `${arg.namespace}.${key}`,
16
- }));
17
-
18
- let mockSeam: {
19
- SIGN_IN_PATH: string | null;
20
- SIGN_OUT_ENDPOINT: string | null;
21
- } = {
22
- SIGN_IN_PATH: "/sign-in",
23
- SIGN_OUT_ENDPOINT: null,
24
- };
25
- // eslint-disable-next-line no-restricted-syntax -- #507: the seam is generated per build (#7894 D8); its `signIn: "hub"` render is the boundary under test, and no env or HTTP surface selects it.
26
- jest.mock("../../../../../lib/topology.generated", () => ({
27
- __esModule: true,
28
- get SIGN_IN_PATH() {
29
- return mockSeam.SIGN_IN_PATH;
30
- },
31
- get SIGN_OUT_ENDPOINT() {
32
- return mockSeam.SIGN_OUT_ENDPOINT;
33
- },
34
- }));
35
-
36
- // eslint-disable-next-line no-restricted-syntax -- #507: test-seam mock; the layout under test composes these account modules and the suite asserts only the sign-out endpoint it forwards
37
- jest.mock("../account-data", () => ({
38
- __esModule: true,
39
- accountSession: async () => ({
40
- ctx: {
41
- locale: "en",
42
- user: { name: "Ada", email: "ada@example.com" },
43
- t: {},
44
- init: { headers: {} },
45
- },
46
- }),
47
- loadForYou: async () => ({ items: [], now: "2026-10-12T00:00:00.000Z" }),
48
- }));
49
-
50
- // eslint-disable-next-line no-restricted-syntax -- #507: test-seam mock; the layout under test composes these account modules and the suite asserts only the sign-out endpoint it forwards
51
- jest.mock("../for-you-labels", () => ({
52
- __esModule: true,
53
- forYouLabels: () => ({}),
54
- }));
55
- // eslint-disable-next-line no-restricted-syntax -- #507: test-seam mock; the layout under test composes these account modules and the suite asserts only the sign-out endpoint it forwards
56
- jest.mock("../../../../../lib/site-logo", () => ({
57
- __esModule: true,
58
- siteLogo: () => null,
59
- }));
60
-
61
- // #8765 D7 — the layout's agreements read: complete, so the frame renders.
62
- jest.mock("@working-theory/api-client", () => ({
63
- __esModule: true,
64
- consent: {
65
- accountAgreements: async () => ({
66
- ok: true,
67
- body: { agreements: [], complete: true },
68
- }),
69
- },
70
- }));
71
-
72
- const mockFrame = jest.fn();
73
- // eslint-disable-next-line no-restricted-syntax -- #507: test-seam mock; the layout under test composes these account modules and the suite asserts only the sign-out endpoint it forwards
74
- jest.mock("../account-frame", () => ({
75
- __esModule: true,
76
- AccountFrame: (props: Record<string, unknown>) => {
77
- mockFrame(props);
78
- return null;
79
- },
80
- }));
81
-
82
- import AccountLayout from "../layout";
83
-
84
- const ENV = process.env;
85
-
86
- async function renderLayout(locale = "en"): Promise<Record<string, unknown>> {
87
- const node = (await AccountLayout({
88
- children: null,
89
- params: Promise.resolve({ locale }),
90
- })) as ReactElement;
91
- render(node);
92
- return mockFrame.mock.calls[0]![0] as Record<string, unknown>;
93
- }
94
-
95
- beforeEach(() => {
96
- mockFrame.mockReset();
97
- mockSeam = { SIGN_IN_PATH: "/sign-in", SIGN_OUT_ENDPOINT: null };
98
- process.env = { ...ENV };
99
- delete process.env.AILK_HELP_CENTER_URL;
100
- });
101
-
102
- afterEach(() => {
103
- process.env = ENV;
104
- });
105
-
106
- describe("sign-out wiring (#8465)", () => {
107
- // #11095 D4 — the spoke's /account redirects into the hub sign-in, which
108
- // signs the person straight back in while their hub session lives, so a
109
- // hub-session sign-out lands on the localized home.
110
- it("passes the endpoint and the localized home on a hub sign-in spoke", async () => {
111
- mockSeam = {
112
- SIGN_IN_PATH: "/account",
113
- SIGN_OUT_ENDPOINT: "/api/hub-session/sign-out",
114
- };
115
- const props = await renderLayout("fr");
116
- expect(props.signOutEndpoint).toBe("/api/hub-session/sign-out");
117
- expect(props.signInHref).toBe(localeHref("fr", "/"));
118
- expect(props.signInHref).not.toMatch(/account/);
119
- });
120
-
121
- it("lands on the home when the seam names no sign-in path too", async () => {
122
- mockSeam = {
123
- SIGN_IN_PATH: null,
124
- SIGN_OUT_ENDPOINT: "/api/hub-session/sign-out",
125
- };
126
- expect((await renderLayout()).signInHref).toBe("/");
127
- });
128
-
129
- it("passes neither on a hub or a single site (no endpoint)", async () => {
130
- const props = await renderLayout();
131
- expect(props).not.toHaveProperty("signOutEndpoint");
132
- expect(props).not.toHaveProperty("signInHref");
133
- });
134
-
135
- it("carries the failed-sign-out label to the frame", async () => {
136
- const props = await renderLayout();
137
- expect((props.labels as Record<string, string>).signOutFailed).toBe(
138
- "account.frame.signOutFailed",
139
- );
140
- });
141
- });
142
-
143
- describe("Help center href (#8467 review, Low)", () => {
144
- const helpItems = (
145
- props: Record<string, unknown>,
146
- ): { id: string; href: string }[] =>
147
- props.helpItems as { id: string; href: string }[];
148
-
149
- it("renders an https URL", async () => {
150
- process.env.AILK_HELP_CENTER_URL = "https://help.example.com";
151
- expect(helpItems(await renderLayout()).map((i) => i.id)).toContain(
152
- "help-center",
153
- );
154
- });
155
-
156
- it.each([
157
- "javascript:alert(1)",
158
- "http://help.example.com",
159
- "not a url",
160
- "data:text/html,x",
161
- ])("drops %s", async (value) => {
162
- process.env.AILK_HELP_CENTER_URL = value;
163
- expect(helpItems(await renderLayout()).map((i) => i.id)).not.toContain(
164
- "help-center",
165
- );
166
- });
167
- });