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,883 +0,0 @@
1
- /**
2
- * Tests for /[locale]/account/general — User settings › General (#8339
3
- * D8; builds on #8232 D1-D8; AC-1, AC-3, AC-4, AC-6).
4
- *
5
- * General now renders through the shared `AccountSettings` composition
6
- * (@working-theory/templates/account, spec 8339 D4) via the `GeneralSettings`
7
- * adapter — the Admin's form structure and test ids
8
- * (`account-general-*`), not the former `account-name-*` ones. Sign-in and
9
- * cookie settings moved to Security/Notifications (security.test.tsx,
10
- * notifications.test.tsx); this file keeps:
11
- *
12
- * 1. The frame — Back to the Inbox, the four-tab rail with General
13
- * current.
14
- * 2. The color-mode control, the profile form (email read-only, name,
15
- * photo, Save) and the deletion block in the pane's DOM order.
16
- * 3. The profile form on the member path: one Save sends the name, and
17
- * the photo only when it changed; a refusal keeps what was typed.
18
- * 4. The profile form with no member API (a 404): Better Auth's save, no
19
- * photo field.
20
- * 5. The deletion request: the answer names who it went to; the action's
21
- * refusal mapping; a Support pointer with no member API.
22
- * 6. `#billing` forwards to Billing; `#general` and no fragment stay.
23
- * 7. #11167 — the member General: Color mode on every site, the photo from
24
- * the member profile read, no Name field (the photo saves alone, the
25
- * account name follows the contact's first and last names on save,
26
- * never a hand-set one), the Contact details as a level-2 section with
27
- * no lead, the hints as placeholders.
28
- */
29
- import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
30
- import { tmpdir } from "node:os";
31
- import { join } from "node:path";
32
-
33
- import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
34
-
35
- jest.mock("next-intl/server", () => {
36
- const msgs: unknown = require("../../../../../messages/en.json");
37
- const dig = (obj: unknown, path: string): unknown =>
38
- path.split(".").reduce<unknown>(
39
- (acc, k) => (acc !== null && typeof acc === "object" ? (acc as Record<string, unknown>)[k] : undefined),
40
- obj,
41
- );
42
- return {
43
- __esModule: true,
44
- getTranslations: async (arg: string | { namespace?: string; locale?: string }) => {
45
- const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
46
- const messages = dig(msgs, ns);
47
- return (key: string, values?: Record<string, unknown>): string => {
48
- const value = dig(messages, key);
49
- if (typeof value !== "string") return `${ns}.${key}`;
50
- return value.replace(/\{(\w+)\}/g, (m, name: string) =>
51
- values && name in values ? String(values[name]) : m,
52
- );
53
- };
54
- },
55
- };
56
- });
57
-
58
- const mockHeaders = jest.fn();
59
- const mockCookieSet = jest.fn();
60
- jest.mock("next/headers", () => ({
61
- __esModule: true,
62
- headers: (...args: unknown[]) => mockHeaders(...args),
63
- cookies: jest.fn().mockImplementation(async () => ({
64
- toString: () => "session=abc",
65
- set: (...args: unknown[]) => mockCookieSet(...args),
66
- })),
67
- }));
68
-
69
- const mockGetSession = jest.fn();
70
- // 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.
71
- jest.mock("../../../../../auth", () => ({
72
- __esModule: true,
73
- auth: { api: { getSession: (...args: unknown[]) => mockGetSession(...args) } },
74
- }));
75
-
76
- const mockPieces = jest.fn();
77
- const mockUpdateProfile = jest.fn();
78
- const mockRequestDeletion = jest.fn();
79
- const mockContact = jest.fn();
80
- const mockUpdateContact = jest.fn();
81
- const mockProfile = jest.fn();
82
- const mockHubMe = jest.fn();
83
- const mockLeadsSubmit = jest.fn();
84
- jest.mock("@working-theory/api-client", () => ({
85
- __esModule: true,
86
- waitlistSignups: { me: jest.fn() },
87
- flowCheckouts: { me: jest.fn() },
88
- subscription: { me: jest.fn(), portalSession: jest.fn() },
89
- leads: { submit: (...args: unknown[]) => mockLeadsSubmit(...args) },
90
- member: {
91
- pieces: (...args: unknown[]) => mockPieces(...args),
92
- updateProfile: (...args: unknown[]) => mockUpdateProfile(...args),
93
- requestDeletion: (...args: unknown[]) => mockRequestDeletion(...args),
94
- contact: (...args: unknown[]) => mockContact(...args),
95
- updateContact: (...args: unknown[]) => mockUpdateContact(...args),
96
- profile: (...args: unknown[]) => mockProfile(...args),
97
- },
98
- hubSignIn: { me: (...args: unknown[]) => mockHubMe(...args) },
99
- visitorForwardHeaders: () => null,
100
- }));
101
-
102
- const mockUpdateUser = jest.fn();
103
- jest.mock("better-auth/react", () => ({
104
- __esModule: true,
105
- createAuthClient: () => ({
106
- signOut: jest.fn(),
107
- updateUser: (...args: unknown[]) => mockUpdateUser(...args),
108
- }),
109
- }));
110
-
111
- const mockRefresh = jest.fn();
112
- const mockReplace = jest.fn();
113
- jest.mock("next/navigation", () => ({
114
- __esModule: true,
115
- useRouter: () => ({ push: jest.fn(), refresh: mockRefresh, replace: mockReplace }),
116
- usePathname: () => "/account/general",
117
- redirect: jest.fn(),
118
- }));
119
-
120
- // The colour-mode cases test the theme's modes, so they run against an unpinned
121
- // chrome, as settings.test.tsx did (theme-modes.test.ts covers the pin).
122
- // eslint-disable-next-line no-restricted-syntax -- #507: `site-chrome.ts` is a generated data module with no external boundary to mock instead (as theme-modes.test.ts).
123
- jest.mock("../../../../../lib/site-chrome", () => {
124
- const actual = jest.requireActual("../../../../../lib/site-chrome");
125
- const { colorMode, ...unpinned } = actual.siteChrome;
126
- return { ...actual, siteChrome: unpinned };
127
- });
128
-
129
- import type { AccountSettingsSection } from "@working-theory/templates/account";
130
-
131
- import { accountSettingsSections } from "../../../../../lib/account-config";
132
- import { seal } from "../../../../../lib/hub-session/seal";
133
- import { BillingAnchor } from "../general/billing-anchor";
134
- import { accountNameFollowsContact, derivedAccountName } from "../general/account-name";
135
- import { saveContact } from "../general/contact-actions";
136
- import Page from "../general/page";
137
- import { savePhoto } from "../general/photo-actions";
138
- import { saveProfile } from "../profile-actions";
139
-
140
- const PHOTO = "https://cdn.example.com/ada.png";
141
- /** The photo the member API holds — the hub's, which a spoke's session never carries (#11167). */
142
- const HUB_PHOTO = "https://lh3.googleusercontent.com/a/ada";
143
- const SESSION = {
144
- user: {
145
- id: "user_1",
146
- name: "Ada Lovelace",
147
- email: "ada@example.com",
148
- emailVerified: true,
149
- image: PHOTO,
150
- createdAt: new Date("2026-09-01T00:00:00.000Z"),
151
- },
152
- };
153
- const COOKIE_INIT = { headers: { cookie: "session=abc" } };
154
- const ok = <T,>(body: T) => ({ ok: true, body });
155
- const refusal = (status: number, code: string) => ({
156
- ok: false,
157
- status,
158
- body: { ok: false, error: { code, message: code } },
159
- });
160
-
161
- // ── The site's theme and env ─────────────────────────────────────────────────
162
-
163
- let contentRoot: string;
164
-
165
- function writeSite(frontmatter: string): void {
166
- writeFileSync(join(contentRoot, "_site.mdx"), `---\n${frontmatter}\n---\n`);
167
- }
168
-
169
- const ENV = process.env;
170
- const ENV_KEYS = [
171
- "GOOGLE_CLIENT_ID",
172
- "GOOGLE_CLIENT_SECRET",
173
- "GITHUB_CLIENT_ID",
174
- "GITHUB_CLIENT_SECRET",
175
- "AUTH_EMAIL_SERVER",
176
- "AUTH_EMAIL_FROM",
177
- "AUTH_EMAIL_WEBHOOK_SECRET",
178
- "BETTER_AUTH_URL",
179
- "BETTER_AUTH_SECRET",
180
- "AILK_HUB_SIGN_IN_URL",
181
- "AILK_HUB_CLIENT_ID",
182
- "AILK_HUB_CLIENT_SECRET",
183
- "AILK_HUB_SESSION_SECRET",
184
- ] as const;
185
-
186
- beforeEach(() => {
187
- process.env = { ...ENV };
188
- for (const key of ENV_KEYS) delete process.env[key];
189
- contentRoot = mkdtempSync(join(tmpdir(), "ailk-general-"));
190
- process.env.AILK_CONTENT_ROOT = contentRoot;
191
- writeSite('siteName: "Test"');
192
- mockHeaders.mockReset().mockResolvedValue(new Headers());
193
- mockCookieSet.mockReset();
194
- mockGetSession.mockReset().mockResolvedValue(SESSION);
195
- mockPieces.mockReset().mockResolvedValue(ok([]));
196
- mockUpdateProfile.mockReset().mockResolvedValue(ok({ name: "Ada King", image: PHOTO }));
197
- mockRequestDeletion.mockReset().mockResolvedValue(ok({ sentTo: "site-operator" }));
198
- mockContact.mockReset().mockResolvedValue(ok({ contact: null }));
199
- mockUpdateContact.mockReset().mockResolvedValue(ok({ contact: null }));
200
- mockProfile.mockReset().mockResolvedValue(ok({ name: "Ada Lovelace", image: HUB_PHOTO }));
201
- mockHubMe.mockReset();
202
- mockLeadsSubmit.mockReset();
203
- mockUpdateUser.mockReset().mockResolvedValue({ data: { status: true }, error: null });
204
- mockRefresh.mockReset();
205
- mockReplace.mockReset();
206
- });
207
-
208
- afterEach(() => {
209
- rmSync(contentRoot, { recursive: true, force: true });
210
- process.env = ENV;
211
- });
212
-
213
- async function renderPage(locale = "en"): Promise<void> {
214
- render(await Page({ params: Promise.resolve({ locale }) }));
215
- }
216
-
217
- async function clickSave(): Promise<void> {
218
- await act(async () => {
219
- fireEvent.click(screen.getByTestId("account-general-save"));
220
- });
221
- }
222
-
223
- // ── 1. The frame (AC-1, AC-4) ──────────────────────────────────────────────────
224
-
225
- describe("AC-1 — the frame (D2, D7)", () => {
226
- it("renders in the settings frame: Back to the Inbox, and the five tabs with General current (#8438 D14 adds Privacy)", async () => {
227
- await renderPage();
228
- expect(screen.getByTestId("account-settings")).toContainElement(
229
- screen.getByRole("heading", { level: 1, name: "General" }),
230
- );
231
- expect(screen.getByTestId("account-settings-back")).toHaveAttribute("href", "/account");
232
- expect(screen.getByTestId("account-settings-back")).toHaveTextContent("Back");
233
- const rail = screen.getByRole("navigation", { name: "Settings" });
234
- const links = within(rail).getAllByRole("link");
235
- expect(links.map((link) => [link.textContent, link.getAttribute("href")])).toEqual([
236
- ["General", "/account/general"],
237
- ["Security", "/account/security"],
238
- ["Notifications", "/account/notifications"],
239
- ["Privacy", "/account/privacy"],
240
- ["Billing", "/account/billing"],
241
- ]);
242
- expect(links[0]).toHaveAttribute("aria-current", "page");
243
- for (const link of links.slice(1)) expect(link).not.toHaveAttribute("aria-current");
244
- });
245
-
246
- it("a non-default locale prefixes Back and the rail", async () => {
247
- await renderPage("fr");
248
- expect(screen.getByTestId("account-settings-back")).toHaveAttribute("href", "/fr/account");
249
- expect(screen.getByTestId("account-settings-rail-general")).toHaveAttribute("href", "/fr/account/general");
250
- expect(screen.getByTestId("account-settings-rail-security")).toHaveAttribute("href", "/fr/account/security");
251
- expect(screen.getByTestId("account-settings-rail-notifications")).toHaveAttribute(
252
- "href",
253
- "/fr/account/notifications",
254
- );
255
- expect(screen.getByTestId("account-settings-rail-privacy")).toHaveAttribute("href", "/fr/account/privacy");
256
- expect(screen.getByTestId("account-settings-rail-billing")).toHaveAttribute("href", "/fr/account/billing");
257
- });
258
-
259
- it("renders no Security or Notifications content on General", async () => {
260
- await renderPage();
261
- expect(screen.queryByTestId("account-signin-method")).not.toBeInTheDocument();
262
- expect(screen.queryByTestId("account-cookie-settings")).not.toBeInTheDocument();
263
- expect(screen.queryByText("Sign-in methods")).not.toBeInTheDocument();
264
- for (const absent of [/credentials/i, /scope/i, /organizations/i, /credits/i]) {
265
- expect(screen.queryByRole("heading", { name: absent })).not.toBeInTheDocument();
266
- }
267
- });
268
-
269
- it("the pane holds the email read-only and the photo input, and no Name field (#11167 ruling 5)", async () => {
270
- await renderPage();
271
- const pane = screen.getByTestId("account-settings-general");
272
- expect(within(pane).getByTestId("account-general-email")).toHaveTextContent("ada@example.com");
273
- expect(within(pane).queryByRole("textbox", { name: "Email" })).not.toBeInTheDocument();
274
- expect(within(pane).queryByLabelText("Name")).not.toBeInTheDocument();
275
- expect(within(pane).queryByTestId("account-general-name")).not.toBeInTheDocument();
276
- // The photo is the member profile's — the hub's row (#11167 ruling 4).
277
- expect(within(pane).getByLabelText("Photo")).toHaveValue(HUB_PHOTO);
278
- expect(mockProfile).toHaveBeenCalledWith(COOKIE_INIT);
279
- });
280
-
281
- it("a failed member profile read falls back to the session's photo", async () => {
282
- mockProfile.mockRejectedValue(new Error("down"));
283
- await renderPage();
284
- expect(screen.getByLabelText("Photo")).toHaveValue(PHOTO);
285
- mockProfile.mockResolvedValue(refusal(503, "tenant_unresolved"));
286
- document.body.innerHTML = "";
287
- await renderPage();
288
- expect(screen.getByLabelText("Photo")).toHaveValue(PHOTO);
289
- });
290
-
291
- it("the rail still shows the account name", async () => {
292
- await renderPage();
293
- expect(within(screen.getByTestId("account-settings-rail")).getByText("Ada Lovelace")).toBeInTheDocument();
294
- });
295
-
296
- it("renders no deletion block — Request account deletion moved to Privacy (#8438 D16)", async () => {
297
- await renderPage();
298
- expect(screen.queryByTestId("account-deletion")).not.toBeInTheDocument();
299
- expect(screen.queryByTestId("account-deletion-request")).not.toBeInTheDocument();
300
- });
301
-
302
- it("the photo is never rendered as an image", async () => {
303
- await renderPage();
304
- expect(document.querySelector(`img[src="${HUB_PHOTO}"]`)).toBeNull();
305
- });
306
-
307
- it("a light-only theme renders the color-mode control too (#11167 ruling 3)", async () => {
308
- writeSite('theme:\n colors:\n light:\n bg: "#fdfcfa"\n text: "#1c1917"');
309
- await renderPage();
310
- expect(screen.getByTestId("account-color-mode")).toBeInTheDocument();
311
- });
312
-
313
- it("the color-mode control writes the theme cookie", async () => {
314
- await renderPage();
315
- const group = screen.getByRole("radiogroup", { name: "Color mode" });
316
- fireEvent.click(within(group).getByRole("radio", { name: "Dark" }));
317
- expect(document.cookie).toContain("ailk-theme=dark");
318
- document.cookie = "ailk-theme=; max-age=0; path=/";
319
- document.documentElement.removeAttribute("data-theme");
320
- });
321
-
322
- it("the color-mode control holds Light · Auto · Dark", async () => {
323
- await renderPage();
324
- const control = screen.getByTestId("account-color-mode");
325
- expect(within(control).getAllByRole("radio").map((r) => r.textContent)).toEqual(["Light", "Auto", "Dark"]);
326
- });
327
-
328
- it("a contributed settings section renders after the general form (C8)", async () => {
329
- const section: AccountSettingsSection = {
330
- id: "extra",
331
- title: "settings.general.title",
332
- render: () => <p data-testid="extra-body">Extra</p>,
333
- };
334
- accountSettingsSections.push(section);
335
- try {
336
- await renderPage();
337
- const form = screen.getByTestId("account-general-form");
338
- const extra = screen.getByTestId("account-settings-extra");
339
- expect(form.compareDocumentPosition(extra) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
340
- expect(screen.getByTestId("extra-body")).toBeInTheDocument();
341
- } finally {
342
- accountSettingsSections.splice(accountSettingsSections.indexOf(section), 1);
343
- }
344
- });
345
- });
346
-
347
- describe("the standalone shape (#8430)", () => {
348
- it("takes the screen as the Admin's settings do: the rail column and the pane are the page's own landmarks", async () => {
349
- await renderPage();
350
- const settings = screen.getByTestId("account-settings");
351
- expect(settings).toHaveClass("min-h-screen");
352
- const column = within(settings).getByRole("complementary");
353
- expect(column.firstElementChild).toBe(screen.getByTestId("account-settings-back"));
354
- expect(column).toContainElement(screen.getByTestId("account-settings-rail"));
355
- expect(within(settings).getByRole("main")).toContainElement(
356
- screen.getByRole("heading", { level: 1 }),
357
- );
358
- });
359
- });
360
-
361
- // ── 2. The profile form on the member path (AC-3) ─────────────────────────────
362
-
363
- describe("AC-3 — the photo through the member API (D4, D8; #11167 ruling 5: the photo alone)", () => {
364
- it("a typed photo sends { image } alone — never the name — then refreshes", async () => {
365
- await renderPage();
366
- const save = screen.getByTestId("account-general-save");
367
- expect(save).toBeDisabled();
368
- const next = "https://cdn.example.com/new.png";
369
- mockUpdateProfile.mockResolvedValue(ok({ name: "Ada Lovelace", image: next }));
370
- fireEvent.change(screen.getByLabelText("Photo"), { target: { value: ` ${next} ` } });
371
- await clickSave();
372
- expect(mockUpdateProfile).toHaveBeenCalledTimes(1);
373
- expect(mockUpdateProfile).toHaveBeenCalledWith({ image: next }, COOKIE_INIT);
374
- await waitFor(() => expect(mockRefresh).toHaveBeenCalledTimes(1));
375
- expect(screen.getByTestId("account-general-status")).toHaveTextContent("Saved.");
376
- expect(mockUpdateUser).not.toHaveBeenCalled();
377
- });
378
-
379
- it("emptying a started photo sends image: null", async () => {
380
- await renderPage();
381
- mockUpdateProfile.mockResolvedValue(ok({ name: "Ada Lovelace", image: null }));
382
- fireEvent.change(screen.getByLabelText("Photo"), { target: { value: "" } });
383
- await clickSave();
384
- expect(mockUpdateProfile).toHaveBeenCalledWith({ image: null }, COOKIE_INIT);
385
- });
386
-
387
- it("a refused photo says so plainly and the field keeps what was typed (AC-MAA-07)", async () => {
388
- mockUpdateProfile.mockResolvedValue(refusal(400, "link_not_https"));
389
- await renderPage();
390
- fireEvent.change(screen.getByLabelText("Photo"), { target: { value: "http://cdn.example.com/a.png" } });
391
- await clickSave();
392
- expect(screen.getByRole("alert")).toHaveTextContent("Enter a link that starts with https://.");
393
- expect(screen.getByLabelText("Photo")).toHaveValue("http://cdn.example.com/a.png");
394
- expect(mockRefresh).not.toHaveBeenCalled();
395
- });
396
-
397
- it.each([
398
- [refusal(403, "email_unverified"), "Confirm your email address first, then try again."],
399
- [refusal(404, "not_found"), "Profile changes aren't available on this site yet."],
400
- [refusal(500, "internal"), "We couldn't save your changes. Try again."],
401
- ])("a refusal shows its message and keeps the edit (%#)", async (answer, message) => {
402
- mockUpdateProfile.mockResolvedValue(answer);
403
- await renderPage();
404
- fireEvent.change(screen.getByLabelText("Photo"), { target: { value: "https://cdn.example.com/b.png" } });
405
- await clickSave();
406
- expect(screen.getByTestId("account-general-status")).toHaveTextContent(message);
407
- expect(screen.getByLabelText("Photo")).toHaveValue("https://cdn.example.com/b.png");
408
- });
409
-
410
- it("a photo that is not a link is refused inline, with no call", async () => {
411
- await renderPage();
412
- fireEvent.change(screen.getByLabelText("Photo"), { target: { value: "ada.png" } });
413
- await clickSave();
414
- expect(mockUpdateProfile).not.toHaveBeenCalled();
415
- expect(screen.getByRole("alert")).toHaveTextContent("Enter a link that starts with https://.");
416
- });
417
-
418
- it("a 503 from the pieces read still offers the member writes", async () => {
419
- mockPieces.mockResolvedValue(refusal(503, "tenant_unresolved"));
420
- await renderPage();
421
- expect(screen.getByLabelText("Photo")).toBeInTheDocument();
422
- });
423
- });
424
-
425
- describe("AC-3 — savePhoto (#11167)", () => {
426
- it("calls member.updateProfile with the image alone and forwardedCookieInit()'s init", async () => {
427
- mockHeaders.mockResolvedValue(new Headers({ origin: "https://site.example.com" }));
428
- mockUpdateProfile.mockResolvedValue(ok({ name: "Ada Lovelace", image: PHOTO }));
429
- await expect(savePhoto(` ${PHOTO} `)).resolves.toEqual({ ok: true, image: PHOTO });
430
- expect(mockUpdateProfile).toHaveBeenCalledWith(
431
- { image: PHOTO },
432
- { headers: { cookie: "session=abc", origin: "https://site.example.com" } },
433
- );
434
- await savePhoto(" ");
435
- expect(mockUpdateProfile).toHaveBeenLastCalledWith({ image: null }, expect.anything());
436
- });
437
-
438
- it.each([
439
- [refusal(400, "link_not_https"), "photo"],
440
- [refusal(400, "invalid_input"), "failed"],
441
- [refusal(403, "email_unverified"), "unverified"],
442
- [refusal(404, "not_found"), "unavailable"],
443
- [refusal(503, "tenant_unresolved"), "unavailable"],
444
- [refusal(500, "internal"), "failed"],
445
- ])("maps %j to %s", async (answer, reason) => {
446
- mockUpdateProfile.mockResolvedValue(answer);
447
- await expect(savePhoto(PHOTO)).resolves.toEqual({ ok: false, reason });
448
- });
449
-
450
- it("refuses an image that is neither a string nor null, and a throw is failed", async () => {
451
- await expect(savePhoto(42 as never)).resolves.toEqual({ ok: false, reason: "photo" });
452
- expect(mockUpdateProfile).not.toHaveBeenCalled();
453
- mockUpdateProfile.mockRejectedValue(new TypeError("fetch failed"));
454
- await expect(savePhoto(PHOTO)).resolves.toEqual({ ok: false, reason: "failed" });
455
- });
456
- });
457
-
458
- describe("AC-3 — saveProfile (D6)", () => {
459
- it("calls member.updateProfile with forwardedCookieInit()'s init and answers the saved pair", async () => {
460
- mockHeaders.mockResolvedValue(new Headers({ origin: "https://site.example.com" }));
461
- await expect(saveProfile({ name: " Ada King ", image: " " })).resolves.toEqual({
462
- ok: true,
463
- name: "Ada King",
464
- image: PHOTO,
465
- });
466
- expect(mockUpdateProfile).toHaveBeenCalledWith(
467
- { name: "Ada King", image: null },
468
- { headers: { cookie: "session=abc", origin: "https://site.example.com" } },
469
- );
470
- });
471
-
472
- it.each([
473
- [refusal(400, "link_not_https"), "photo"],
474
- [refusal(400, "invalid_input"), "failed"],
475
- [refusal(403, "email_unverified"), "unverified"],
476
- [refusal(404, "not_found"), "unavailable"],
477
- [refusal(503, "tenant_unresolved"), "unavailable"],
478
- [refusal(500, "internal"), "failed"],
479
- ])("maps %j to %s", async (answer, reason) => {
480
- mockUpdateProfile.mockResolvedValue(answer);
481
- await expect(saveProfile({ name: "Ada" })).resolves.toEqual({ ok: false, reason });
482
- });
483
-
484
- it("refuses an image that is neither a string nor null, rather than clearing the photo", async () => {
485
- await expect(saveProfile({ name: "Ada", image: 42 as never })).resolves.toEqual({
486
- ok: false,
487
- reason: "photo",
488
- });
489
- expect(mockUpdateProfile).not.toHaveBeenCalled();
490
- await expect(saveProfile(null as never)).resolves.toEqual({ ok: false, reason: "required" });
491
- });
492
-
493
- it("a throw is failed; a blank name is required with no call", async () => {
494
- mockUpdateProfile.mockRejectedValue(new TypeError("fetch failed"));
495
- await expect(saveProfile({ name: "Ada" })).resolves.toEqual({ ok: false, reason: "failed" });
496
- mockUpdateProfile.mockClear();
497
- await expect(saveProfile({ name: " " })).resolves.toEqual({ ok: false, reason: "required" });
498
- expect(mockUpdateProfile).not.toHaveBeenCalled();
499
- });
500
-
501
- it("re-seals the hub session once after a 200 (D11), and never after a refusal", async () => {
502
- const secret = "s".repeat(43);
503
- process.env.AILK_HUB_SIGN_IN_URL = "https://hub.example.com";
504
- process.env.AILK_HUB_CLIENT_ID = "spoke_0001";
505
- process.env.AILK_HUB_CLIENT_SECRET = `ailk_hcs_${"c".repeat(43)}`;
506
- process.env.AILK_HUB_SESSION_SECRET = secret;
507
- process.env.NEXT_PUBLIC_BASE_URL = "http://127.0.0.1:3100";
508
- const user = { name: "Ada Lovelace", email: "ada@example.com", emailVerified: true, createdAt: "2026-09-01T00:00:00.000Z" };
509
- const sealed = seal(
510
- { v: 1, accessToken: `ailk_hst_${"t".repeat(43)}`, expiresAt: Date.now() + 60_000, user },
511
- secret,
512
- "session",
513
- "ailk-hub-session",
514
- );
515
- mockHeaders.mockResolvedValue(new Headers({ cookie: `ailk-hub-session=${sealed}` }));
516
- mockHubMe.mockResolvedValue(ok({ user: { ...user, name: "Ada King" }, billingCustomerId: null }));
517
-
518
- await saveProfile({ name: "Ada King" });
519
- expect(mockHubMe).toHaveBeenCalledTimes(1);
520
- expect(mockCookieSet).toHaveBeenCalledTimes(1);
521
-
522
- mockUpdateProfile.mockResolvedValue(refusal(403, "email_unverified"));
523
- await saveProfile({ name: "Ada King" });
524
- expect(mockHubMe).toHaveBeenCalledTimes(1);
525
- });
526
-
527
- it("re-seals nothing on a single site with no hub configuration", async () => {
528
- await expect(saveProfile({ name: "Ada King" })).resolves.toMatchObject({ ok: true });
529
- expect(mockHubMe).not.toHaveBeenCalled();
530
- expect(mockCookieSet).not.toHaveBeenCalled();
531
- });
532
- });
533
-
534
- // ── 3. No member API (C2, D3) ─────────────────────────────────────────────────
535
-
536
- describe("AC-3 — a single site with no member API (a 404 from the pieces read)", () => {
537
- beforeEach(() => {
538
- mockPieces.mockResolvedValue(refusal(404, "not_found"));
539
- });
540
-
541
- it("shows no photo field and saves the name through Better Auth, not the member API", async () => {
542
- await renderPage();
543
- expect(screen.queryByLabelText("Photo")).not.toBeInTheDocument();
544
- fireEvent.change(screen.getByLabelText("Name"), { target: { value: " Grace Hopper " } });
545
- await clickSave();
546
- expect(mockUpdateUser).toHaveBeenCalledWith({ name: "Grace Hopper" });
547
- expect(mockUpdateProfile).not.toHaveBeenCalled();
548
- await waitFor(() => expect(mockRefresh).toHaveBeenCalledTimes(1));
549
- });
550
-
551
- it("a failed Better Auth save says so and keeps the edit", async () => {
552
- mockUpdateUser.mockResolvedValue({ data: null, error: { message: "nope" } });
553
- await renderPage();
554
- fireEvent.change(screen.getByLabelText("Name"), { target: { value: "Ada King" } });
555
- await clickSave();
556
- expect(screen.getByTestId("account-general-status")).toHaveTextContent(
557
- "We couldn't save your changes. Try again.",
558
- );
559
- expect(screen.getByLabelText("Name")).toHaveValue("Ada King");
560
- });
561
- });
562
-
563
- // ── #8435 D13 (AC-6) — the contact details on this site ───────────────────────
564
-
565
- describe("AC-6 — the contact details (#8435 D13)", () => {
566
- const CONTACT = {
567
- givenName: "Ada",
568
- familyName: "Lovelace",
569
- telephone: "+442071234567",
570
- address: {
571
- addressLine1: "1 Analytical Way",
572
- addressLine2: null,
573
- city: "London",
574
- region: "LDN",
575
- postalCode: "N1 1AA",
576
- country: "GB",
577
- },
578
- companyName: "Engines Ltd",
579
- jobTitle: "Countess",
580
- };
581
-
582
- it("with the member API, renders the contact section seeded from member.contact", async () => {
583
- mockContact.mockResolvedValue(ok({ contact: CONTACT }));
584
- await renderPage();
585
- const section = screen.getByTestId("account-contact-section");
586
- expect(mockContact).toHaveBeenCalledWith(COOKIE_INIT);
587
- expect(within(section).getByTestId("contact-given-name")).toHaveValue("Ada");
588
- expect(within(section).getByTestId("contact-company")).toHaveValue("Engines Ltd");
589
- expect(within(section).getByTestId("field-addressLine1")).toHaveValue("1 Analytical Way");
590
- // The profile form's single "Save changes" button stays unique.
591
- expect(screen.getAllByRole("button", { name: "Save changes" })).toHaveLength(1);
592
- expect(within(section).getByTestId("contact-details-save")).toHaveTextContent("Save contact details");
593
- });
594
-
595
- // #11167 rulings 6, 7, 11, 12 — the headings order and the three strings
596
- // that are gone: the Contact details lead, the Photo help copy and the
597
- // phone's Format caption.
598
- it("General is the h1 and Contact details a level-2 section under it; the lead and the two hints are gone", async () => {
599
- await renderPage();
600
- const headings = screen.getAllByRole("heading").map((h) => [h.tagName, h.textContent]);
601
- expect(headings[0]).toEqual(["H1", "General"]);
602
- expect(headings).toContainEqual(["H2", "Contact details"]);
603
- expect(headings.map(([tag]) => tag)).not.toContain("H3");
604
- for (const absent of [
605
- "Kept on this site, for the people you work with here.",
606
- "A link to a square image, starting with https://. Leave it empty to show your initials.",
607
- "Format: (201) 555-0123",
608
- ]) {
609
- expect(screen.queryByText(absent)).not.toBeInTheDocument();
610
- }
611
- expect(screen.getByLabelText("Photo")).toHaveAttribute("placeholder", "https://");
612
- expect(screen.getByTestId("field-telephone")).toHaveAttribute("placeholder", "(###) ###-####");
613
- // The Address group label is the fieldset's hidden legend (ruling 12).
614
- expect(screen.getByTestId("field-contact-address-legend")).toHaveClass("sr-only");
615
- expect(screen.getAllByText("Address")).toHaveLength(1);
616
- // Each group is a card of the pane (ruling 2): color mode, the form, the contact.
617
- const cards = screen.getAllByTestId("account-settings-general-card");
618
- expect(cards.length).toBeGreaterThanOrEqual(3);
619
- expect(cards[2]).toContainElement(screen.getByTestId("account-contact-section"));
620
- });
621
-
622
- it("a saved contact refreshes the route, so the rail follows the derived name", async () => {
623
- mockContact.mockResolvedValue(ok({ contact: CONTACT }));
624
- await renderPage();
625
- fireEvent.change(screen.getByTestId("contact-company"), { target: { value: "Acme" } });
626
- await act(async () => {
627
- fireEvent.submit(screen.getByTestId("contact-details-form"));
628
- });
629
- await waitFor(() => expect(mockRefresh).toHaveBeenCalledTimes(1));
630
- });
631
-
632
- it("with no confirmed contact yet, the form starts blank", async () => {
633
- await renderPage();
634
- expect(screen.getByTestId("contact-given-name")).toHaveValue("");
635
- });
636
-
637
- it("a failed read renders the section's unavailable line, not the form", async () => {
638
- mockContact.mockResolvedValue(refusal(503, "tenant_unresolved"));
639
- await renderPage();
640
- expect(screen.queryByTestId("contact-details-form")).not.toBeInTheDocument();
641
- expect(screen.getByTestId("account-contact-unavailable")).toHaveTextContent(
642
- "Contact details aren't available on this site right now.",
643
- );
644
- });
645
-
646
- it("a read that throws is the same unavailable line", async () => {
647
- mockContact.mockRejectedValue(new Error("down"));
648
- await renderPage();
649
- expect(screen.getByTestId("account-contact-unavailable")).toBeInTheDocument();
650
- });
651
-
652
- it("with no member API (a 404 from the pieces read) the section does not render", async () => {
653
- mockPieces.mockResolvedValue(refusal(404, "not_found"));
654
- await renderPage();
655
- expect(screen.queryByTestId("account-contact-section")).not.toBeInTheDocument();
656
- expect(mockContact).not.toHaveBeenCalled();
657
- });
658
-
659
- it("saving posts all six keys through saveContact and answers Saved", async () => {
660
- mockContact.mockResolvedValue(ok({ contact: CONTACT }));
661
- await renderPage();
662
- fireEvent.change(screen.getByTestId("contact-company"), { target: { value: "Acme" } });
663
- await act(async () => {
664
- fireEvent.submit(screen.getByTestId("contact-details-form"));
665
- });
666
- await waitFor(() => expect(mockUpdateContact).toHaveBeenCalledTimes(1));
667
- expect(mockUpdateContact).toHaveBeenCalledWith(
668
- {
669
- givenName: "Ada",
670
- familyName: "Lovelace",
671
- telephone: "+442071234567",
672
- address: CONTACT.address,
673
- companyName: "Acme",
674
- jobTitle: "Countess",
675
- },
676
- COOKIE_INIT,
677
- );
678
- expect(await screen.findByTestId("contact-details-message")).toHaveTextContent("Saved.");
679
- });
680
-
681
- it("a refused telephone shows its own line and keeps the fields as typed", async () => {
682
- mockUpdateContact.mockResolvedValue(refusal(400, "telephone_invalid"));
683
- await renderPage();
684
- fireEvent.change(screen.getByTestId("contact-company"), { target: { value: "Acme" } });
685
- await act(async () => {
686
- fireEvent.submit(screen.getByTestId("contact-details-form"));
687
- });
688
- expect(await screen.findByTestId("contact-details-message")).toHaveTextContent(
689
- "Enter the phone number with its country code.",
690
- );
691
- expect(screen.getByTestId("contact-company")).toHaveValue("Acme");
692
- });
693
- });
694
-
695
- describe("AC-6 — saveContact (#8435 D13)", () => {
696
- const BODY = {
697
- givenName: "Ada",
698
- familyName: null,
699
- telephone: null,
700
- address: null,
701
- companyName: null,
702
- jobTitle: null,
703
- };
704
-
705
- it("calls member.updateContact with forwardedCookieInit()'s init", async () => {
706
- mockHeaders.mockResolvedValue(new Headers({ origin: "https://site.example.com" }));
707
- await expect(saveContact(BODY)).resolves.toEqual({ ok: true });
708
- expect(mockUpdateContact).toHaveBeenCalledWith(BODY, {
709
- headers: { cookie: "session=abc", origin: "https://site.example.com" },
710
- });
711
- });
712
-
713
- it.each([
714
- [refusal(400, "telephone_invalid"), "telephone"],
715
- [refusal(400, "invalid_input"), "invalid"],
716
- [refusal(403, "email_unverified"), "unverified"],
717
- [refusal(404, "not_found"), "unavailable"],
718
- [refusal(409, "contact_unavailable"), "unavailable"],
719
- [refusal(503, "tenant_unresolved"), "unavailable"],
720
- [refusal(500, "internal_error"), "failed"],
721
- ])("maps %j to %s", async (res, reason) => {
722
- mockUpdateContact.mockResolvedValue(res);
723
- await expect(saveContact(BODY)).resolves.toEqual({ ok: false, reason });
724
- });
725
-
726
- it("a throw is failed, and a non-object body makes no call", async () => {
727
- mockUpdateContact.mockRejectedValue(new Error("down"));
728
- await expect(saveContact(BODY)).resolves.toEqual({ ok: false, reason: "failed" });
729
- mockUpdateContact.mockClear();
730
- await expect(saveContact(null as never)).resolves.toEqual({ ok: false, reason: "invalid" });
731
- expect(mockUpdateContact).not.toHaveBeenCalled();
732
- });
733
- });
734
-
735
- // ── #11167 ruling 5 — the account name follows the contact ──────────────────
736
-
737
- describe("the account name follows the contact (#11167 ruling 5)", () => {
738
- type Names = { givenName: string | null; familyName: string | null };
739
- const NAMES: Names = { givenName: "Ada", familyName: "King" };
740
- const BLANK_REST = { telephone: null, address: null, companyName: null, jobTitle: null };
741
- const saved = (names: Names) => ok({ contact: { ...names, ...BLANK_REST } });
742
- const previous = (names: Names | null) =>
743
- ok({ contact: names === null ? null : { ...names, ...BLANK_REST } });
744
- // The account name is the STORED one (`member.profile`), never the session's
745
- // copy — a spoke's cookie holds the name from its last re-seal.
746
- const stored = (name: string | null) => mockProfile.mockResolvedValue(ok({ name, image: null }));
747
- const BODY = { ...NAMES, ...BLANK_REST };
748
-
749
- it("derivedAccountName is 'First Last', trimmed, cut to the profile width, and empty with neither name", () => {
750
- expect(derivedAccountName({ givenName: " Ada ", familyName: "King" })).toBe("Ada King");
751
- expect(derivedAccountName({ givenName: "A".repeat(150), familyName: "B".repeat(150) })).toHaveLength(200);
752
- expect(derivedAccountName({ givenName: "Ada", familyName: null })).toBe("Ada");
753
- expect(derivedAccountName({ givenName: null, familyName: " " })).toBe("");
754
- expect(derivedAccountName(null)).toBe("");
755
- });
756
-
757
- it("accountNameFollowsContact: an empty name follows; the last derived value follows; a hand-set name never does", () => {
758
- expect(accountNameFollowsContact("", null)).toBe(true);
759
- expect(accountNameFollowsContact(null, { givenName: "Ada", familyName: "Lovelace" })).toBe(true);
760
- expect(accountNameFollowsContact("Ada Lovelace", { givenName: "Ada", familyName: "Lovelace" })).toBe(true);
761
- expect(accountNameFollowsContact("Countess Ada", { givenName: "Ada", familyName: "Lovelace" })).toBe(false);
762
- expect(accountNameFollowsContact("Ada Lovelace", null)).toBe(false);
763
- });
764
-
765
- it("an empty account name takes 'First Last' after the contact saves", async () => {
766
- stored(null);
767
- mockContact.mockResolvedValue(previous(null));
768
- mockUpdateContact.mockResolvedValue(saved(NAMES));
769
- await expect(saveContact(BODY)).resolves.toEqual({ ok: true });
770
- expect(mockUpdateProfile).toHaveBeenCalledTimes(1);
771
- expect(mockUpdateProfile).toHaveBeenCalledWith({ name: "Ada King" }, COOKIE_INIT);
772
- // The stored name and the previous contact are read before the save.
773
- expect(mockProfile).toHaveBeenCalledWith(COOKIE_INIT);
774
- expect(mockContact.mock.invocationCallOrder[0]).toBeLessThan(mockUpdateContact.mock.invocationCallOrder[0]!);
775
- expect(mockProfile.mock.invocationCallOrder[0]).toBeLessThan(mockUpdateContact.mock.invocationCallOrder[0]!);
776
- // A single site has no hub session to re-seal.
777
- expect(mockHubMe).not.toHaveBeenCalled();
778
- });
779
-
780
- it("a name that equals the last derived value follows the new names", async () => {
781
- stored("Ada Lovelace");
782
- mockContact.mockResolvedValue(previous({ givenName: "Ada", familyName: "Lovelace" }));
783
- mockUpdateContact.mockResolvedValue(saved(NAMES));
784
- await saveContact(BODY);
785
- expect(mockUpdateProfile).toHaveBeenCalledWith({ name: "Ada King" }, COOKIE_INIT);
786
- });
787
-
788
- it("the stored name decides, not the session's copy: a hand-set name on the hub is kept even when the session still carries the derived one", async () => {
789
- mockGetSession.mockResolvedValue({ ...SESSION, user: { ...SESSION.user, name: "Ada Lovelace" } });
790
- stored("Countess Ada");
791
- mockContact.mockResolvedValue(previous({ givenName: "Ada", familyName: "Lovelace" }));
792
- mockUpdateContact.mockResolvedValue(saved(NAMES));
793
- await saveContact(BODY);
794
- expect(mockUpdateProfile).not.toHaveBeenCalled();
795
- });
796
-
797
- it("when the stored name cannot be read, nothing follows", async () => {
798
- mockProfile.mockResolvedValue(refusal(503, "tenant_unresolved"));
799
- mockContact.mockResolvedValue(previous(null));
800
- mockUpdateContact.mockResolvedValue(saved(NAMES));
801
- await expect(saveContact(BODY)).resolves.toEqual({ ok: true });
802
- expect(mockUpdateProfile).not.toHaveBeenCalled();
803
- });
804
-
805
- it("a hand-set name is never overwritten", async () => {
806
- stored("Countess Ada");
807
- mockContact.mockResolvedValue(previous({ givenName: "Ada", familyName: "Lovelace" }));
808
- mockUpdateContact.mockResolvedValue(saved(NAMES));
809
- await expect(saveContact(BODY)).resolves.toEqual({ ok: true });
810
- expect(mockUpdateProfile).not.toHaveBeenCalled();
811
- });
812
-
813
- it("a name already equal to the derived one, or a contact with no names, writes nothing", async () => {
814
- stored("Ada King");
815
- mockContact.mockResolvedValue(previous(NAMES));
816
- mockUpdateContact.mockResolvedValue(saved(NAMES));
817
- await saveContact(BODY);
818
- expect(mockUpdateProfile).not.toHaveBeenCalled();
819
-
820
- stored(null);
821
- mockUpdateContact.mockResolvedValue(saved({ givenName: null, familyName: null }));
822
- await saveContact({ ...BODY, givenName: null, familyName: null });
823
- expect(mockUpdateProfile).not.toHaveBeenCalled();
824
- });
825
-
826
- it("when the previous contact cannot be read, only an empty name follows", async () => {
827
- mockContact.mockRejectedValue(new Error("down"));
828
- mockUpdateContact.mockResolvedValue(saved(NAMES));
829
- stored("Ada Lovelace");
830
- await saveContact(BODY);
831
- expect(mockUpdateProfile).not.toHaveBeenCalled();
832
- stored("");
833
- await saveContact(BODY);
834
- expect(mockUpdateProfile).toHaveBeenCalledWith({ name: "Ada King" }, COOKIE_INIT);
835
- });
836
-
837
- it("a refused contact save derives nothing, and a failed follow still answers ok", async () => {
838
- stored(null);
839
- mockUpdateContact.mockResolvedValue(refusal(403, "email_unverified"));
840
- await expect(saveContact(BODY)).resolves.toEqual({ ok: false, reason: "unverified" });
841
- expect(mockUpdateProfile).not.toHaveBeenCalled();
842
-
843
- mockUpdateContact.mockResolvedValue(saved(NAMES));
844
- mockUpdateProfile.mockRejectedValue(new Error("down"));
845
- await expect(saveContact(BODY)).resolves.toEqual({ ok: true });
846
- });
847
- });
848
-
849
- // The deletion-request cases moved to privacy.test.tsx — Request account
850
- // deletion now renders on Privacy, not General (#8438 D16).
851
-
852
- // ── 5. #billing (AC-6) ────────────────────────────────────────────────────────
853
-
854
- describe("AC-6 — BillingAnchor forwards #billing to Billing (D8)", () => {
855
- afterEach(() => {
856
- window.location.hash = "";
857
- });
858
-
859
- it("#billing replaces the route with /account/billing, once", () => {
860
- window.location.hash = "#billing";
861
- render(<BillingAnchor locale="en" />);
862
- expect(mockReplace).toHaveBeenCalledTimes(1);
863
- expect(mockReplace).toHaveBeenCalledWith("/account/billing");
864
- });
865
-
866
- it("keeps the locale", () => {
867
- window.location.hash = "#billing";
868
- render(<BillingAnchor locale="fr" />);
869
- expect(mockReplace).toHaveBeenCalledWith("/fr/account/billing");
870
- });
871
-
872
- it.each(["#general", ""])("%j stays on General", (hash) => {
873
- window.location.hash = hash;
874
- render(<BillingAnchor locale="en" />);
875
- expect(mockReplace).not.toHaveBeenCalled();
876
- });
877
-
878
- it("General carries the anchor", async () => {
879
- window.location.hash = "#billing";
880
- await renderPage();
881
- expect(mockReplace).toHaveBeenCalledWith("/account/billing");
882
- });
883
- });