create-ailk 0.37.1 → 0.39.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 (318) 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 +19 -12
  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 +12 -16
  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 +73 -2
  26. package/dist/routes.d.ts +130 -0
  27. package/dist/routes.js +954 -0
  28. package/dist/site-manifest.js +6 -4
  29. package/dist/site-roster.d.ts +11 -2
  30. package/dist/site-roster.js +63 -21
  31. package/dist/spoke-checkout.d.ts +28 -27
  32. package/dist/spoke-checkout.js +71 -102
  33. package/dist/surfaces.d.ts +26 -0
  34. package/dist/surfaces.js +105 -293
  35. package/dist/sync-routes.d.ts +14 -1
  36. package/dist/sync-routes.js +108 -10
  37. package/dist/template-record.js +3 -1
  38. package/dist/topology.d.ts +26 -1
  39. package/dist/topology.js +273 -7
  40. package/dist/update.d.ts +17 -2
  41. package/dist/update.js +480 -77
  42. package/package.json +3 -3
  43. package/templates/README.md +1 -1
  44. package/templates/apps/mcp/CLAUDE.md +5 -3
  45. package/templates/apps/web/CLAUDE.md +87 -23
  46. package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +5 -1
  47. package/templates/apps/web/__tests__/__mocks__/next-intl.ts +5 -1
  48. package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
  49. package/templates/apps/web/account.config.tsx +100 -0
  50. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
  51. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +2 -2
  52. package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
  53. package/templates/apps/web/app/[locale]/layout.tsx +46 -29
  54. package/templates/apps/web/app/apple-icon.tsx +72 -0
  55. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
  56. package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
  57. package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
  58. package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
  59. package/templates/apps/web/app/og/route.tsx +155 -72
  60. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
  61. package/templates/apps/web/auth.config.tsx +107 -0
  62. package/templates/apps/web/auth.ts +2 -1
  63. package/templates/apps/web/i18n/request.ts +51 -1
  64. package/templates/apps/web/jest.config.cjs +17 -1
  65. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
  66. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +73 -0
  67. package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
  68. package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
  69. package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
  70. package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
  71. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
  72. package/templates/apps/web/lib/listings.tsx +2 -2
  73. package/templates/apps/web/lib/nav-label-keys.ts +16 -2
  74. package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
  75. package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
  76. package/templates/apps/web/lib/profile-back-link.ts +105 -32
  77. package/templates/apps/web/lib/served-pages.ts +95 -0
  78. package/templates/apps/web/lib/server-api.ts +1 -1
  79. package/templates/apps/web/lib/site-brand.tsx +3 -5
  80. package/templates/apps/web/lib/topology.generated.ts +5 -0
  81. package/templates/apps/web/messages/en.json +8 -836
  82. package/templates/apps/web/middleware.ts +15 -26
  83. package/templates/apps/web/next.config.mjs +35 -0
  84. package/templates/apps/web/package.json +2 -0
  85. package/templates/apps/web/types/messages.d.ts +6 -1
  86. package/templates/customizations.yaml +9 -0
  87. package/templates/package.json +3 -1
  88. package/templates/tools/lint-architecture.ts +164 -11
  89. package/versions.json +49 -47
  90. package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +0 -322
  91. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +0 -554
  92. package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/consent-actions.test.ts +0 -56
  93. package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/page.test.tsx +0 -164
  94. package/templates/apps/web/app/[locale]/(auth)/consent/consent-form.tsx +0 -132
  95. package/templates/apps/web/app/[locale]/(auth)/consent/consent.actions.ts +0 -51
  96. package/templates/apps/web/app/[locale]/(auth)/consent/page.tsx +0 -144
  97. package/templates/apps/web/app/[locale]/(auth)/forgot-password/forgot-password-card.tsx +0 -101
  98. package/templates/apps/web/app/[locale]/(auth)/forgot-password/page.tsx +0 -111
  99. package/templates/apps/web/app/[locale]/(auth)/layout.tsx +0 -81
  100. package/templates/apps/web/app/[locale]/(auth)/legal-footnote.tsx +0 -35
  101. package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +0 -179
  102. package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +0 -157
  103. package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +0 -126
  104. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/next-path.test.ts +0 -54
  105. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +0 -628
  106. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +0 -43
  107. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +0 -266
  108. package/templates/apps/web/app/[locale]/(auth)/sign-in/next-path.ts +0 -20
  109. package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +0 -234
  110. package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +0 -37
  111. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +0 -323
  112. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +0 -93
  113. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/page.test.tsx +0 -301
  114. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +0 -309
  115. package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +0 -201
  116. package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +0 -366
  117. package/templates/apps/web/app/[locale]/(auth)/use-auth-card-flow.ts +0 -116
  118. package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +0 -94
  119. package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +0 -77
  120. package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +0 -154
  121. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/account-frame-sign-out.test.tsx +0 -175
  122. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
  123. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
  124. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
  125. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
  126. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
  127. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
  128. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
  129. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
  130. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
  131. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
  132. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
  133. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
  134. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
  135. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
  136. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
  137. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
  138. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
  139. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
  140. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
  141. package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
  142. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
  143. package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
  144. package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
  145. package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
  146. package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
  147. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -161
  148. package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
  149. package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
  150. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -139
  151. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -406
  152. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
  153. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
  154. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -190
  155. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
  156. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
  157. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
  158. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
  159. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
  160. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
  161. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -182
  162. package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
  163. package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
  164. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -424
  165. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
  166. package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
  167. package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
  168. package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
  169. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
  170. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
  171. package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
  172. package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
  173. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
  174. package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
  175. package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
  176. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -218
  177. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
  178. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
  179. package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
  180. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
  181. package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
  182. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -119
  183. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
  184. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -80
  185. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
  186. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -125
  187. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
  188. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
  189. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
  190. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
  191. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
  192. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
  193. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -154
  194. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -152
  195. package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
  196. package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
  197. package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
  198. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -143
  199. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
  200. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
  201. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -126
  202. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -306
  203. package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
  204. package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
  205. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -102
  206. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -240
  207. package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
  208. package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
  209. package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
  210. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -131
  211. package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
  212. package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
  213. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -24
  214. package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
  215. package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
  216. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -60
  217. package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
  218. package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
  219. package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
  220. package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
  221. package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
  222. package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
  223. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
  224. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
  225. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
  226. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
  227. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
  228. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
  229. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
  230. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
  231. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
  232. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
  233. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
  234. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
  235. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
  236. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
  237. package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
  238. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
  239. package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
  240. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
  241. package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
  242. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
  243. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
  244. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
  245. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
  246. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
  247. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
  248. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
  249. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
  250. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
  251. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
  252. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
  253. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
  254. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
  255. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
  256. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
  257. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
  258. package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
  259. package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
  260. package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
  261. package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
  262. package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
  263. package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
  264. package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
  265. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
  266. package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
  267. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
  268. package/templates/apps/web/app/api/auth/[...all]/route.ts +0 -16
  269. package/templates/apps/web/app/api/auth/hub/__tests__/continuation.test.ts +0 -143
  270. package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +0 -749
  271. package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +0 -964
  272. package/templates/apps/web/app/api/auth/hub/authorize/route.ts +0 -390
  273. package/templates/apps/web/app/api/auth/hub/continuation.ts +0 -127
  274. package/templates/apps/web/app/api/auth/hub/continue/[ref]/__tests__/route.test.ts +0 -188
  275. package/templates/apps/web/app/api/auth/hub/continue/[ref]/route.ts +0 -53
  276. package/templates/apps/web/app/api/auth/hub/email/route.ts +0 -111
  277. package/templates/apps/web/app/api/auth/hub/entry-shared.ts +0 -163
  278. package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +0 -86
  279. package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +0 -368
  280. package/templates/apps/web/app/api/auth/hub/password/return.ts +0 -86
  281. package/templates/apps/web/app/api/auth/hub/password/route.ts +0 -171
  282. package/templates/apps/web/app/api/auth/hub/purchase/route.ts +0 -230
  283. package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +0 -174
  284. package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +0 -60
  285. package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +0 -97
  286. package/templates/apps/web/app/api/auth/mcp/__tests__/continuation.test.ts +0 -92
  287. package/templates/apps/web/app/api/auth/mcp/continuation.ts +0 -89
  288. package/templates/apps/web/app/api/auth/mcp/continue/[ref]/__tests__/route.test.ts +0 -59
  289. package/templates/apps/web/app/api/auth/mcp/continue/[ref]/route.ts +0 -41
  290. package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +0 -1166
  291. package/templates/apps/web/app/api/hub-session/callback/route.ts +0 -134
  292. package/templates/apps/web/app/api/hub-session/email/route.ts +0 -125
  293. package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +0 -49
  294. package/templates/apps/web/app/api/hub-session/one-tap/route.ts +0 -106
  295. package/templates/apps/web/app/api/hub-session/open/route.ts +0 -111
  296. package/templates/apps/web/app/api/hub-session/password/return/route.ts +0 -69
  297. package/templates/apps/web/app/api/hub-session/password/route.ts +0 -106
  298. package/templates/apps/web/app/api/hub-session/sign-in/route.ts +0 -91
  299. package/templates/apps/web/app/api/hub-session/sign-out/route.ts +0 -54
  300. package/templates/apps/web/components/sign-out-trigger.tsx +0 -62
  301. package/templates/apps/web/lib/__tests__/account-config.test.ts +0 -704
  302. package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
  303. package/templates/apps/web/lib/account-config.ts +0 -678
  304. package/templates/apps/web/lib/auth-routes.ts +0 -125
  305. package/templates/apps/web/lib/checkout-config.ts +0 -16
  306. package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +0 -433
  307. package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +0 -332
  308. package/templates/apps/web/lib/hub-session/config.ts +0 -110
  309. package/templates/apps/web/lib/hub-session/entry.ts +0 -238
  310. package/templates/apps/web/lib/hub-session/index.ts +0 -21
  311. package/templates/apps/web/lib/hub-session/one-tap.tsx +0 -148
  312. package/templates/apps/web/lib/hub-session/reseal.ts +0 -90
  313. package/templates/apps/web/lib/hub-session/seal.ts +0 -86
  314. package/templates/apps/web/lib/hub-session/session.ts +0 -298
  315. package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +0 -277
  316. package/templates/apps/web/lib/next-path.ts +0 -35
  317. package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
  318. package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
