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,208 +0,0 @@
1
- /**
2
- * Tests for /[locale]/account/support — Contact support (#7430, spec 7423
3
- * U4 · D11; AC-9).
4
- *
5
- * Covers:
6
- * 1. The form posts `{ kind: "support", subject, message }` to
7
- * `/v1/leads/submit` (`leads.submit`) with `source: "web"`, the
8
- * session's email and no `siteId`, and shows a confirmation on 201.
9
- * 2. A missing subject or message is refused without a call.
10
- * 3. A failed submit says so and keeps what was typed; the API's
11
- * `lead_capture_not_configured` 503 says requests can't be sent.
12
- */
13
- import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
14
-
15
- jest.mock("next-intl/server", () => {
16
- const msgs: unknown = require("../../../../../messages/en.json");
17
- const dig = (obj: unknown, path: string): unknown =>
18
- path.split(".").reduce<unknown>(
19
- (acc, k) => (acc !== null && typeof acc === "object" ? (acc as Record<string, unknown>)[k] : undefined),
20
- obj,
21
- );
22
- return {
23
- __esModule: true,
24
- getTranslations: async (arg: string | { namespace?: string; locale?: string }) => {
25
- const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
26
- const messages = dig(msgs, ns);
27
- return (key: string, values?: Record<string, unknown>): string => {
28
- const value = dig(messages, key);
29
- if (typeof value !== "string") return `${ns}.${key}`;
30
- return value.replace(/\{(\w+)\}/g, (m, name: string) =>
31
- values && name in values ? String(values[name]) : m,
32
- );
33
- };
34
- },
35
- };
36
- });
37
-
38
- jest.mock("next/headers", () => ({
39
- __esModule: true,
40
- headers: jest.fn().mockResolvedValue(new Headers()),
41
- cookies: jest.fn().mockResolvedValue({ toString: () => "session=abc" }),
42
- }));
43
-
44
- const mockGetSession = jest.fn();
45
- // 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.
46
- jest.mock("../../../../../auth", () => ({
47
- __esModule: true,
48
- auth: { api: { getSession: (...args: unknown[]) => mockGetSession(...args) } },
49
- }));
50
-
51
- const mockLeadsSubmit = jest.fn();
52
- jest.mock("@working-theory/api-client", () => ({
53
- __esModule: true,
54
- subscription: { me: jest.fn(), portalSession: jest.fn() },
55
- leads: { submit: (...args: unknown[]) => mockLeadsSubmit(...args) },
56
- visitorForwardHeaders: () => undefined,
57
- }));
58
-
59
- jest.mock("next/navigation", () => ({
60
- __esModule: true,
61
- useRouter: () => ({ push: jest.fn(), refresh: jest.fn() }),
62
- usePathname: () => "/account/support",
63
- redirect: jest.fn(),
64
- }));
65
-
66
- import { submitSupportRequest } from "../support-actions";
67
- import Page from "../support/page";
68
-
69
- const SESSION = {
70
- user: { id: "user_1", name: "Ada", email: "ada@example.com", emailVerified: true },
71
- };
72
-
73
- beforeEach(() => {
74
- mockGetSession.mockReset().mockResolvedValue(SESSION);
75
- mockLeadsSubmit
76
- .mockReset()
77
- .mockResolvedValue({ ok: true, body: { id: "lead_1", persisted: "db" } });
78
- });
79
-
80
- async function renderPage(): Promise<void> {
81
- const element = await Page({ params: Promise.resolve({ locale: "en" }) });
82
- render(element);
83
- }
84
-
85
- async function submit(subject: string, message: string): Promise<void> {
86
- fireEvent.change(screen.getByLabelText("Subject"), { target: { value: subject } });
87
- fireEvent.change(screen.getByLabelText("Message"), { target: { value: message } });
88
- await act(async () => {
89
- fireEvent.click(screen.getByTestId("account-support-submit"));
90
- });
91
- }
92
-
93
- describe("Contact support (AC-9, D11)", () => {
94
- it("the primary is 44px on a phone only — the 36px default from md up (DESIGN.md §4)", async () => {
95
- await renderPage();
96
- const submit = screen.getByTestId("account-support-submit");
97
- expect(submit).toHaveClass("max-md:min-h-11");
98
- });
99
-
100
- it("renders the page heading and says where the reply goes", async () => {
101
- await renderPage();
102
- expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("Contact support");
103
- expect(screen.getByTestId("account-support")).toHaveTextContent("ada@example.com");
104
- });
105
-
106
- it('posts { kind: "support", subject, message } with source "web", and confirms on 201', async () => {
107
- await renderPage();
108
- await submit("Billing question", "Where is my receipt?");
109
- await waitFor(() => expect(mockLeadsSubmit).toHaveBeenCalledTimes(1));
110
- expect(mockLeadsSubmit.mock.calls[0]).toEqual([
111
- {
112
- source: "web",
113
- email: "ada@example.com",
114
- payload: {
115
- kind: "support",
116
- subject: "Billing question",
117
- message: "Where is my receipt?",
118
- },
119
- },
120
- ]);
121
- await waitFor(() =>
122
- expect(screen.getByRole("status")).toHaveTextContent("your request is on its way"),
123
- );
124
- expect(screen.queryByTestId("account-support-submit")).not.toBeInTheDocument();
125
- });
126
-
127
- it("a missing message is refused without a call", async () => {
128
- await renderPage();
129
- await submit("Billing question", " ");
130
- expect(mockLeadsSubmit).not.toHaveBeenCalled();
131
- expect(screen.getByRole("alert")).toHaveTextContent(
132
- "Fill in both the subject and the message.",
133
- );
134
- });
135
-
136
- it("a failed submit says so and keeps what was typed", async () => {
137
- mockLeadsSubmit.mockResolvedValue({ ok: false, status: 500, body: {} });
138
- await renderPage();
139
- await submit("Billing question", "Where is my receipt?");
140
- await waitFor(() =>
141
- expect(screen.getByRole("alert")).toHaveTextContent("We couldn't send your request."),
142
- );
143
- expect(screen.getByLabelText("Subject")).toHaveValue("Billing question");
144
- expect(screen.getByLabelText("Message")).toHaveValue("Where is my receipt?");
145
- });
146
-
147
- it("a deployment that accepts no contact message says requests can't be sent", async () => {
148
- mockLeadsSubmit.mockResolvedValue({
149
- ok: false,
150
- status: 503,
151
- body: { error: "lead_capture_not_configured" },
152
- });
153
- await renderPage();
154
- await submit("Billing question", "Where is my receipt?");
155
- await waitFor(() =>
156
- expect(screen.getByRole("alert")).toHaveTextContent("Requests can't be sent from this site yet."),
157
- );
158
- });
159
- });
160
-
161
- describe("submitSupportRequest — the Server Action's own guards", () => {
162
- function form(fields: Record<string, string>): FormData {
163
- const data = new FormData();
164
- for (const [key, value] of Object.entries(fields)) data.set(key, value);
165
- return data;
166
- }
167
-
168
- it("with no session, files nothing", async () => {
169
- mockGetSession.mockResolvedValue(null);
170
- const state = await submitSupportRequest(
171
- { kind: "idle" },
172
- form({ kind: "support", subject: "Hi", message: "Help" }),
173
- );
174
- expect(state).toEqual({ kind: "error", reason: "failed" });
175
- expect(mockLeadsSubmit).not.toHaveBeenCalled();
176
- });
177
-
178
- it("refuses an over-length subject or message", async () => {
179
- const long = await submitSupportRequest(
180
- { kind: "idle" },
181
- form({ kind: "support", subject: "x".repeat(201), message: "Help" }),
182
- );
183
- expect(long).toEqual({ kind: "error", reason: "required" });
184
- const longer = await submitSupportRequest(
185
- { kind: "idle" },
186
- form({ kind: "support", subject: "Hi", message: "x".repeat(5001) }),
187
- );
188
- expect(longer).toEqual({ kind: "error", reason: "required" });
189
- expect(mockLeadsSubmit).not.toHaveBeenCalled();
190
- });
191
-
192
- // #8232 D12 — a deletion request goes through `member.requestDeletion`
193
- // (`profile-actions.ts`), so Support files support only.
194
- it.each(["refund", "deletion"])(
195
- "every request files as support, a posted kind=%s included; the email is always the session's",
196
- async (kind) => {
197
- await submitSupportRequest(
198
- { kind: "idle" },
199
- form({ kind, subject: "Hi", message: "Help", email: "someone@else.com" }),
200
- );
201
- expect(mockLeadsSubmit).toHaveBeenCalledWith({
202
- source: "web",
203
- email: "ada@example.com",
204
- payload: { kind: "support", subject: "Hi", message: "Help" },
205
- });
206
- },
207
- );
208
- });
@@ -1,340 +0,0 @@
1
- /**
2
- * Tests for /[locale]/account/inbox/thread — the member's one conversation
3
- * with the workspace (#11152).
4
- *
5
- * Covers:
6
- * 1. The page lists every message between the signed-in person and the
7
- * workspace — the provider's messages (`member.messages`, start side)
8
- * and the person's own sent requests and messages (`member.requests`,
9
- * end side) — oldest first, under a RecordHeader titled Messages whose
10
- * back link returns to the Inbox's Messages tab, with the composer at
11
- * the foot of the conversation.
12
- * 2. An empty thread reads the empty line; a failed read shows the error
13
- * row with Retry above what did load (D12's posture); signed out is a
14
- * not-found.
15
- * 3. A message's own actions (a file's Download) render under its bubble.
16
- * 4. Posting from the composer runs the existing member message write
17
- * (`sendMessage` → `member.sendMessage`) with the body as typed and a
18
- * subject cut from its first line; a success clears the field and
19
- * refreshes the route, whose next render lists the sent message — no
20
- * reload; a refusal shows its plain message and keeps the body.
21
- * 5. `threadSubject` — the first non-blank line, whitespace collapsed,
22
- * clipped to the subject's cap.
23
- */
24
- import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
25
-
26
- jest.mock("next-intl/server", () => {
27
- const msgs: unknown = require("../../../../../messages/en.json");
28
- const dig = (obj: unknown, path: string): unknown =>
29
- path.split(".").reduce<unknown>(
30
- (acc, k) => (acc !== null && typeof acc === "object" ? (acc as Record<string, unknown>)[k] : undefined),
31
- obj,
32
- );
33
- return {
34
- __esModule: true,
35
- getTranslations: async (arg: string | { namespace?: string; locale?: string }) => {
36
- const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
37
- const messages = dig(msgs, ns);
38
- return (key: string, values?: Record<string, unknown>): string => {
39
- const value = dig(messages, key);
40
- if (typeof value !== "string") return `${ns}.${key}`;
41
- return value.replace(/\{(\w+)\}/g, (m, name: string) =>
42
- values && name in values ? String(values[name]) : m,
43
- );
44
- };
45
- },
46
- };
47
- });
48
-
49
- jest.mock("next/headers", () => ({
50
- __esModule: true,
51
- headers: jest.fn().mockResolvedValue(new Headers()),
52
- cookies: jest.fn().mockResolvedValue({ toString: () => "session=abc" }),
53
- }));
54
-
55
- const mockGetSession = jest.fn();
56
- // 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.
57
- jest.mock("../../../../../auth", () => ({
58
- __esModule: true,
59
- auth: { api: { getSession: (...args: unknown[]) => mockGetSession(...args) } },
60
- }));
61
-
62
- const mockMemberMessages = jest.fn();
63
- const mockMemberRequests = jest.fn();
64
- const mockMemberSendMessage = jest.fn();
65
- jest.mock("@working-theory/api-client", () => ({
66
- __esModule: true,
67
- waitlistSignups: { me: jest.fn() },
68
- subscription: { me: jest.fn() },
69
- member: {
70
- messages: (...args: unknown[]) => mockMemberMessages(...args),
71
- requests: (...args: unknown[]) => mockMemberRequests(...args),
72
- sendMessage: (...args: unknown[]) => mockMemberSendMessage(...args),
73
- },
74
- }));
75
-
76
- const mockNotFound = jest.fn(() => {
77
- throw new Error("NEXT_NOT_FOUND");
78
- });
79
- const mockRefresh = jest.fn();
80
- jest.mock("next/navigation", () => ({
81
- __esModule: true,
82
- notFound: () => mockNotFound(),
83
- useRouter: () => ({ push: jest.fn(), refresh: mockRefresh }),
84
- usePathname: () => "/account/inbox/thread",
85
- }));
86
-
87
- import { MESSAGE_SUBJECT_MAX } from "@working-theory/validation";
88
-
89
- import Page from "../inbox/thread/page";
90
- import { threadSubject } from "../inbox/thread/thread-data";
91
-
92
- const SESSION = {
93
- user: { id: "user_1", name: "Ada", email: "ada@example.com", emailVerified: true },
94
- };
95
-
96
- /** The cookie a single site forwards (`forwardedCookieInit()`). */
97
- const INIT = { headers: { cookie: "session=abc" } };
98
-
99
- const ok = <T,>(body: T) => ({ ok: true, body });
100
- const refusal = (status: number, code: string) => ({
101
- ok: false,
102
- status,
103
- body: { ok: false, error: { code, message: "x" } },
104
- });
105
-
106
- /** The provider's messages to the member, newest first as the read serves them. */
107
- const MESSAGES = [
108
- {
109
- id: "int_file",
110
- subject: "Your plan",
111
- body: "The plan is attached.",
112
- file: { filename: "plan.pdf", contentType: "application/pdf" },
113
- action: null,
114
- createdAt: "2026-10-12T09:00:00.000Z",
115
- readAt: null,
116
- },
117
- {
118
- id: "int_1",
119
- subject: "Welcome",
120
- body: "Thanks for reaching out.",
121
- file: null,
122
- action: null,
123
- createdAt: "2026-10-10T09:00:00.000Z",
124
- readAt: null,
125
- },
126
- ];
127
-
128
- /** The member's own sent rows, newest first as the read serves them. */
129
- const REQUESTS = [
130
- {
131
- id: "intx_a",
132
- kind: "message" as const,
133
- subject: "Hello",
134
- body: "Hi there",
135
- createdAt: "2026-10-11T10:00:00.000Z",
136
- },
137
- {
138
- id: "intx_q",
139
- kind: "quote" as const,
140
- subject: "Request quote",
141
- body: "",
142
- createdAt: "2026-10-09T10:00:00.000Z",
143
- },
144
- ];
145
-
146
- const RECEIPT = ok({ id: "intx_new", createdAt: "2026-10-13T10:00:00.000Z" });
147
-
148
- beforeEach(() => {
149
- mockGetSession.mockReset().mockResolvedValue(SESSION);
150
- mockMemberMessages.mockReset().mockResolvedValue(ok({ items: MESSAGES }));
151
- mockMemberRequests.mockReset().mockResolvedValue(ok({ items: REQUESTS }));
152
- mockMemberSendMessage.mockReset().mockResolvedValue(RECEIPT);
153
- mockNotFound.mockClear();
154
- mockRefresh.mockReset();
155
- });
156
-
157
- async function renderThread(locale = "en"): Promise<ReturnType<typeof render>> {
158
- const element = await Page({ params: Promise.resolve({ locale }) });
159
- return render(element);
160
- }
161
-
162
- function entries(): HTMLElement[] {
163
- return screen.getAllByTestId("account-thread-entry");
164
- }
165
-
166
- describe("the member thread page lists the whole conversation (AC-2)", () => {
167
- it("renders both sides oldest first under a Messages header, the composer at the foot", async () => {
168
- await renderThread();
169
- const frame = screen.getByTestId("account-thread");
170
- const header = within(frame).getByTestId("account-thread-header");
171
- expect(within(header).getByRole("heading", { level: 1 })).toHaveTextContent("Messages");
172
- const back = within(header).getByTestId("account-thread-back");
173
- expect(back).toHaveAttribute("href", "/account?tab=messages");
174
- expect(back).toHaveAccessibleName("Inbox");
175
-
176
- expect(mockMemberMessages).toHaveBeenCalledWith(INIT);
177
- expect(mockMemberRequests).toHaveBeenCalledWith(INIT);
178
-
179
- // Oldest first: the quote request, Welcome, Hello, Your plan.
180
- const rows = entries();
181
- expect(rows.map((row) => row.getAttribute("data-kind"))).toEqual([
182
- "request",
183
- "message",
184
- "request",
185
- "message",
186
- ]);
187
- expect(rows[0]).toHaveTextContent("Your quote request was sent.");
188
- expect(rows[1]).toHaveTextContent("Thanks for reaching out.");
189
- expect(rows[2]).toHaveTextContent("Hi there");
190
- expect(rows[3]).toHaveTextContent("The plan is attached.");
191
- // The provider's messages sit on the start side, the member's own on the end.
192
- expect(within(rows[1]!).getByTestId("account-item-message")).toHaveAttribute("data-side", "start");
193
- expect(within(rows[2]!).getByTestId("account-item-request")).toHaveAttribute("data-side", "end");
194
-
195
- // The composer is pinned after the conversation.
196
- const conversation = within(frame).getByTestId("account-thread-conversation");
197
- const composer = within(frame).getByTestId("account-thread-composer");
198
- expect(
199
- conversation.compareDocumentPosition(composer) & Node.DOCUMENT_POSITION_FOLLOWING,
200
- ).toBeTruthy();
201
- expect(within(composer).getByRole("form", { name: "Send a message" })).toBeInTheDocument();
202
- expect(screen.queryByTestId("account-thread-empty")).not.toBeInTheDocument();
203
- });
204
-
205
- it("a message's own actions render under its bubble — the file's Download", async () => {
206
- await renderThread();
207
- const row = entries()[3]!;
208
- const download = within(row).getByRole("link", { name: "Download plan.pdf" });
209
- expect(download).toHaveAttribute("href", "/account/inbox/message/int_file/file");
210
- // The provider's plain message carries none.
211
- expect(within(entries()[1]!).queryByRole("link")).not.toBeInTheDocument();
212
- });
213
-
214
- it("a non-default locale's back link returns to that locale's Inbox", async () => {
215
- await renderThread("fr");
216
- expect(screen.getByTestId("account-thread-back")).toHaveAttribute("href", "/fr/account?tab=messages");
217
- });
218
-
219
- it("an empty thread reads the empty line and still offers the composer", async () => {
220
- mockMemberMessages.mockResolvedValue(ok({ items: [] }));
221
- mockMemberRequests.mockResolvedValue(ok({ items: [] }));
222
- await renderThread();
223
- expect(screen.getByTestId("account-thread-empty")).toHaveTextContent("No messages yet.");
224
- expect(screen.queryAllByTestId("account-thread-entry")).toEqual([]);
225
- expect(screen.getByTestId("thread-composer")).toBeInTheDocument();
226
- });
227
-
228
- it("a 404 from a read is nothing for this caller, not an error", async () => {
229
- mockMemberRequests.mockResolvedValue({ ok: false, status: 404, body: {} });
230
- await renderThread();
231
- expect(screen.queryByTestId("inbox-error")).not.toBeInTheDocument();
232
- expect(entries().map((row) => row.getAttribute("data-kind"))).toEqual(["message", "message"]);
233
- });
234
-
235
- it("a failed read shows the error row with Retry above what did load (D12)", async () => {
236
- mockMemberMessages.mockResolvedValue({ ok: false, status: 500, body: {} });
237
- await renderThread();
238
- expect(mockNotFound).not.toHaveBeenCalled();
239
- const error = screen.getByTestId("inbox-error");
240
- expect(error).toHaveTextContent("We couldn't load this conversation.");
241
- expect(entries().map((row) => row.getAttribute("data-kind"))).toEqual(["request", "request"]);
242
- expect(screen.queryByTestId("account-thread-empty")).not.toBeInTheDocument();
243
- fireEvent.click(screen.getByTestId("inbox-retry"));
244
- expect(mockRefresh).toHaveBeenCalledTimes(1);
245
- });
246
-
247
- it("signed out is a not-found and reads nothing", async () => {
248
- mockGetSession.mockResolvedValue(null);
249
- await expect(renderThread()).rejects.toThrow("NEXT_NOT_FOUND");
250
- expect(mockMemberMessages).not.toHaveBeenCalled();
251
- });
252
- });
253
-
254
- describe("posting from the composer uses the existing member message write (AC-3)", () => {
255
- function type(value: string): HTMLTextAreaElement {
256
- const field = screen.getByLabelText("Message") as HTMLTextAreaElement;
257
- fireEvent.change(field, { target: { value } });
258
- return field;
259
- }
260
-
261
- it("posts the body as typed with its first line as the subject, clears the field and refreshes the route", async () => {
262
- await renderThread();
263
- const field = type("Can we move the call?\nThursday works.");
264
- fireEvent.click(screen.getByTestId("thread-composer-send"));
265
- await waitFor(() => expect(mockMemberSendMessage).toHaveBeenCalledTimes(1));
266
- expect(mockMemberSendMessage).toHaveBeenCalledWith(
267
- { subject: "Can we move the call?", body: "Can we move the call?\nThursday works." },
268
- INIT,
269
- );
270
- await waitFor(() => expect(field).toHaveValue(""));
271
- expect(screen.getByTestId("thread-composer-notice")).toHaveTextContent("Sent.");
272
- expect(mockRefresh).toHaveBeenCalledTimes(1);
273
- });
274
-
275
- it("the refreshed render lists the sent message as the member's own newest bubble — no reload", async () => {
276
- const { unmount } = await renderThread();
277
- type("Can we move the call?");
278
- fireEvent.click(screen.getByTestId("thread-composer-send"));
279
- await waitFor(() => expect(mockRefresh).toHaveBeenCalledTimes(1));
280
- unmount();
281
- // `router.refresh()` re-renders the route's Server Components: the
282
- // requests read now serves the row the write created.
283
- mockMemberRequests.mockResolvedValue(
284
- ok({
285
- items: [
286
- {
287
- id: "intx_new",
288
- kind: "message" as const,
289
- subject: "Can we move the call?",
290
- body: "Can we move the call?",
291
- createdAt: "2026-10-13T10:00:00.000Z",
292
- },
293
- ...REQUESTS,
294
- ],
295
- }),
296
- );
297
- await renderThread();
298
- const rows = entries();
299
- const last = rows[rows.length - 1]!;
300
- expect(last).toHaveAttribute("data-kind", "request");
301
- expect(last).toHaveTextContent("Can we move the call?");
302
- expect(within(last).getByTestId("account-item-request")).toHaveAttribute("data-side", "end");
303
- });
304
-
305
- it("a refusal shows its plain message, keeps the body and refreshes nothing", async () => {
306
- mockMemberSendMessage.mockResolvedValue(refusal(429, "too_many_requests"));
307
- await renderThread();
308
- const field = type("Hello again");
309
- fireEvent.click(screen.getByTestId("thread-composer-send"));
310
- const notice = await screen.findByTestId("thread-composer-notice");
311
- expect(notice).toHaveTextContent("Too many requests. Try again later.");
312
- expect(field).toHaveValue("Hello again");
313
- expect(mockRefresh).not.toHaveBeenCalled();
314
- });
315
-
316
- it("an unlisted refusal code reads the generic line", async () => {
317
- mockMemberSendMessage.mockResolvedValue(refusal(503, "tenant_unresolved"));
318
- await renderThread();
319
- type("Hello again");
320
- fireEvent.click(screen.getByTestId("thread-composer-send"));
321
- expect(await screen.findByText("This could not be sent. Try again.")).toBeInTheDocument();
322
- });
323
- });
324
-
325
- describe("threadSubject — the subject cut from the body", () => {
326
- it("is the first non-blank line, its whitespace collapsed", () => {
327
- expect(threadSubject(" \n Can we move the call? \nThursday works.")).toBe(
328
- "Can we move the call?",
329
- );
330
- });
331
-
332
- it("is clipped to the subject's cap", () => {
333
- const long = "x".repeat(MESSAGE_SUBJECT_MAX + 20);
334
- expect(threadSubject(long)).toHaveLength(MESSAGE_SUBJECT_MAX);
335
- });
336
-
337
- it("is empty for a blank body — the server's own rule refuses it", () => {
338
- expect(threadSubject(" \n ")).toBe("");
339
- });
340
- });