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,203 +0,0 @@
1
- // oss: false
2
- "use client";
3
-
4
- /**
5
- * ResultsEmailStep — the results page's in-place email step (#4842 FR2/FR4),
6
- * mirroring the FlowStepper single-field topology (#4806 FR1/FR4, DESIGN
7
- * §7.4): the hero question is the visible `<Heading>` AND the field's own
8
- * `sr-only` label — one visible question, one answer box, no second small
9
- * label. Enter submits (a one-text-field form submits implicitly); the
10
- * frame's bar button submits the same form by `form={formId}`.
11
- *
12
- * Client-side validation is the ONLY thing that happens before the caller's
13
- * `onSubmit` fires: an invalid address renders the validation message and
14
- * calls nothing (AC-1 — no request leaves on an invalid submit). The
15
- * saved micro-state (FR4) renders in place of the field once `saved` is set.
16
- *
17
- * #11013 D-F — the results view's Get your full report form is this same
18
- * step: with `action` the submit button renders inside the form, in one row
19
- * with the field from `md:` and stacked below it, and `consent` renders a
20
- * line under the field; `labels.savedBody` is optional. Without the new props
21
- * it renders exactly as before, so the checkout view's call is unchanged.
22
- *
23
- * Every visible string is a prop (FR8 / `customer-facing-i18n`) — no bare
24
- * JSX text node lives in this file (§5.2).
25
- */
26
- import { Button, Form, Heading, Input, Label, Text } from "@working-theory/ui";
27
- import { flowSaveInputSchema } from "@working-theory/validation";
28
- import type { FormEvent, ReactElement } from "react";
29
- import { useEffect, useRef, useState } from "react";
30
-
31
- export interface ResultsEmailStepLabels {
32
- /** The validation message for a malformed address. */
33
- invalidEmail: string;
34
- placeholder: string;
35
- savedTitle: string;
36
- savedBody?: string;
37
- }
38
-
39
- export interface ResultsEmailStepProps {
40
- /** The hero question — visible heading + the field's sr-only label. */
41
- title: string;
42
- /** The form's id, so a bar button outside it can submit it (`form={id}`). */
43
- formId: string;
44
- labels: ResultsEmailStepLabels;
45
- /** Fires ONLY with a schema-valid email. */
46
- onSubmit: (email: string) => void | Promise<void>;
47
- pending: boolean;
48
- /** A server-side failure message; rendered as an alert under the field. */
49
- error?: string;
50
- /** FR4 — the saved micro-state replaces the field. */
51
- saved?: boolean;
52
- /**
53
- * #11013 D-F — a submit button inside the form (the report form's Send it);
54
- * `outline` beside a card, `default` when it is the primary. With
55
- * `dockedBelowMd` the button shows from `md:` only — below it a docked copy
56
- * outside the form submits by `form={formId}` (decision 16). Absent, the
57
- * frame's bar button submits the form by `form={formId}`, as before.
58
- */
59
- action?: { label: string; variant: "default" | "outline"; dockedBelowMd?: boolean };
60
- /** #11013 D-F — the consent line under the field. */
61
- consent?: string;
62
- "data-testid"?: string;
63
- }
64
-
65
- const emailSchema = flowSaveInputSchema.shape.email;
66
-
67
- export function ResultsEmailStep({
68
- title,
69
- formId,
70
- labels,
71
- onSubmit,
72
- pending,
73
- error,
74
- saved = false,
75
- action,
76
- consent,
77
- "data-testid": dataTestId = "results-email-step",
78
- }: ResultsEmailStepProps): ReactElement {
79
- const [email, setEmail] = useState("");
80
- const [validationError, setValidationError] = useState<string | undefined>();
81
- const inputRef = useRef<HTMLInputElement>(null);
82
- const inputId = `${formId}-email`;
83
- const messageId = `${formId}-message`;
84
-
85
- // A docked Send it (`action.dockedBelowMd`) can sit a screen below the
86
- // field, so a failed submit brings the field — and its message — into view
87
- // and under focus; a server error arriving later does the same.
88
- useEffect(() => {
89
- if (error !== undefined) inputRef.current?.focus();
90
- }, [error]);
91
-
92
- if (saved) {
93
- return (
94
- <div data-testid={`${dataTestId}-saved`} role="status">
95
- {action !== undefined ? (
96
- // Decision 13 — the section label stays; the sent line takes the form's place.
97
- <>
98
- <Heading level={2} className="text-heading-4">
99
- {title}
100
- </Heading>
101
- <Text variant="body" className="mt-block-tight">
102
- {labels.savedTitle}
103
- </Text>
104
- </>
105
- ) : (
106
- <Heading level={2}>{labels.savedTitle}</Heading>
107
- )}
108
- {labels.savedBody !== undefined ? (
109
- <Text variant="body" tone="muted" className="mt-block-tight">
110
- {labels.savedBody}
111
- </Text>
112
- ) : null}
113
- </div>
114
- );
115
- }
116
-
117
- function handleSubmit(_event: FormEvent<HTMLFormElement>): void {
118
- if (pending) return;
119
- const parsed = emailSchema.safeParse(email);
120
- if (!parsed.success) {
121
- setValidationError(labels.invalidEmail);
122
- inputRef.current?.focus();
123
- return;
124
- }
125
- setValidationError(undefined);
126
- void onSubmit(parsed.data);
127
- }
128
-
129
- const message = validationError ?? error;
130
-
131
- const field = (
132
- <>
133
- <Label htmlFor={inputId} className="sr-only">
134
- {title}
135
- </Label>
136
- <Input
137
- ref={inputRef}
138
- id={inputId}
139
- name="email"
140
- type="email"
141
- size="big"
142
- autoComplete="email"
143
- inputMode="email"
144
- placeholder={labels.placeholder}
145
- value={email}
146
- onChange={(event) => setEmail(event.target.value)}
147
- disabled={pending}
148
- aria-invalid={message !== undefined ? true : undefined}
149
- aria-describedby={message !== undefined ? messageId : undefined}
150
- {...(message !== undefined ? { variant: "error" as const } : {})}
151
- />
152
- {message !== undefined ? (
153
- <div id={messageId} role="alert" className="mt-block-tight">
154
- <Text variant="body-sm" className="text-(--color-error-fg)">
155
- {message}
156
- </Text>
157
- </div>
158
- ) : null}
159
- </>
160
- );
161
-
162
- return (
163
- <div data-testid={dataTestId}>
164
- {/* #11013 D-F — the inline report form's heading is a section label (decision 13). */}
165
- <Heading level={2} {...(action !== undefined ? { className: "text-heading-4" } : {})}>
166
- {title}
167
- </Heading>
168
- <Form id={formId} className="mt-block-loose" onSubmit={handleSubmit}>
169
- {action !== undefined ? (
170
- // #11013 D-F — the field and Send it in one row from `md:`, stacked below.
171
- <div className="flex flex-col gap-3 md:flex-row md:items-start">
172
- <div className="min-w-0 flex-1">{field}</div>
173
- {/* `Button` joins its classes without a merge, so `hidden` cannot
174
- override its own `inline-flex`; the wrapper hides the docked
175
- copy's in-form twin below `md:` and vanishes from `md:`. */}
176
- <div
177
- className={action.dockedBelowMd === true ? "hidden md:contents" : "contents"}
178
- data-testid={`${dataTestId}-send-slot`}
179
- >
180
- <Button
181
- type="submit"
182
- variant={action.variant}
183
- size="big"
184
- disabled={pending}
185
- className="min-h-11 w-full md:w-auto"
186
- data-testid={`${dataTestId}-send`}
187
- >
188
- {action.label}
189
- </Button>
190
- </div>
191
- </div>
192
- ) : (
193
- field
194
- )}
195
- </Form>
196
- {consent !== undefined ? (
197
- <Text variant="caption" tone="muted" className="mt-block-tight">
198
- {consent}
199
- </Text>
200
- ) : null}
201
- </div>
202
- );
203
- }
@@ -1,194 +0,0 @@
1
- /**
2
- * The results page without commerce (#6786 AC2) — the Pro default, where the
3
- * route ships with signal-collectors and commerce's `layout.tsx` is absent.
4
- *
5
- * `ResultsClient` is rendered with no `ResultsCheckoutContext` provider, as
6
- * Next renders it in a scaffold that carries no commerce layout: it shows its
7
- * non-checkout result — the recommendation, the top fit with Book a Call and
8
- * the Get your full report form (#11013) — and offers no checkout action,
9
- * even for a fit the register can quote.
10
- *
11
- * This suite ships into that scaffold, so it names no commerce file: it mocks
12
- * only `../../../save.actions` (the boundary is ResultsClient → the save
13
- * action, covered on its own by `save.actions.test.ts`), plus `next-intl` and
14
- * `@working-theory/api-client` as `ResultsClient.checkout.test.tsx` does.
15
- */
16
- import { readFileSync } from "node:fs";
17
- import { join } from "node:path";
18
-
19
- import { render, screen } from "@testing-library/react";
20
- import userEvent from "@testing-library/user-event";
21
- import type { FlowConfig } from "@working-theory/validation";
22
-
23
- jest.mock("@working-theory/api-client", () => ({
24
- __esModule: true,
25
- flows: { get: jest.fn() },
26
- }));
27
-
28
- const mockSave = jest.fn();
29
- // The boundary under test is ResultsClient's own wiring to its Server Action,
30
- // not the action itself (save.actions.test.ts) — the same narrow-scope
31
- // justification ResultsClient.checkout.test.tsx carries.
32
- // eslint-disable-next-line no-restricted-syntax -- see comment above
33
- jest.mock("../../../save.actions", () => ({
34
- sendResultsEmailAction: (...args: unknown[]) => mockSave(...args),
35
- }));
36
-
37
- jest.mock("next-intl", () => ({
38
- __esModule: true,
39
- useTranslations: () => (key: string) => key,
40
- useMessages: () => ({}),
41
- }));
42
-
43
- import { ResultsClient } from "../ResultsClient";
44
-
45
- const SLUG = "ailk-recommender";
46
- const ANSWERS = { team_size: "agency" };
47
-
48
- /** A register that CAN quote `pro` — so only commerce's absence withholds Get Started. */
49
- const CONFIG = {
50
- slug: SLUG,
51
- defaultLocale: "en",
52
- mode: "recommending",
53
- steps: [
54
- {
55
- key: "team",
56
- type: "segmentation",
57
- copy: { title: { en: "Team" } },
58
- questions: [
59
- {
60
- name: "team_size",
61
- options: [
62
- { value: "solo", label: { en: "Solo" } },
63
- { value: "agency", label: { en: "Agency" } },
64
- ],
65
- },
66
- ],
67
- },
68
- ],
69
- offers: [
70
- {
71
- key: "pro",
72
- copy: { name: { en: "Pro" } },
73
- price: { kind: "exact", amount: 249, period: "annual" },
74
- rules: [
75
- {
76
- when: { answer: "team_size", eq: "agency" },
77
- reason: { en: "You run an agency." },
78
- },
79
- ],
80
- },
81
- {
82
- key: "consult",
83
- copy: { name: { en: "Consulting" } },
84
- price: { kind: "label", label: { en: "Application-based" } },
85
- rules: [
86
- {
87
- when: { answer: "team_size", eq: "agency" },
88
- reason: { en: "Agencies ask." },
89
- },
90
- ],
91
- },
92
- ],
93
- rateTable: {
94
- currency: "usd",
95
- seatRates: [{ offer: "pro", amount: 249, period: "annual" }],
96
- creditLadder: {
97
- denomination: "annual",
98
- tiers: [{ credits: 10, amount: 99 }],
99
- custom: { en: "Contact us" },
100
- },
101
- },
102
- recommendation: {
103
- key: "recommendation",
104
- copy: { title: { en: "Your recommendation" } },
105
- },
106
- // #11013 — a lead magnet whose walk asked no email: the results page's form is the email step.
107
- conversion: "lead",
108
- } as FlowConfig;
109
-
110
- function renderResults(): void {
111
- render(
112
- <ResultsClient
113
- config={CONFIG}
114
- locale="en"
115
- answers={ANSWERS}
116
- slug={SLUG}
117
- payload="v1-abc"
118
- />,
119
- );
120
- }
121
-
122
- beforeEach(() => {
123
- mockSave.mockReset();
124
- mockSave.mockResolvedValue({ ok: true });
125
- });
126
-
127
- describe("#6786 AC2 — with commerce absent, the results page renders its non-checkout result", () => {
128
- it("renders the recommendation and the top fit with Book a Call — no Get Started", () => {
129
- renderResults();
130
- expect(screen.getByTestId("flow-results")).toBeInTheDocument();
131
- expect(
132
- screen.getByRole("heading", { name: "Your recommendation" }),
133
- ).toBeInTheDocument();
134
- expect(
135
- screen.getByTestId("recommendation-card-pro-terminal-bookCall"),
136
- ).toBeInTheDocument();
137
- expect(screen.queryByTestId("recommendation-card-consult")).not.toBeInTheDocument();
138
- expect(screen.queryAllByTestId(/-terminal-getStarted$/)).toHaveLength(0);
139
- });
140
-
141
- it("offers no checkout action anywhere — no price card, no Pay", () => {
142
- renderResults();
143
- expect(screen.queryByTestId("checkout-price-card")).not.toBeInTheDocument();
144
- expect(screen.queryByTestId("flow-results-pay")).not.toBeInTheDocument();
145
- expect(
146
- screen.queryByRole("button", { name: "getStarted" }),
147
- ).not.toBeInTheDocument();
148
- });
149
-
150
- it("still converts by email, through the report form (#11013)", async () => {
151
- const user = userEvent.setup();
152
- renderResults();
153
- await user.type(
154
- screen.getByLabelText("resultsFormHeadingResults"),
155
- "jane@example.com",
156
- );
157
- await user.click(screen.getByTestId("flow-results-report-send"));
158
- expect(mockSave).toHaveBeenCalledTimes(1);
159
- expect(mockSave).toHaveBeenCalledWith(SLUG, {
160
- answers: ANSWERS,
161
- email: "jane@example.com",
162
- locale: "en",
163
- });
164
- expect(
165
- await screen.findByTestId("flow-results-report-saved"),
166
- ).toBeInTheDocument();
167
- });
168
- });
169
-
170
- describe("#6786 — the page's own files name no commerce module", () => {
171
- // A base file importing a commerce file is swept out of the keyless
172
- // snapshot with it (`paidModuleTemplateExclusions`), and a scaffold without
173
- // commerce has no `@working-theory/ui-commerce` to resolve.
174
- const RESULTS_DIR = join(__dirname, "..");
175
- it.each([
176
- "page.tsx",
177
- "ResultsClient.tsx",
178
- "ResultsEmailStep.tsx",
179
- "ResultsCard.tsx",
180
- "LevelChart.tsx",
181
- "checkout-seam.ts",
182
- "meeting-seam.ts",
183
- "../../save.actions.ts",
184
- "../../email-moment.ts",
185
- ])(
186
- "%s imports neither @working-theory/ui-commerce, checkout.actions nor the commerce layout",
187
- (file) => {
188
- const source = readFileSync(join(RESULTS_DIR, file), "utf8");
189
- expect(source).not.toContain('"@working-theory/ui-commerce"');
190
- expect(source).not.toMatch(/from "[./]*checkout\.actions"/);
191
- expect(source).not.toMatch(/from "\.\/layout"/);
192
- },
193
- );
194
- });
@@ -1,284 +0,0 @@
1
- // oss: false
2
- /**
3
- * Get your full report replaces Save plan (#11013 spec E, D-F; AC-4).
4
- *
5
- * The results view renders the report form inline — the heading from
6
- * `resultsPage.formHeading`, else the Written report default, else the
7
- * results default; the button from `resultsPage.formButton`, else the site
8
- * message; the consent line under the field — only when the walk asked no
9
- * required email question (`resultsPageAsksEmail`) and the served conversion
10
- * is neither absent nor `none`. Submitting calls `sendResultsEmailAction`
11
- * once and, on `{ ok: true }`, replaces the form with "Sent to {email}."; a
12
- * failure keeps the form with its message.
13
- *
14
- * Mocks mirror `ResultsClient.no-commerce.test.tsx`; the translator echoes
15
- * its values so an interpolated message is observable.
16
- */
17
- import { render, screen, within } from "@testing-library/react";
18
- import userEvent from "@testing-library/user-event";
19
- import type { FlowConfig } from "@working-theory/validation";
20
-
21
- jest.mock("@working-theory/api-client", () => ({
22
- __esModule: true,
23
- flows: { get: jest.fn() },
24
- }));
25
-
26
- const mockSend = jest.fn();
27
- // The boundary under test is ResultsClient's wiring to its Server Action, not
28
- // the action itself (save.actions.test.ts) — the narrow-scope mock every
29
- // ResultsClient suite carries.
30
- // eslint-disable-next-line no-restricted-syntax -- see comment above
31
- jest.mock("../../../save.actions", () => ({
32
- sendResultsEmailAction: (...args: unknown[]) => mockSend(...args),
33
- }));
34
-
35
- jest.mock("next-intl", () => ({
36
- __esModule: true,
37
- useTranslations:
38
- () =>
39
- (key: string, values?: Record<string, unknown>): string =>
40
- values === undefined
41
- ? key
42
- : `${key}:${Object.entries(values)
43
- .map(([k, v]) => `${k}=${String(v)}`)
44
- .join(",")}`,
45
- useMessages: () => ({}),
46
- }));
47
-
48
- import { ResultsClient } from "../ResultsClient";
49
-
50
- const SLUG = "ai-readiness";
51
- const en = (s: string) => ({ en: s });
52
- const ANSWERS = { cadence: "weekly" };
53
- const STORAGE_KEY = `ailk:flow-session:${SLUG}`;
54
-
55
- type ServedConfig = FlowConfig & {
56
- conversion?: "none" | "lead" | "lead-link" | "user";
57
- writtenReport?: boolean;
58
- };
59
-
60
- /** A recommending magnet with no offers, no rows and no ending — the results page alone. */
61
- function config(extra: Record<string, unknown> = {}, emailQuestion = false): ServedConfig {
62
- return {
63
- slug: SLUG,
64
- defaultLocale: "en",
65
- mode: "recommending",
66
- steps: [
67
- {
68
- key: "q0",
69
- type: "segmentation",
70
- copy: { title: en("How often do you ship?") },
71
- questions: [
72
- {
73
- name: "cadence",
74
- options: [
75
- { value: "monthly", label: en("Monthly") },
76
- { value: "weekly", label: en("Weekly") },
77
- ],
78
- },
79
- ],
80
- },
81
- ...(emailQuestion
82
- ? [
83
- {
84
- key: "contact",
85
- type: "field",
86
- copy: { title: en("Where do we send it?") },
87
- fields: [
88
- { name: "email", inputType: "email", required: true, mapsTo: "email", copy: { label: en("Email") } },
89
- ],
90
- },
91
- ]
92
- : []),
93
- ],
94
- recommendation: { key: "result", copy: { title: en("Your result") } },
95
- conversion: "lead",
96
- ...extra,
97
- } as ServedConfig;
98
- }
99
-
100
- function renderResults(cfg: ServedConfig): void {
101
- render(<ResultsClient config={cfg} locale="en" answers={ANSWERS} slug={SLUG} payload="v1-abc" />);
102
- }
103
-
104
- beforeEach(() => {
105
- mockSend.mockReset();
106
- window.sessionStorage.clear();
107
- });
108
-
109
- describe("AC-4 — the form shows only where the results page is the email step (decision 17)", () => {
110
- it("a lead magnet with no email question shows the form, and no 'Email me this plan'", () => {
111
- renderResults(config());
112
- expect(screen.getByTestId("flow-results-report")).toBeInTheDocument();
113
- expect(screen.queryByText("emailMePlan")).not.toBeInTheDocument();
114
- expect(screen.queryByTestId("flow-results-save")).not.toBeInTheDocument();
115
- expect(screen.queryByTestId("flow-frame-bar")).not.toBeInTheDocument();
116
- });
117
-
118
- it("a required email question in the walk: no form", () => {
119
- renderResults(config({}, true));
120
- expect(screen.queryByTestId("flow-results-report")).not.toBeInTheDocument();
121
- });
122
-
123
- it.each([
124
- ["conversion: none", { conversion: "none" }],
125
- ["no conversion key (an older API)", { conversion: undefined }],
126
- ])("%s: no form", (_label, extra) => {
127
- renderResults(config(extra));
128
- expect(screen.queryByTestId("flow-results-report")).not.toBeInTheDocument();
129
- });
130
- });
131
-
132
- describe("AC-4 — the heading, the button and the consent line (decisions 13, 18)", () => {
133
- it("reads resultsPage.formHeading and formButton when set", () => {
134
- renderResults(
135
- config({
136
- resultsPage: { formHeading: en("Get the playbook"), formButton: en("Send the playbook") },
137
- writtenReport: true,
138
- }),
139
- );
140
- expect(screen.getByRole("heading", { name: "Get the playbook" })).toBeInTheDocument();
141
- expect(screen.getByTestId("flow-results-report-send")).toHaveTextContent("Send the playbook");
142
- });
143
-
144
- it("defaults to the Written report heading when the switch is on", () => {
145
- renderResults(config({ writtenReport: true }));
146
- expect(screen.getByRole("heading", { name: "resultsFormHeadingReport" })).toBeInTheDocument();
147
- expect(screen.getByTestId("flow-results-report-send")).toHaveTextContent("resultsFormButton");
148
- });
149
-
150
- it.each([
151
- ["off", { writtenReport: false }],
152
- ["absent", {}],
153
- ])("defaults to the results heading when the switch is %s", (_label, extra) => {
154
- renderResults(config(extra));
155
- expect(screen.getByRole("heading", { name: "resultsFormHeadingResults" })).toBeInTheDocument();
156
- });
157
-
158
- it("renders the consent line under the field", () => {
159
- renderResults(config());
160
- const form = screen.getByTestId("flow-results-report");
161
- const field = screen.getByLabelText("resultsFormHeadingResults");
162
- const consent = screen.getByText("resultsConsent");
163
- expect(form).toContainElement(consent);
164
- expect(field.compareDocumentPosition(consent) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
165
- });
166
- });
167
-
168
- describe("AC-4 — Send it converts through the results-email action", () => {
169
- it("calls sendResultsEmailAction once with the answers, the email, the locale and the stored session id, then shows Sent to {email}", async () => {
170
- window.sessionStorage.setItem(STORAGE_KEY, "fs_walk_1");
171
- mockSend.mockResolvedValue({ ok: true });
172
- const user = userEvent.setup();
173
- renderResults(config());
174
-
175
- expect(mockSend).not.toHaveBeenCalled();
176
- await user.type(screen.getByLabelText("resultsFormHeadingResults"), "a@b.co");
177
- await user.click(screen.getByTestId("flow-results-report-send"));
178
-
179
- expect(mockSend).toHaveBeenCalledTimes(1);
180
- expect(mockSend).toHaveBeenCalledWith(SLUG, {
181
- answers: ANSWERS,
182
- email: "a@b.co",
183
- locale: "en",
184
- sessionId: "fs_walk_1",
185
- });
186
- const sent = await screen.findByTestId("flow-results-report-saved");
187
- expect(sent).toHaveTextContent("resultsSent:email=a@b.co");
188
- expect(screen.queryByTestId("flow-results-report-send")).not.toBeInTheDocument();
189
- expect(screen.queryByLabelText("resultsFormHeadingResults")).not.toBeInTheDocument();
190
- });
191
-
192
- it("with no card the phone dock carries Send it as a submit bound to the form, and the dock leaves after sending", async () => {
193
- mockSend.mockResolvedValue({ ok: true });
194
- const user = userEvent.setup();
195
- renderResults(config());
196
-
197
- const docked = screen.getByTestId("flow-results-dock-send");
198
- expect(docked).toHaveAttribute("type", "submit");
199
- expect(docked).toHaveAttribute("form", "flow-results-email");
200
- expect(docked).toHaveTextContent("resultsFormButton");
201
- // The in-form button is the `md:` one; the dock is the phone's.
202
- expect(screen.getByTestId("flow-results-report-send-slot").className).toBe("hidden md:contents");
203
-
204
- await user.type(screen.getByLabelText("resultsFormHeadingResults"), "a@b.co");
205
- await user.click(docked);
206
-
207
- expect(mockSend).toHaveBeenCalledTimes(1);
208
- await screen.findByTestId("flow-results-report-saved");
209
- expect(screen.queryByTestId("flow-results-dock")).not.toBeInTheDocument();
210
- });
211
-
212
- it("a docked submit with an empty field focuses the field and shows the message; the sent state keeps the heading", async () => {
213
- mockSend.mockResolvedValue({ ok: true });
214
- const user = userEvent.setup();
215
- renderResults(config());
216
-
217
- await user.click(screen.getByTestId("flow-results-dock-send"));
218
- expect(mockSend).not.toHaveBeenCalled();
219
- const field = screen.getByLabelText("resultsFormHeadingResults");
220
- expect(field).toHaveFocus();
221
- expect(screen.getByRole("alert")).toHaveTextContent("validationInvalidEmail");
222
-
223
- await user.type(field, "a@b.co");
224
- await user.click(screen.getByTestId("flow-results-dock-send"));
225
- const sent = await screen.findByTestId("flow-results-report-saved");
226
- expect(within(sent).getByRole("heading", { level: 2 })).toHaveTextContent("resultsFormHeadingResults");
227
- expect(sent).toHaveTextContent("resultsSent:email=a@b.co");
228
- });
229
-
230
- it("a server failure focuses the field so a docked submitter sees the message", async () => {
231
- mockSend.mockResolvedValue({ ok: false, reason: "submit_failed" });
232
- const user = userEvent.setup();
233
- renderResults(config());
234
-
235
- await user.type(screen.getByLabelText("resultsFormHeadingResults"), "a@b.co");
236
- await user.click(screen.getByTestId("flow-results-dock-send"));
237
- await screen.findByRole("alert");
238
- expect(screen.getByLabelText("resultsFormHeadingResults")).toHaveFocus();
239
- });
240
-
241
- it("omits sessionId when no entry exists; an invalid address sends nothing", async () => {
242
- mockSend.mockResolvedValue({ ok: true });
243
- const user = userEvent.setup();
244
- renderResults(config());
245
-
246
- await user.type(screen.getByLabelText("resultsFormHeadingResults"), "nope");
247
- await user.click(screen.getByTestId("flow-results-report-send"));
248
- expect(screen.getByRole("alert")).toHaveTextContent("validationInvalidEmail");
249
- expect(mockSend).not.toHaveBeenCalled();
250
-
251
- await user.clear(screen.getByLabelText("resultsFormHeadingResults"));
252
- await user.type(screen.getByLabelText("resultsFormHeadingResults"), "a@b.co");
253
- await user.click(screen.getByTestId("flow-results-report-send"));
254
- expect(mockSend.mock.calls[0]?.[1]).toEqual({ answers: ANSWERS, email: "a@b.co", locale: "en" });
255
- });
256
-
257
- it.each([
258
- ["a failure", { ok: false, kind: "unavailable" }, "submitError"],
259
- ["a rate limit", { ok: false, kind: "rate_limited", retryAfterSeconds: 9 }, "rateLimited:seconds=9"],
260
- ])("%s keeps the form with its message", async (_label, outcome, message) => {
261
- mockSend.mockResolvedValue(outcome);
262
- const user = userEvent.setup();
263
- renderResults(config());
264
-
265
- await user.type(screen.getByLabelText("resultsFormHeadingResults"), "a@b.co");
266
- await user.click(screen.getByTestId("flow-results-report-send"));
267
-
268
- expect(await screen.findByRole("alert")).toHaveTextContent(message);
269
- expect(screen.getByTestId("flow-results-report")).toBeInTheDocument();
270
- expect(screen.queryByTestId("flow-results-report-saved")).not.toBeInTheDocument();
271
- expect(screen.getByTestId("flow-results-report-send")).not.toBeDisabled();
272
- });
273
-
274
- it("a thrown action is the submit error, never an unhandled rejection", async () => {
275
- mockSend.mockRejectedValue(new TypeError("fetch failed"));
276
- const user = userEvent.setup();
277
- renderResults(config());
278
-
279
- await user.type(screen.getByLabelText("resultsFormHeadingResults"), "a@b.co");
280
- await user.click(screen.getByTestId("flow-results-report-send"));
281
-
282
- expect(await screen.findByRole("alert")).toHaveTextContent("submitError");
283
- });
284
- });