@@ -1,730 +0,0 @@
1
- /**
2
- * Tests for the account layout — the base area's SignedInShell frame
3
- * (#7430, spec 7423 U4 · D13; the U4 half of AC-17; #8231 D1).
4
- *
5
- * Covers:
6
- * 1. The rail: the site logo as the top tile (a link home), then Inbox and
7
- * a Library group holding Artifacts and Appointments (#11154) — each selected on its own paths,
8
- * no row on a Settings page — and a footer of the avatar and ? only.
9
- * No Settings row (#8334: Settings lives in the avatar menu, as on the
10
- * Admin).
11
- * 2. The avatar opens the card menu (name, then Settings and Log out side
12
- * by side); Settings is the one route to /account/general; Log out
13
- * signs out and routes home.
14
- * 3. ? opens Contact support (→ /account/support) and, only when the site
15
- * configures a help URL, Help center.
16
- * 4. Below md the tab bar reads avatar · Inbox · For you · Help, with no
17
- * count on any tab (#7469, DESIGN.md §2b as amended 2026-10-01); For
18
- * you is `?tab=for-you` of the Inbox route, and the frame hands the
19
- * tab to the page (PhoneTabProvider).
20
- * 5. The For-you items are the aside; none → no aside.
21
- * 6. No site chrome (Nav, Footer, ThemeToggle) inside the frame.
22
- * 7. The four Settings pages render alone, inside the shell marker only —
23
- * no rail, no Inbox, no AppShell frame (#8430): the page draws its own
24
- * standalone settings frame, as the Admin's does. Membership is an
25
- * exact, locale-aware match on settings-frame.tsx's `SETTINGS_ROUTES`
26
- * (#8441): a sub-route of a settings path stays inside the shell.
27
- * 8. One main landmark (#8441): every settings route and the Inbox, each
28
- * rendered through this layout with its real page, draw exactly one.
29
- * 9. The agreements interstitial (#8765 D7, AC-2, AC-3, AC-4): the layout
30
- * reads `consent.accountAgreements`; `complete: false` renders the
31
- * interstitial in place of the frame and the page; a read that fails
32
- * (anything but a 2xx or a 404) fails closed to the registry's own
33
- * agreements; an older hub's 404 renders the account as before.
34
- */
35
- import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
36
- import type { ReactElement, ReactNode } from "react";
37
-
38
- jest.mock("next-intl/server", () => {
39
- const msgs: unknown = require("../../../../../messages/en.json");
40
- const dig = (obj: unknown, path: string): unknown =>
41
- path.split(".").reduce<unknown>(
42
- (acc, k) => (acc !== null && typeof acc === "object" ? (acc as Record<string, unknown>)[k] : undefined),
43
- obj,
44
- );
45
- return {
46
- __esModule: true,
47
- getTranslations: async (arg: string | { namespace?: string; locale?: string }) => {
48
- const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
49
- const messages = dig(msgs, ns);
50
- const t = (key: string, values?: Record<string, unknown>): string => {
51
- const value = dig(messages, key);
52
- if (typeof value !== "string") return `${ns}.${key}`;
53
- return value.replace(/\{(\w+)\}/g, (m, name: string) =>
54
- values && name in values ? String(values[name]) : m,
55
- );
56
- };
57
- // #11164: the one-main-landmark cases render the real Privacy page,
58
- // whose lead is a `t.rich` message with a `<policy>` tag.
59
- const { withRich } = require("./rich-translator") as typeof import("./rich-translator");
60
- return withRich(t, (key: string) => dig(messages, key), ns);
61
- },
62
- };
63
- });
64
-
65
- jest.mock("next/headers", () => ({
66
- __esModule: true,
67
- headers: jest.fn().mockResolvedValue(new Headers()),
68
- cookies: jest.fn().mockResolvedValue({ toString: () => "session=abc" }),
69
- }));
70
-
71
- const mockGetSession = jest.fn();
72
- // 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.
73
- jest.mock("../../../../../auth", () => ({
74
- __esModule: true,
75
- auth: { api: { getSession: (...args: unknown[]) => mockGetSession(...args) } },
76
- }));
77
-
78
- const mockSubscriptionMe = jest.fn();
79
- // #8231 D7 — the member reads call on every topology; here every one 404s.
80
- const mockMemberNotFound = jest.fn();
81
- jest.mock("@working-theory/api-client", () => ({
82
- __esModule: true,
83
- waitlistSignups: { me: jest.fn() },
84
- flowCheckouts: { me: jest.fn() },
85
- subscription: { me: (...args: unknown[]) => mockSubscriptionMe(...args), portalSession: jest.fn() },
86
- leads: { submit: jest.fn() },
87
- member: {
88
- pieces: (...args: unknown[]) => mockMemberNotFound(...args),
89
- messages: (...args: unknown[]) => mockMemberNotFound(...args),
90
- purchases: (...args: unknown[]) => mockMemberNotFound(...args),
91
- appointments: (...args: unknown[]) => mockMemberNotFound(...args),
92
- // #8441 — the Inbox page's New-menu availability reads, for § one main landmark.
93
- meetingTypes: (...args: unknown[]) => mockMemberNotFound(...args),
94
- requestForm: (...args: unknown[]) => mockMemberNotFound(...args),
95
- // #11150 — the onboarding-steps read.
96
- welcome: (...args: unknown[]) => mockMemberNotFound(...args),
97
- },
98
- hubSignIn: { me: jest.fn() },
99
- // #8765 D7 — the interstitial's read; `complete: true` unless a case says otherwise.
100
- consent: { accountAgreements: (...args: unknown[]) => mockAccountAgreements(...args) },
101
- visitorForwardHeaders: () => null,
102
- }));
103
-
104
- const mockAccountAgreements = jest.fn();
105
- const mockAcceptAction = jest.fn();
106
- // eslint-disable-next-line no-restricted-syntax -- test-seam mock: the Server Action module is a "use server" boundary; the interstitial only passes it through.
107
- jest.mock("../agreements-actions", () => ({
108
- __esModule: true,
109
- acceptAccountAgreementsAction: (...args: unknown[]) => mockAcceptAction(...args),
110
- }));
111
-
112
- const mockSignOut = jest.fn();
113
- jest.mock("better-auth/react", () => ({
114
- __esModule: true,
115
- createAuthClient: () => ({ signOut: (...args: unknown[]) => mockSignOut(...args) }),
116
- }));
117
-
118
- const mockPush = jest.fn();
119
- const mockRefresh = jest.fn();
120
- let mockPathname = "/account";
121
- let mockSearch = "";
122
- jest.mock("next/navigation", () => ({
123
- __esModule: true,
124
- useRouter: () => ({ push: mockPush, refresh: mockRefresh, replace: jest.fn() }),
125
- redirect: jest.fn(),
126
- usePathname: () => mockPathname,
127
- useSearchParams: () => new URLSearchParams(mockSearch),
128
- }));
129
-
130
- import { usePhoneTab } from "@working-theory/templates/account";
131
- import { consentStatementText } from "@working-theory/ui/blocks";
132
- import { ACCOUNT_TERMS_STATEMENT } from "@working-theory/validation";
133
-
134
- import AccountLayout from "../layout";
135
- import InboxPage from "../page";
136
- import { SETTINGS_ROUTES, type SettingsTabKey } from "../settings-frame";
137
-
138
- /** A page that shows the phone tab the frame hands it. */
139
- function PhoneTabProbe(): ReactElement {
140
- return <p data-testid="phone-tab-probe">{usePhoneTab()}</p>;
141
- }
142
-
143
- const SESSION = {
144
- user: {
145
- id: "user_1",
146
- name: "Ada Lovelace",
147
- email: "ada@example.com",
148
- emailVerified: true,
149
- createdAt: new Date("2026-09-01T00:00:00.000Z"),
150
- },
151
- };
152
-
153
- /** One `account_terms` entry of `GET /v1/consent/account` (#8765 D5). */
154
- function agreementsAnswer(entry: { acceptedVersion: number | null; current: boolean }) {
155
- return {
156
- ok: true,
157
- body: {
158
- agreements: [
159
- {
160
- id: "account_terms",
161
- statement: ACCOUNT_TERMS_STATEMENT,
162
- policyVersion: 2,
163
- acceptedVersion: entry.acceptedVersion,
164
- acceptedAt: entry.acceptedVersion === null ? null : "2026-09-01T00:00:00.000Z",
165
- current: entry.current,
166
- },
167
- ],
168
- complete: entry.current,
169
- },
170
- };
171
- }
172
- const COMPLETE = agreementsAnswer({ acceptedVersion: 2, current: true });
173
-
174
- const NO_SUBSCRIPTION = {
175
- ok: true,
176
- body: { actionRequired: false, status: null, accessRevokesAt: null, portalAvailable: false },
177
- };
178
-
179
- // Pointer, not keyboard: Radix menus open on pointerdown. jsdom has no
180
- // PointerEvent; a MouseEvent stands in (the packages/ui jest-setup idiom).
181
- beforeAll(() => {
182
- if (typeof globalThis.PointerEvent === "undefined") {
183
- // eslint-disable-next-line no-restricted-syntax -- a MouseEvent stands in for jsdom's missing PointerEvent
184
- globalThis.PointerEvent = MouseEvent as unknown as typeof PointerEvent;
185
- }
186
- });
187
-
188
- function openByPointer(trigger: HTMLElement): void {
189
- fireEvent.pointerDown(trigger, { button: 0, ctrlKey: false, pointerType: "mouse" });
190
- }
191
-
192
- async function renderLayout(
193
- locale = "en",
194
- children: ReactNode = (
195
- <>
196
- <p data-testid="account-child">page</p>
197
- <PhoneTabProbe />
198
- </>
199
- ),
200
- ): Promise<void> {
201
- const element = await AccountLayout({ children, params: Promise.resolve({ locale }) });
202
- render(element);
203
- }
204
-
205
- const ORIGINAL_HELP_URL = process.env.AILK_HELP_CENTER_URL;
206
-
207
- beforeEach(() => {
208
- window.localStorage.clear();
209
- mockPathname = "/account";
210
- mockSearch = "";
211
- delete process.env.AILK_HELP_CENTER_URL;
212
- mockGetSession.mockReset().mockResolvedValue(SESSION);
213
- mockSubscriptionMe.mockReset().mockResolvedValue(NO_SUBSCRIPTION);
214
- mockMemberNotFound.mockReset().mockResolvedValue({ ok: false, status: 404, body: null });
215
- mockSignOut.mockReset().mockResolvedValue({ data: {}, error: null });
216
- mockAccountAgreements.mockReset().mockResolvedValue(COMPLETE);
217
- mockAcceptAction.mockReset();
218
- mockPush.mockReset();
219
- mockRefresh.mockReset();
220
- });
221
-
222
- afterAll(() => {
223
- if (ORIGINAL_HELP_URL === undefined) delete process.env.AILK_HELP_CENTER_URL;
224
- else process.env.AILK_HELP_CENTER_URL = ORIGINAL_HELP_URL;
225
- });
226
-
227
- describe("the account rail (D13, AC-17)", () => {
228
- it("the top tile is the site logo — a link to the site home", async () => {
229
- await renderLayout();
230
- const rail = screen.getByTestId("sidebar-desktop");
231
- const home = within(rail).getByTestId("account-site-logo");
232
- expect(home).toHaveAttribute("href", "/");
233
- expect(home).toHaveAccessibleName("Home");
234
- expect(within(home).getByRole("img")).toBeInTheDocument();
235
- });
236
-
237
- it("a non-default locale's logo links to that locale's home", async () => {
238
- await renderLayout("fr");
239
- const rail = screen.getByTestId("sidebar-desktop");
240
- expect(within(rail).getByTestId("account-site-logo")).toHaveAttribute("href", "/fr/");
241
- });
242
-
243
- /** The rail's rows, in DOM order — every link but the logo. */
244
- function railRows(): HTMLElement[] {
245
- return within(screen.getByTestId("sidebar-desktop"))
246
- .getAllByRole("link")
247
- .filter((link) => link.getAttribute("data-testid") !== "account-site-logo");
248
- }
249
-
250
- it("the rows are Inbox, then Artifacts and Appointments under Library — no Settings row (#8231 D1, #8334, #11154)", async () => {
251
- await renderLayout();
252
- const rows = railRows();
253
- expect(rows.map((row) => [row.textContent, row.getAttribute("href")])).toEqual([
254
- ["Inbox", "/account"],
255
- ["Artifacts", "/account/artifacts"],
256
- ["Appointments", "/account/appointments"],
257
- ]);
258
- expect(rows[0]).toHaveAttribute("aria-current", "page");
259
- // Artifacts and Appointments sit in the Library group.
260
- const heading = screen.getByTestId("sidebar-group-heading-library");
261
- expect(heading).toHaveTextContent("Library");
262
- const library = heading.parentElement as HTMLElement;
263
- expect(within(library).getByText("Artifacts")).toBeInTheDocument();
264
- expect(within(library).getByText("Appointments")).toBeInTheDocument();
265
- // #8334 — Settings is nowhere in the rail, at any viewport: not a row, not
266
- // a tab. The avatar menu is its one route (the next describe).
267
- expect(within(screen.getByTestId("sidebar-desktop")).queryByText("Settings")).not.toBeInTheDocument();
268
- expect(within(screen.getByTestId("bottom-tab-bar")).queryByText("Settings")).not.toBeInTheDocument();
269
- });
270
-
271
- it.each([
272
- ["/account", "Inbox"],
273
- ["/account/inbox/purchase/x", "Inbox"],
274
- ["/account/artifacts", "Artifacts"],
275
- ["/account/artifacts/p1", "Artifacts"],
276
- ["/account/appointments", "Appointments"],
277
- ["/account/appointments/intro", "Appointments"],
278
- ])("on %s only %s is selected (#8231 D1, #11154)", async (path, selected) => {
279
- mockPathname = path;
280
- await renderLayout();
281
- const current = railRows().filter((row) => row.getAttribute("aria-current") === "page");
282
- expect(current.map((row) => row.textContent)).toEqual([selected]);
283
- });
284
-
285
- it.each([
286
- "/account/support",
287
- // #8334 — the old Settings path (it redirects to General) selects no
288
- // row: Settings has no rail row to select. The four Settings pages render
289
- // no rail at all (#8430, § the settings routes below).
290
- "/account/settings",
291
- "/fr/account/support",
292
- ])("no row is selected on %s (#8231 D1, #8334)", async (path) => {
293
- mockPathname = path;
294
- await renderLayout(path.startsWith("/fr/") ? "fr" : "en");
295
- const rows = railRows();
296
- expect(rows).toHaveLength(3);
297
- expect(rows.some((row) => row.hasAttribute("aria-current"))).toBe(false);
298
- });
299
-
300
- it("a non-default locale prefixes every row (#8231 D1)", async () => {
301
- mockPathname = "/fr/account/artifacts";
302
- await renderLayout("fr");
303
- const rows = railRows();
304
- expect(rows.map((row) => row.getAttribute("href"))).toEqual([
305
- "/fr/account",
306
- "/fr/account/artifacts",
307
- "/fr/account/appointments",
308
- ]);
309
- expect(rows[1]).toHaveAttribute("aria-current", "page");
310
- });
311
-
312
- it("an Inbox item page keeps Inbox selected", async () => {
313
- mockPathname = "/account/inbox/purchase/fc_1";
314
- await renderLayout();
315
- const rail = screen.getByTestId("sidebar-desktop");
316
- expect(within(rail).getByText("Inbox").closest("a")).toHaveAttribute("aria-current", "page");
317
- });
318
-
319
- it("the footer is the avatar and ? only — no name beside the avatar", async () => {
320
- await renderLayout();
321
- const footer = screen.getByTestId("signed-in-shell-rail-footer");
322
- expect(within(footer).getAllByRole("button")).toHaveLength(2);
323
- expect(screen.getByTestId("sidebar-nav-user-trigger")).not.toHaveTextContent("Ada Lovelace");
324
- expect(within(footer).getByTestId("signed-in-shell-help-trigger")).toHaveAccessibleName("Help");
325
- });
326
-
327
- it("the page renders inside the frame, with no site chrome", async () => {
328
- await renderLayout();
329
- expect(screen.getByTestId("account-child")).toBeInTheDocument();
330
- expect(document.querySelector('nav[aria-label="Primary"]')).not.toBeInTheDocument();
331
- expect(document.querySelector(".ailk-footer")).not.toBeInTheDocument();
332
- expect(screen.queryByTestId("theme-toggle")).not.toBeInTheDocument();
333
- });
334
- });
335
-
336
- describe("the avatar menu (D13)", () => {
337
- it("opens the card menu: the name, then Settings and Log out side by side", async () => {
338
- await renderLayout();
339
- openByPointer(screen.getByTestId("sidebar-nav-user-trigger"));
340
- const menu = screen.getByTestId("account-menu-content");
341
- expect(menu).toHaveAttribute("data-layout", "card");
342
- expect(within(menu).getByTestId("account-menu-user")).toHaveTextContent("Ada Lovelace");
343
- // The base area knows no plan, so the plan line is absent.
344
- expect(within(menu).queryByTestId("account-menu-plan")).not.toBeInTheDocument();
345
- const actions = within(menu).getByTestId("account-menu-actions");
346
- expect(within(actions).getByText("Settings").closest("a")).toHaveAttribute(
347
- "href",
348
- "/account/general",
349
- );
350
- expect(within(actions).getByTestId("account-menu-sign-out")).toHaveTextContent("Log out");
351
- });
352
-
353
- it("Settings in the menu is the one route to General, locale-prefixed (#8334)", async () => {
354
- mockPathname = "/fr/account";
355
- await renderLayout("fr");
356
- openByPointer(screen.getByTestId("sidebar-nav-user-trigger"));
357
- const actions = within(screen.getByTestId("account-menu-content")).getByTestId(
358
- "account-menu-actions",
359
- );
360
- expect(within(actions).getByText("Settings").closest("a")).toHaveAttribute(
361
- "href",
362
- "/fr/account/general",
363
- );
364
- // The rail offers no second Settings link.
365
- expect(
366
- within(screen.getByTestId("sidebar-desktop")).queryByRole("link", { name: "Settings" }),
367
- ).not.toBeInTheDocument();
368
- });
369
-
370
- it("Log out signs out, then routes home and refreshes", async () => {
371
- await renderLayout();
372
- openByPointer(screen.getByTestId("sidebar-nav-user-trigger"));
373
- fireEvent.click(screen.getByTestId("account-menu-sign-out"));
374
- await waitFor(() => expect(mockPush).toHaveBeenCalledWith("/"));
375
- expect(mockSignOut).toHaveBeenCalledTimes(1);
376
- expect(mockRefresh).toHaveBeenCalledTimes(1);
377
- });
378
-
379
- it("a member with no name is shown by their email", async () => {
380
- mockGetSession.mockResolvedValue({ user: { ...SESSION.user, name: "" } });
381
- await renderLayout();
382
- openByPointer(screen.getByTestId("sidebar-nav-user-trigger"));
383
- expect(screen.getByTestId("account-menu-user")).toHaveTextContent("ada@example.com");
384
- });
385
- });
386
-
387
- describe("the help menu (D13)", () => {
388
- it("? opens Contact support alone when the site configures no help URL", async () => {
389
- await renderLayout();
390
- openByPointer(screen.getByTestId("signed-in-shell-help-trigger"));
391
- const menu = screen.getByTestId("signed-in-shell-help-menu");
392
- expect(within(menu).getAllByRole("link")).toHaveLength(1);
393
- expect(within(menu).getByText("Contact support").closest("a")).toHaveAttribute(
394
- "href",
395
- "/account/support",
396
- );
397
- });
398
-
399
- it("with a help URL configured, Help center follows Contact support", async () => {
400
- process.env.AILK_HELP_CENTER_URL = "https://help.example.com";
401
- await renderLayout();
402
- openByPointer(screen.getByTestId("signed-in-shell-help-trigger"));
403
- const menu = screen.getByTestId("signed-in-shell-help-menu");
404
- const links = within(menu).getAllByRole("link");
405
- expect(links.map((link) => link.textContent)).toEqual(["Contact support", "Help center"]);
406
- expect(links[1]).toHaveAttribute("href", "https://help.example.com");
407
- });
408
- });
409
-
410
- describe("the phone frame (D13; #7469 — the For you tab)", () => {
411
- it("the tab bar reads avatar · Inbox · For you · Help, and Help opens the same menu", async () => {
412
- await renderLayout();
413
- const bar = screen.getByTestId("bottom-tab-bar");
414
- const cells = Array.from(bar.children);
415
- expect(cells).toHaveLength(4);
416
- expect(cells[0]).toBe(screen.getByTestId("bottom-tab-bar-leading"));
417
- expect(cells[1]).toHaveTextContent("Inbox");
418
- expect(cells[1]).toHaveAttribute("href", "/account");
419
- expect(cells[1]).toHaveAttribute("aria-current", "page");
420
- expect(cells[2]).toHaveTextContent("For you");
421
- expect(cells[2]).toHaveAttribute("href", "/account?tab=for-you");
422
- expect(cells[2]).not.toHaveAttribute("aria-current");
423
- expect(cells[3]).toBe(screen.getByTestId("bottom-tab-bar-trailing"));
424
- openByPointer(screen.getByTestId("frame-bottom-bar-help"));
425
- expect(
426
- within(screen.getByTestId("signed-in-shell-help-menu")).getByText("Contact support"),
427
- ).toBeInTheDocument();
428
- });
429
-
430
- it("no tab carries a count, even with For-you items waiting", async () => {
431
- mockGetSession.mockResolvedValue({
432
- user: { ...SESSION.user, name: null, emailVerified: false },
433
- });
434
- await renderLayout();
435
- const bar = screen.getByTestId("bottom-tab-bar");
436
- const tabs = within(bar).getAllByRole("link");
437
- expect(tabs.map((tab) => tab.textContent)).toEqual(["Inbox", "For you"]);
438
- });
439
-
440
- it("a non-default locale prefixes both tabs", async () => {
441
- mockPathname = "/fr/account";
442
- await renderLayout("fr");
443
- const tabs = within(screen.getByTestId("bottom-tab-bar")).getAllByRole("link");
444
- expect(tabs.map((tab) => tab.getAttribute("href"))).toEqual([
445
- "/fr/account",
446
- "/fr/account?tab=for-you",
447
- ]);
448
- });
449
-
450
- it("on ?tab=for-you, For you is selected, Inbox is not, and the page is handed the tab", async () => {
451
- mockSearch = "tab=for-you";
452
- await renderLayout();
453
- const [inbox, forYou] = within(screen.getByTestId("bottom-tab-bar")).getAllByRole("link");
454
- expect(forYou).toHaveAttribute("aria-current", "page");
455
- expect(inbox).not.toHaveAttribute("aria-current");
456
- expect(screen.getByTestId("phone-tab-probe")).toHaveTextContent("for-you");
457
- });
458
-
459
- it("on the Inbox the page is handed the inbox tab", async () => {
460
- await renderLayout();
461
- expect(screen.getByTestId("phone-tab-probe")).toHaveTextContent("inbox");
462
- });
463
-
464
- it("an unknown ?tab= is the Inbox", async () => {
465
- mockSearch = "tab=library";
466
- await renderLayout();
467
- const [inbox] = within(screen.getByTestId("bottom-tab-bar")).getAllByRole("link");
468
- expect(inbox).toHaveAttribute("aria-current", "page");
469
- expect(screen.getByTestId("phone-tab-probe")).toHaveTextContent("inbox");
470
- });
471
-
472
- it("an Inbox item page keeps the Inbox tab selected, whatever ?tab= says", async () => {
473
- mockPathname = "/account/inbox/purchase/fc_1";
474
- mockSearch = "tab=for-you";
475
- await renderLayout();
476
- const [inbox, forYou] = within(screen.getByTestId("bottom-tab-bar")).getAllByRole("link");
477
- expect(inbox).toHaveAttribute("aria-current", "page");
478
- expect(forYou).not.toHaveAttribute("aria-current");
479
- expect(screen.getByTestId("phone-tab-probe")).toHaveTextContent("inbox");
480
- });
481
-
482
- it("the phone top bar carries the site logo, linking home", async () => {
483
- await renderLayout();
484
- const logos = screen.getAllByTestId("account-site-logo");
485
- // One in the rail, one in the phone top bar.
486
- expect(logos).toHaveLength(2);
487
- for (const logo of logos) expect(logo).toHaveAttribute("href", "/");
488
- });
489
- });
490
-
491
- describe("the For-you aside (D3, D8a)", () => {
492
- it("no items → no aside", async () => {
493
- await renderLayout();
494
- expect(screen.queryByTestId("app-shell-aside")).not.toBeInTheDocument();
495
- });
496
-
497
- it("items → the For-you panel is the aside", async () => {
498
- mockGetSession.mockResolvedValue({ user: { ...SESSION.user, emailVerified: false } });
499
- await renderLayout();
500
- const panel = screen.getByTestId("app-shell-aside");
501
- expect(within(panel).getByText("Email not verified")).toBeInTheDocument();
502
- });
503
-
504
- it("a member with no name sees 'Add your name' in the aside", async () => {
505
- mockGetSession.mockResolvedValue({ user: { ...SESSION.user, name: null } });
506
- await renderLayout();
507
- const panel = screen.getByTestId("app-shell-aside");
508
- expect(within(panel).getByText("Add your name")).toBeInTheDocument();
509
- });
510
- });
511
-
512
- describe("no session", () => {
513
- it("renders the page alone — the (authed) layout owns the gate", async () => {
514
- mockGetSession.mockResolvedValue(null);
515
- await renderLayout();
516
- expect(screen.getByTestId("account-child")).toBeInTheDocument();
517
- expect(screen.queryByTestId("sidebar-desktop")).not.toBeInTheDocument();
518
- });
519
- });
520
-
521
- describe("the settings routes take the screen (#8430)", () => {
522
- it.each([
523
- ["/account/general", "en"],
524
- ["/account/security", "en"],
525
- ["/account/notifications", "en"],
526
- ["/account/privacy", "en"],
527
- ["/account/billing", "en"],
528
- ["/fr/account/billing", "fr"],
529
- ])("on %s the page renders alone — no rail, no Inbox, no AppShell frame", async (path, locale) => {
530
- mockPathname = path;
531
- await renderLayout(locale);
532
- expect(screen.getByTestId("account-child")).toBeInTheDocument();
533
- expect(screen.queryByTestId("dashboard-shell")).not.toBeInTheDocument();
534
- expect(screen.queryByTestId("sidebar-desktop")).not.toBeInTheDocument();
535
- expect(screen.queryByTestId("app-shell-aside")).not.toBeInTheDocument();
536
- expect(screen.queryByRole("link", { name: "Inbox" })).not.toBeInTheDocument();
537
- expect(screen.queryByRole("link", { name: "Artifacts" })).not.toBeInTheDocument();
538
- });
539
-
540
- it("keeps the shell marker around the page, so the Admin's tokens still apply (#8337 D4)", async () => {
541
- mockPathname = "/account/general";
542
- await renderLayout();
543
- const markers = document.querySelectorAll("[data-ailk-shell]");
544
- expect(markers).toHaveLength(1);
545
- const marker = markers[0] as HTMLElement;
546
- expect(marker.getAttribute("data-ailk-shell")).toBe("account");
547
- expect(Array.from(marker.classList)).toEqual(["contents"]);
548
- expect(within(marker).getByTestId("account-child")).toBeInTheDocument();
549
- });
550
-
551
- it.each([
552
- "/account",
553
- "/account/artifacts",
554
- "/account/support",
555
- "/account/inbox/purchase/fc_1",
556
- // #8441 — the match is exact: a sub-route of a settings path is not listed,
557
- // so it stays inside the shell.
558
- "/account/billing/history",
559
- "/account/general/",
560
- "/fr/account/security/sessions",
561
- ])(
562
- "%s still renders inside the frame",
563
- async (path) => {
564
- mockPathname = path;
565
- await renderLayout(path.startsWith("/fr/") ? "fr" : "en");
566
- expect(screen.getByTestId("dashboard-shell")).toBeInTheDocument();
567
- expect(within(screen.getByTestId("sidebar-desktop")).getByRole("link", { name: "Inbox" })).toBeInTheDocument();
568
- },
569
- );
570
- });
571
-
572
- describe("one main landmark (#8441)", () => {
573
- type Page = (props: { params: Promise<{ locale: string }> }) => Promise<ReactElement | null>;
574
- // Keyed by the list's own type, so a tab added to `SETTINGS_ROUTES` without
575
- // its page here fails to compile. Billing loads with `import()`:
576
- // architecture.yaml bans a static import of a relative billing/ path
577
- // (billing.test.tsx).
578
- const PAGES: Record<SettingsTabKey, () => Promise<Page>> = {
579
- general: async () => (await import("../general/page")).default,
580
- security: async () => (await import("../security/page")).default,
581
- notifications: async () => (await import("../notifications/page")).default,
582
- privacy: async () => (await import("../privacy/page")).default,
583
- billing: async () => (await import("../billing/page")).default,
584
- };
585
-
586
- async function renderRoute(path: string, locale: string, page: Page): Promise<void> {
587
- mockPathname = path;
588
- await renderLayout(locale, await page({ params: Promise.resolve({ locale }) }));
589
- }
590
-
591
- it.each(SETTINGS_ROUTES.flatMap(({ key, path }) => [
592
- [path, "en", key] as const,
593
- [`/fr${path}`, "fr", key] as const,
594
- ]))("%s draws exactly one <main>", async (path, locale, key) => {
595
- await renderRoute(path, locale, await PAGES[key]());
596
- expect(screen.getAllByRole("main")).toHaveLength(1);
597
- expect(document.querySelectorAll("main")).toHaveLength(1);
598
- });
599
-
600
- it.each([
601
- ["/account", "en"],
602
- ["/fr/account", "fr"],
603
- ])("the Inbox, %s, draws exactly one <main>", async (path, locale) => {
604
- await renderRoute(path, locale, InboxPage);
605
- expect(screen.getByTestId("dashboard-shell")).toBeInTheDocument();
606
- expect(screen.getAllByRole("main")).toHaveLength(1);
607
- expect(document.querySelectorAll("main")).toHaveLength(1);
608
- });
609
- });
610
-
611
- describe("the shell marker (#8337 D4, AC-6)", () => {
612
- it("with a session, exactly one [data-ailk-shell=\"account\"] wraps the shell", async () => {
613
- await renderLayout();
614
- const markers = document.querySelectorAll("[data-ailk-shell]");
615
- expect(markers).toHaveLength(1);
616
- const marker = markers[0] as HTMLElement;
617
- expect(marker.getAttribute("data-ailk-shell")).toBe("account");
618
- expect(marker.getAttribute("data-testid")).toBe("account-shell");
619
- expect(Array.from(marker.classList)).toEqual(["contents"]);
620
- expect(within(marker).getByTestId("dashboard-shell")).toBeInTheDocument();
621
- });
622
-
623
- it("with no session, no [data-ailk-shell] exists", async () => {
624
- mockGetSession.mockResolvedValue(null);
625
- await renderLayout();
626
- expect(document.querySelector("[data-ailk-shell]")).not.toBeInTheDocument();
627
- });
628
- });
629
-
630
- describe("the agreements interstitial (#8765 D7)", () => {
631
- const PAGE_REFUSAL = (status: number) => ({
632
- ok: false,
633
- status,
634
- body: { ok: false, error: { code: "x", message: "x" } },
635
- });
636
-
637
- function expectInterstitialAlone(title: string): void {
638
- const page = screen.getByTestId("account-agreements-interstitial");
639
- expect(within(page).getByRole("heading", { level: 1 })).toHaveTextContent(title);
640
- expect(screen.queryByTestId("account-shell")).not.toBeInTheDocument();
641
- expect(screen.queryByTestId("dashboard-shell")).not.toBeInTheDocument();
642
- expect(screen.queryByTestId("account-child")).not.toBeInTheDocument();
643
- expect(screen.queryByTestId("app-shell-aside")).not.toBeInTheDocument();
644
- }
645
-
646
- it("reads the account-level agreements with the session's own init and locale", async () => {
647
- await renderLayout("fr");
648
- expect(mockAccountAgreements).toHaveBeenCalledWith(
649
- { headers: { cookie: "session=abc" } },
650
- { locale: "fr" },
651
- );
652
- });
653
-
654
- it("complete: true → the frame and its children, and no interstitial (AC-3)", async () => {
655
- await renderLayout();
656
- expect(screen.getByTestId("account-shell")).toBeInTheDocument();
657
- expect(screen.getByTestId("account-child")).toBeInTheDocument();
658
- expect(screen.queryByTestId("account-agreements-interstitial")).not.toBeInTheDocument();
659
- });
660
-
661
- it("complete: false → the interstitial in place of the frame and the page (AC-2)", async () => {
662
- mockAccountAgreements.mockResolvedValue(agreementsAnswer({ acceptedVersion: null, current: false }));
663
- await renderLayout();
664
- expectInterstitialAlone("Please accept our terms");
665
- });
666
-
667
- it("Accept calls the action once with every id, then refreshes (AC-2)", async () => {
668
- mockAccountAgreements.mockResolvedValue(agreementsAnswer({ acceptedVersion: null, current: false }));
669
- mockAcceptAction.mockResolvedValue({ ok: true });
670
- await renderLayout();
671
- fireEvent.click(screen.getByTestId("account-agreements-accept"));
672
- await waitFor(() => expect(mockRefresh).toHaveBeenCalledTimes(1));
673
- expect(mockAcceptAction).toHaveBeenCalledTimes(1);
674
- expect(mockAcceptAction).toHaveBeenCalledWith(["account_terms"]);
675
- });
676
-
677
- it("an older accepted version → 'We've updated our terms' (AC-4)", async () => {
678
- mockAccountAgreements.mockResolvedValue(agreementsAnswer({ acceptedVersion: 1, current: false }));
679
- await renderLayout();
680
- expectInterstitialAlone("We've updated our terms");
681
- });
682
-
683
- it("gates the settings routes too — no account page loads behind it", async () => {
684
- mockPathname = "/account/general";
685
- mockAccountAgreements.mockResolvedValue(agreementsAnswer({ acceptedVersion: null, current: false }));
686
- await renderLayout();
687
- expectInterstitialAlone("Please accept our terms");
688
- });
689
-
690
- describe("fails closed (SEC-8765-C)", () => {
691
- let errorSpy: jest.SpyInstance;
692
- beforeEach(() => {
693
- errorSpy = jest.spyOn(console, "error").mockImplementation(() => undefined);
694
- });
695
- afterEach(() => errorSpy.mockRestore());
696
-
697
- it.each([
698
- ["a 503", () => mockAccountAgreements.mockResolvedValue(PAGE_REFUSAL(503))],
699
- ["a 429", () => mockAccountAgreements.mockResolvedValue(PAGE_REFUSAL(429))],
700
- ["a 401", () => mockAccountAgreements.mockResolvedValue(PAGE_REFUSAL(401))],
701
- ["a 403", () => mockAccountAgreements.mockResolvedValue(PAGE_REFUSAL(403))],
702
- ["a thrown read", () => mockAccountAgreements.mockRejectedValue(new Error("down"))],
703
- ])("%s → the interstitial from the registry, with no account behind it", async (_label, arrange) => {
704
- arrange();
705
- await renderLayout();
706
- expectInterstitialAlone("Please accept our terms");
707
- const statement = screen.getByTestId("account-agreements-statement-account_terms");
708
- expect(statement.textContent).toBe(consentStatementText(ACCOUNT_TERMS_STATEMENT));
709
- expect(errorSpy).toHaveBeenCalledWith(
710
- expect.any(String),
711
- { event: "account-agreements", outcome: "read_failed" },
712
- );
713
- });
714
-
715
- it("an older hub's 404 → the account as today, and no log line", async () => {
716
- mockAccountAgreements.mockResolvedValue(PAGE_REFUSAL(404));
717
- await renderLayout();
718
- expect(screen.getByTestId("account-shell")).toBeInTheDocument();
719
- expect(screen.getByTestId("account-child")).toBeInTheDocument();
720
- expect(screen.queryByTestId("account-agreements-interstitial")).not.toBeInTheDocument();
721
- expect(errorSpy).not.toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ event: "account-agreements" }));
722
- });
723
- });
724
-
725
- it("with no session there is no read", async () => {
726
- mockGetSession.mockResolvedValue(null);
727
- await renderLayout();
728
- expect(mockAccountAgreements).not.toHaveBeenCalled();
729
- });
730
- });