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,376 +0,0 @@
1
- // oss: false
2
- /**
3
- * Tests for FlowStepperClient's segment-keyed completion redirect (#3960 D5).
4
- *
5
- * AC1 — two different segments navigate to two different
6
- * /{locale}/thanks/{slug} paths.
7
- * AC2 — the redirect URL carries no PII: the mocked FlowStepper submits a
8
- * step whose values contain an email, a name, a phone number, and
9
- * free text, and the pushed URL (a) matches the no-query/no-fragment
10
- * shape and (b) contains none of those submitted substrings — proving
11
- * the wiring, not just the resolver, never routes a form value into
12
- * the URL.
13
- * AC4 — backward compatibility: no `thankYou` block on the config never
14
- * navigates (no `onCompleted` reaches FlowStepper at all); no
15
- * `segment` on a `thankYou`-bearing flow resolves to `default`.
16
- *
17
- * `@working-theory/ui-signal-collectors`'s FlowStepper is mocked as a minimal
18
- * stub that calls the real `onSubmitStep`/`onCompleted` props it receives —
19
- * FlowStepper's OWN submission/onCompleted-firing behavior is already covered
20
- * by its own package test
21
- * (packages-paid/ui-signal-collectors/src/sections/__tests__/FlowStepper.test.tsx);
22
- * this file is scoped to FlowStepperClient's own responsibility — the
23
- * Server Action binding and the onCompleted → router.push wiring.
24
- */
25
- import { render, screen } from "@testing-library/react";
26
- import userEvent from "@testing-library/user-event";
27
- import type { FlowConfig } from "@working-theory/validation";
28
- import type { ReactElement } from "react";
29
-
30
- const mockPush = jest.fn();
31
- jest.mock("next/navigation", () => ({
32
- useRouter: () => ({ push: mockPush }),
33
- }));
34
-
35
- jest.mock("next-intl", () => ({
36
- useTranslations: () => (key: string) => key,
37
- useMessages: () => ({}),
38
- }));
39
-
40
- // FlowStepperClient binds onSubmitStep directly to this Server Action, and
41
- // the boundary under test here is the onCompleted -> router.push wiring, not
42
- // the action itself (covered by flow.actions.test.ts); internal-module mock
43
- // is the narrowest possible scope.
44
- // eslint-disable-next-line no-restricted-syntax -- see comment above
45
- jest.mock("../flow.actions", () => ({
46
- submitFlowStepAction: jest.fn(),
47
- }));
48
-
49
- interface MockFlowStepperProps {
50
- onSubmitStep: (payload: {
51
- stepKey: string;
52
- values: Record<string, unknown>;
53
- locale?: string;
54
- }) => Promise<{
55
- ok: boolean;
56
- response?: { completed: boolean; segment?: string };
57
- }>;
58
- onCompleted?: (result: { segment?: string }) => void;
59
- }
60
-
61
- // The PII-laden payload a real form submission would carry — proves AC2 by
62
- // construction: onCompleted only ever receives `{ segment }` downstream, so
63
- // none of this can reach the pushed URL.
64
- const PII_PAYLOAD = {
65
- email: "jane@example.com",
66
- name: "Jane Doe",
67
- phone: "555-123-4567",
68
- message: "Please reach out about the enterprise plan as soon as possible",
69
- };
70
-
71
- let capturedOnCompleted: MockFlowStepperProps["onCompleted"];
72
- // #11013 AC-1 — every prop the client hands the stepper, for the forwarding cases.
73
- let capturedProps: Record<string, unknown> | undefined;
74
-
75
- jest.mock("@working-theory/ui-signal-collectors", () => ({
76
- FlowStepper: (props: MockFlowStepperProps & Record<string, unknown>) => {
77
- capturedOnCompleted = props.onCompleted;
78
- capturedProps = props;
79
- async function handleSubmit(): Promise<void> {
80
- const result = await props.onSubmitStep({
81
- stepKey: "contact",
82
- values: PII_PAYLOAD,
83
- locale: "en",
84
- });
85
- if (result.ok && result.response?.completed) {
86
- props.onCompleted?.({
87
- ...(result.response.segment !== undefined
88
- ? { segment: result.response.segment }
89
- : {}),
90
- });
91
- }
92
- }
93
- return require("react").createElement(
94
- "button",
95
- { "data-testid": "mock-submit", onClick: handleSubmit },
96
- "Submit",
97
- ) as ReactElement;
98
- },
99
- }));
100
-
101
- import { submitFlowStepAction } from "../flow.actions";
102
- import { FlowStepperClient } from "../FlowStepperClient";
103
-
104
- const mockSubmitFlowStepAction = submitFlowStepAction as jest.MockedFunction<
105
- typeof submitFlowStepAction
106
- >;
107
-
108
- function thankYouFlowConfig(): FlowConfig {
109
- return {
110
- slug: "get-a-quote",
111
- defaultLocale: "en",
112
- steps: [
113
- {
114
- key: "contact",
115
- type: "field",
116
- copy: { title: { en: "Let's get started" } },
117
- fields: [
118
- {
119
- name: "email",
120
- inputType: "email",
121
- required: true,
122
- copy: { label: { en: "Email" } },
123
- },
124
- ],
125
- },
126
- ],
127
- thankYou: {
128
- default: "flow-thanks",
129
- bySegment: {
130
- qualified: "flow-thanks-qualified",
131
- standard: "flow-thanks",
132
- },
133
- },
134
- } as FlowConfig;
135
- }
136
-
137
- function noThankYouFlowConfig(): FlowConfig {
138
- const { thankYou: _thankYou, ...rest } = thankYouFlowConfig();
139
- return rest as FlowConfig;
140
- }
141
-
142
- beforeEach(() => {
143
- mockPush.mockClear();
144
- mockSubmitFlowStepAction.mockClear();
145
- capturedOnCompleted = undefined;
146
- capturedProps = undefined;
147
- });
148
-
149
- describe("FlowStepperClient — forwards brand, exit and presentation to FlowStepper (#11013 AC-1)", () => {
150
- const brand = { logomark: <span data-testid="mark" />, wordmark: <span data-testid="word" />, title: "Quote" };
151
- const exit = { href: "/en/flows/x", label: "Exit" };
152
-
153
- it("forwards each unchanged", () => {
154
- render(
155
- <FlowStepperClient
156
- config={noThankYouFlowConfig()}
157
- locale="en"
158
- slug="get-a-quote"
159
- brand={brand}
160
- exit={exit}
161
- presentation="full"
162
- />,
163
- );
164
- expect(capturedProps?.["brand"]).toBe(brand);
165
- expect(capturedProps?.["exit"]).toBe(exit);
166
- expect(capturedProps?.["presentation"]).toBe("full");
167
- expect(capturedProps).not.toHaveProperty("header");
168
- });
169
-
170
- it("omits each when absent, so the stepper's own defaults apply", () => {
171
- render(<FlowStepperClient config={noThankYouFlowConfig()} locale="en" slug="get-a-quote" />);
172
- expect(capturedProps).not.toHaveProperty("brand");
173
- expect(capturedProps).not.toHaveProperty("exit");
174
- expect(capturedProps).not.toHaveProperty("presentation");
175
- });
176
- });
177
-
178
- describe("FlowStepperClient — segment-keyed completion redirect (AC1)", () => {
179
- it("navigates to the segment's mapped thank-you page", async () => {
180
- const user = userEvent.setup();
181
- mockSubmitFlowStepAction.mockResolvedValueOnce({
182
- ok: true,
183
- response: {
184
- sessionId: "sess1",
185
- landed: "contact",
186
- nextStepKey: null,
187
- completed: true,
188
- segment: "qualified",
189
- },
190
- });
191
-
192
- render(
193
- <FlowStepperClient
194
- config={thankYouFlowConfig()}
195
- locale="en"
196
- slug="get-a-quote"
197
- />,
198
- );
199
- await user.click(screen.getByTestId("mock-submit"));
200
-
201
- expect(mockPush).toHaveBeenCalledWith("/en/thanks/flow-thanks-qualified");
202
- });
203
-
204
- it("a DIFFERENT segment navigates to a DIFFERENT thank-you page", async () => {
205
- const user = userEvent.setup();
206
- mockSubmitFlowStepAction.mockResolvedValueOnce({
207
- ok: true,
208
- response: {
209
- sessionId: "sess1",
210
- landed: "contact",
211
- nextStepKey: null,
212
- completed: true,
213
- segment: "standard",
214
- },
215
- });
216
-
217
- render(
218
- <FlowStepperClient
219
- config={thankYouFlowConfig()}
220
- locale="en"
221
- slug="get-a-quote"
222
- />,
223
- );
224
- await user.click(screen.getByTestId("mock-submit"));
225
-
226
- expect(mockPush).toHaveBeenCalledWith("/en/thanks/flow-thanks");
227
- });
228
- });
229
-
230
- describe("FlowStepperClient — no PII in the redirect URL (AC2)", () => {
231
- it("the pushed URL matches the no-query/no-fragment shape and carries none of the submitted PII substrings", async () => {
232
- const user = userEvent.setup();
233
- mockSubmitFlowStepAction.mockResolvedValueOnce({
234
- ok: true,
235
- response: {
236
- sessionId: "sess1",
237
- landed: "contact",
238
- nextStepKey: null,
239
- completed: true,
240
- segment: "qualified",
241
- },
242
- });
243
-
244
- render(
245
- <FlowStepperClient
246
- config={thankYouFlowConfig()}
247
- locale="en"
248
- slug="get-a-quote"
249
- />,
250
- );
251
- await user.click(screen.getByTestId("mock-submit"));
252
-
253
- // Prove the PII actually reached onSubmitStep (the wiring propagates
254
- // real form data as usual) — the interesting assertion is that NONE of
255
- // it reaches the push call below.
256
- expect(mockSubmitFlowStepAction).toHaveBeenCalledWith(
257
- "get-a-quote",
258
- expect.objectContaining({ values: PII_PAYLOAD }),
259
- );
260
-
261
- expect(mockPush).toHaveBeenCalledTimes(1);
262
- const pushedUrl = mockPush.mock.calls[0]?.[0] as string;
263
- expect(pushedUrl).toMatch(/^\/[A-Za-z-]+\/thanks\/[a-z0-9-]+$/);
264
- for (const value of Object.values(PII_PAYLOAD)) {
265
- expect(pushedUrl).not.toContain(value);
266
- }
267
- });
268
- });
269
-
270
- describe("FlowStepperClient — locale validated before redirect interpolation (AILK #4707)", () => {
271
- // NEXT_PUBLIC_ENABLED_LOCALES is unset in this test env, so the
272
- // configured-locale set the component validates against is ["en"]
273
- // (mirrors middleware.test.ts's own "not set in test env" baseline).
274
- it("falls back to the default locale when the [locale] route param is not in the configured set", async () => {
275
- const user = userEvent.setup();
276
- mockSubmitFlowStepAction.mockResolvedValueOnce({
277
- ok: true,
278
- response: {
279
- sessionId: "sess1",
280
- landed: "contact",
281
- nextStepKey: null,
282
- completed: true,
283
- segment: "qualified",
284
- },
285
- });
286
-
287
- render(
288
- <FlowStepperClient
289
- config={thankYouFlowConfig()}
290
- locale="fr"
291
- slug="get-a-quote"
292
- />,
293
- );
294
- await user.click(screen.getByTestId("mock-submit"));
295
-
296
- expect(mockPush).toHaveBeenCalledWith("/en/thanks/flow-thanks-qualified");
297
- });
298
-
299
- it("falls back to the default locale for a malformed/unexpected locale segment", async () => {
300
- const user = userEvent.setup();
301
- mockSubmitFlowStepAction.mockResolvedValueOnce({
302
- ok: true,
303
- response: {
304
- sessionId: "sess1",
305
- landed: "contact",
306
- nextStepKey: null,
307
- completed: true,
308
- segment: "qualified",
309
- },
310
- });
311
-
312
- render(
313
- <FlowStepperClient
314
- config={thankYouFlowConfig()}
315
- locale="../evil"
316
- slug="get-a-quote"
317
- />,
318
- );
319
- await user.click(screen.getByTestId("mock-submit"));
320
-
321
- expect(mockPush).toHaveBeenCalledWith("/en/thanks/flow-thanks-qualified");
322
- });
323
- });
324
-
325
- describe("FlowStepperClient — backward compatibility (AC4)", () => {
326
- it("never navigates when the config carries no thankYou block", async () => {
327
- const user = userEvent.setup();
328
- mockSubmitFlowStepAction.mockResolvedValueOnce({
329
- ok: true,
330
- response: {
331
- sessionId: "sess1",
332
- landed: "contact",
333
- nextStepKey: null,
334
- completed: true,
335
- segment: "qualified",
336
- },
337
- });
338
-
339
- render(
340
- <FlowStepperClient
341
- config={noThankYouFlowConfig()}
342
- locale="en"
343
- slug="get-a-quote"
344
- />,
345
- );
346
-
347
- expect(capturedOnCompleted).toBeUndefined();
348
-
349
- await user.click(screen.getByTestId("mock-submit"));
350
- expect(mockPush).not.toHaveBeenCalled();
351
- });
352
-
353
- it("falls back to thankYou.default when the completion carries no segment", async () => {
354
- const user = userEvent.setup();
355
- mockSubmitFlowStepAction.mockResolvedValueOnce({
356
- ok: true,
357
- response: {
358
- sessionId: "sess1",
359
- landed: "contact",
360
- nextStepKey: null,
361
- completed: true,
362
- },
363
- });
364
-
365
- render(
366
- <FlowStepperClient
367
- config={thankYouFlowConfig()}
368
- locale="en"
369
- slug="get-a-quote"
370
- />,
371
- );
372
- await user.click(screen.getByTestId("mock-submit"));
373
-
374
- expect(mockPush).toHaveBeenCalledWith("/en/thanks/flow-thanks");
375
- });
376
- });
@@ -1,306 +0,0 @@
1
- // oss: false
2
- /**
3
- * Tests for FlowStepperClient's per-tier thank-you redirect on a scored
4
- * recommending flow (#10616 D4).
5
- *
6
- * A SEPARATE file from the six existing `FlowStepperClient.*.test.tsx`
7
- * suites, which stay UNEDITED as the AC-4 regression floor. It mocks
8
- * `FlowStepper` the way `FlowStepperClient.permalink.test.tsx` does — a stub
9
- * that captures the `onSubmitStep`/`onCompleted` props — because this file's
10
- * scope is the client's own completion wiring, not the stepper.
11
- *
12
- * AC-3(b) — a finished walk whose scored tier carries a `thankYou` slug
13
- * pushes exactly `/<locale>/thanks/<slug>`, ahead of the results
14
- * permalink; the URL carries no submitted value, no segmentation answer
15
- * and no session id; an unknown locale falls back to the default.
16
- * AC-3(a) — the client scores with EMPTY flags (the server's input), so a
17
- * flag-gated tier never wins even when the walk's own `flags` would set it.
18
- * AC-3(c) — a flow with tier slugs but no `thankYou` and no `offers` still
19
- * receives `onCompleted`.
20
- * AC-4 — a tier with no slug pushes today's permalink; a `thankYou`-only
21
- * flow pushes `thankYou.default`; an `ending` still wins (no `onCompleted`).
22
- */
23
- import { render } from "@testing-library/react";
24
- import type { FlowConfig } from "@working-theory/validation";
25
- import { decodePermalink } from "@working-theory/validation";
26
- import type { ReactElement } from "react";
27
-
28
- const mockPush = jest.fn();
29
- jest.mock("next/navigation", () => ({
30
- useRouter: () => ({ push: mockPush }),
31
- }));
32
-
33
- jest.mock("next-intl", () => ({
34
- useTranslations: () => (key: string) => key,
35
- useMessages: () => ({}),
36
- }));
37
-
38
- // FlowStepperClient binds onSubmitStep directly to this Server Action, and
39
- // the boundary under test here is the onCompleted -> router.push wiring, not
40
- // the action itself (covered by flow.actions.test.ts) — mirrors the sibling
41
- // suites' identical narrow-scope justification.
42
- // eslint-disable-next-line no-restricted-syntax -- see comment above
43
- jest.mock("../flow.actions", () => ({
44
- submitFlowStepAction: jest.fn(),
45
- }));
46
-
47
- interface MockFlowStepperProps {
48
- onSubmitStep: (payload: {
49
- stepKey: string;
50
- values: Record<string, unknown>;
51
- locale?: string;
52
- }) => Promise<{
53
- ok: boolean;
54
- kind?: string;
55
- response?: { completed: boolean; segment?: string };
56
- }>;
57
- onCompleted?: (result: { segment?: string }) => void;
58
- }
59
-
60
- let captured: MockFlowStepperProps | undefined;
61
-
62
- jest.mock("@working-theory/ui-signal-collectors", () => ({
63
- FlowStepper: (props: MockFlowStepperProps) => {
64
- captured = props;
65
- return require("react").createElement("div", {
66
- "data-testid": "mock-flow-stepper",
67
- }) as ReactElement;
68
- },
69
- }));
70
-
71
- import { submitFlowStepAction } from "../flow.actions";
72
- import { FlowStepperClient } from "../FlowStepperClient";
73
-
74
- const mockSubmitFlowStepAction = submitFlowStepAction as jest.MockedFunction<
75
- typeof submitFlowStepAction
76
- >;
77
-
78
- const SLUG = "founder-diagnostic";
79
- const SESSION_ID = "sess-1a2b3c";
80
-
81
- type Scoring = NonNullable<FlowConfig["scoring"]>;
82
-
83
- const PATH_A_ANSWERS = { revenue: "1m-plus", timing: "now" };
84
- const PATH_B_ANSWERS = { revenue: "under-500k", timing: "exploring" };
85
- const PII_PAYLOAD = {
86
- email: "jane@example.com",
87
- name: "Jane Doe",
88
- phone: "555-123-4567",
89
- message: "Please reach out about the enterprise plan as soon as possible",
90
- };
91
-
92
- /**
93
- * path_a: revenue in the top bands AND timing not "exploring" — a rule over
94
- * two answers, which `thankYou.bySegment` cannot express; path_b is the
95
- * default. Each tier carries its own ThankYouPage slug.
96
- */
97
- function tierScoring(): Scoring {
98
- return {
99
- version: 1,
100
- points: [
101
- {
102
- name: "revenue_points",
103
- question: "revenue",
104
- kind: "optionWeights",
105
- weights: { "under-500k": 0, "500k-1m": 1, "1m-plus": 2 },
106
- },
107
- ],
108
- scores: { total: { sum: ["revenue_points"] } },
109
- tiers: [
110
- {
111
- key: "path_a",
112
- when: {
113
- allOf: [
114
- { answer: "revenue", in: ["500k-1m", "1m-plus"] },
115
- { not: { answer: "timing", eq: "exploring" } },
116
- ],
117
- },
118
- thankYou: "path-a-thanks",
119
- },
120
- { key: "path_b", when: { answer: "timing", eq: "exploring" }, thankYou: "path-b-thanks" },
121
- ],
122
- default: "path_b",
123
- };
124
- }
125
-
126
- /** A recommending flow — `offers` plus the scoring above — whose field step
127
- * submits an email, a name, a phone number and free text. */
128
- function scoredFlowConfig(overrides: Partial<FlowConfig> = {}): FlowConfig {
129
- return {
130
- slug: SLUG,
131
- defaultLocale: "en",
132
- mode: "recommending",
133
- steps: [
134
- {
135
- key: "fit",
136
- type: "segmentation",
137
- copy: { title: { en: "Fit" } },
138
- questions: [
139
- {
140
- name: "revenue",
141
- options: [
142
- { value: "under-500k", label: { en: "Under $500K" } },
143
- { value: "500k-1m", label: { en: "$500K–$1M" } },
144
- { value: "1m-plus", label: { en: "$1M+" } },
145
- ],
146
- },
147
- {
148
- name: "timing",
149
- options: [
150
- { value: "now", label: { en: "Now" } },
151
- { value: "exploring", label: { en: "Just exploring" } },
152
- ],
153
- },
154
- ],
155
- },
156
- {
157
- key: "contact",
158
- type: "field",
159
- copy: { title: { en: "Contact" } },
160
- fields: [
161
- { name: "email", inputType: "email", required: true, copy: { label: { en: "Email" } } },
162
- { name: "name", inputType: "text", required: true, copy: { label: { en: "Name" } } },
163
- { name: "phone", inputType: "tel", copy: { label: { en: "Phone" } } },
164
- { name: "message", inputType: "textarea", copy: { label: { en: "Message" } } },
165
- ],
166
- },
167
- ],
168
- offers: [
169
- {
170
- key: "call",
171
- copy: { name: { en: "A call" } },
172
- price: { kind: "label", label: { en: "Free" } },
173
- rules: [{ when: { answer: "revenue", eq: "1m-plus" }, reason: { en: "Ready" } }],
174
- },
175
- ],
176
- scoring: tierScoring(),
177
- ...overrides,
178
- } as FlowConfig;
179
- }
180
-
181
- /** Render the client, submit the segmentation step then the PII-laden field
182
- * step (the second completing the walk), and fire `onCompleted`. */
183
- async function completeWalk(
184
- config: FlowConfig,
185
- answers: Record<string, string>,
186
- locale = "en",
187
- ): Promise<void> {
188
- mockSubmitFlowStepAction
189
- .mockResolvedValueOnce({
190
- ok: true,
191
- response: { sessionId: SESSION_ID, landed: "fit", nextStepKey: "contact", completed: false },
192
- })
193
- .mockResolvedValueOnce({
194
- ok: true,
195
- response: { sessionId: SESSION_ID, landed: "contact", nextStepKey: null, completed: true },
196
- });
197
-
198
- render(<FlowStepperClient config={config} locale={locale} slug={SLUG} />);
199
-
200
- await captured!.onSubmitStep({ stepKey: "fit", values: answers, locale });
201
- await captured!.onSubmitStep({ stepKey: "contact", values: PII_PAYLOAD, locale });
202
- captured!.onCompleted?.({});
203
- }
204
-
205
- function pushedUrl(): string {
206
- expect(mockPush).toHaveBeenCalledTimes(1);
207
- return mockPush.mock.calls[0]?.[0] as string;
208
- }
209
-
210
- beforeEach(() => {
211
- mockPush.mockClear();
212
- mockSubmitFlowStepAction.mockClear();
213
- captured = undefined;
214
- window.sessionStorage.clear();
215
- });
216
-
217
- describe("FlowStepperClient — a scored tier's thank-you page replaces the permalink (#10616 AC-3(b))", () => {
218
- it("path-A answers push exactly /en/thanks/path-a-thanks", async () => {
219
- await completeWalk(scoredFlowConfig(), PATH_A_ANSWERS);
220
- expect(pushedUrl()).toBe("/en/thanks/path-a-thanks");
221
- });
222
-
223
- it("path-B answers push exactly /en/thanks/path-b-thanks", async () => {
224
- await completeWalk(scoredFlowConfig(), PATH_B_ANSWERS);
225
- expect(pushedUrl()).toBe("/en/thanks/path-b-thanks");
226
- });
227
-
228
- it("the pushed URL carries no submitted value, no segmentation answer and no session id", async () => {
229
- await completeWalk(scoredFlowConfig(), PATH_A_ANSWERS);
230
- // The PII reached onSubmitStep (the wiring forwards real form data) —
231
- // the assertion is that none of it reaches the push.
232
- expect(mockSubmitFlowStepAction).toHaveBeenCalledWith(
233
- SLUG,
234
- expect.objectContaining({ values: PII_PAYLOAD }),
235
- );
236
- const url = pushedUrl();
237
- expect(url).toMatch(/^\/[A-Za-z-]+\/thanks\/[a-z0-9-]+$/);
238
- for (const value of [
239
- ...Object.values(PII_PAYLOAD),
240
- ...Object.values(PATH_A_ANSWERS),
241
- SESSION_ID,
242
- ]) {
243
- expect(url).not.toContain(value);
244
- }
245
- });
246
-
247
- it("an unknown [locale] falls back to the default locale before interpolation", async () => {
248
- await completeWalk(scoredFlowConfig(), PATH_A_ANSWERS, "xx");
249
- expect(pushedUrl()).toBe("/en/thanks/path-a-thanks");
250
- });
251
- });
252
-
253
- describe("FlowStepperClient — the client scores with the server's empty flags (#10616 AC-3(a))", () => {
254
- it("a flag-gated first tier never wins, even when the walk's own flags would set it", async () => {
255
- const scoring = tierScoring();
256
- scoring.tiers = [
257
- { key: "flagged", when: { flag: "pre_launch" }, thankYou: "flagged-thanks" },
258
- { key: "path_b", when: { answer: "timing", eq: "exploring" }, thankYou: "path-b-thanks" },
259
- ];
260
- const config = scoredFlowConfig({
261
- flags: [{ name: "pre_launch", when: { answer: "timing", eq: "now" } }],
262
- scoring,
263
- });
264
- await completeWalk(config, PATH_A_ANSWERS);
265
- expect(pushedUrl()).toBe("/en/thanks/path-b-thanks");
266
- });
267
- });
268
-
269
- describe("FlowStepperClient — onCompleted is supplied for a flow with tier slugs alone (#10616 AC-3(c))", () => {
270
- it("mode recommending with scoring, no offers and no thankYou still receives onCompleted", () => {
271
- const { offers: _offers, ...noOffers } = scoredFlowConfig();
272
- render(<FlowStepperClient config={noOffers as FlowConfig} locale="en" slug={SLUG} />);
273
- expect(captured?.onCompleted).toBeDefined();
274
- });
275
- });
276
-
277
- describe("FlowStepperClient — no mapping is today's behavior (#10616 AC-4)", () => {
278
- it("(a) a tier with no slug pushes the results permalink, decodable to the segmentation answers", async () => {
279
- const scoring = tierScoring();
280
- delete scoring.tiers[1]!.thankYou;
281
- await completeWalk(scoredFlowConfig({ scoring }), PATH_B_ANSWERS);
282
-
283
- const match = pushedUrl().match(new RegExp(`^/en/flows/${SLUG}/results/(.+)$`));
284
- expect(match).not.toBeNull();
285
- const decoded = decodePermalink(match![1]!);
286
- expect(decoded.ok).toBe(true);
287
- if (!decoded.ok) return;
288
- expect(decoded.value.flowSlug).toBe(SLUG);
289
- expect(decoded.value.answers).toEqual(PATH_B_ANSWERS);
290
- });
291
-
292
- it("(b) a thankYou-only flow with no scoring pushes thankYou.default", async () => {
293
- const { mode: _mode, offers: _offers, scoring: _scoring, ...plain } = scoredFlowConfig();
294
- const config = { ...plain, thankYou: { default: "flow-thanks" } } as FlowConfig;
295
- await completeWalk(config, PATH_A_ANSWERS);
296
- expect(pushedUrl()).toBe("/en/thanks/flow-thanks");
297
- });
298
-
299
- it("(c) a flow with an ending and tier slugs is passed no onCompleted", () => {
300
- const config = scoredFlowConfig({
301
- ending: { default: { kind: "screen", headline: { en: "Thanks" } } },
302
- } as Partial<FlowConfig>);
303
- render(<FlowStepperClient config={config} locale="en" slug={SLUG} />);
304
- expect(captured?.onCompleted).toBeUndefined();
305
- });
306
- });