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,402 +0,0 @@
1
- // oss: false
2
- /**
3
- * One card, by decision 15's order, and the primary action that follows it
4
- * (#11013 spec E, D-G, D-H, D-K; AC-5).
5
- *
6
- * The page resolves the Product card for an `offering` link from the shown
7
- * set; `ResultsClient` resolves the Meeting card for an `appointment` link
8
- * from the scheduling seam (`ResultsMeetingContext`), which the scheduling
9
- * layout provides and a scaffold without scheduling never does. A by-result
10
- * card beats a link's card, and with neither the top fit renders as one
11
- * `RecommendationCard` — no second fit, no pairing, no side panel. With a
12
- * card its button is the primary and Send it is an outline button; with none
13
- * Send it is primary.
14
- *
15
- * Page mocks mirror `by-result.test.tsx`; client mocks mirror
16
- * `ResultsClient.no-commerce.test.tsx`.
17
- */
18
- import { readFileSync } from "node:fs";
19
- import { join } from "node:path";
20
-
21
- import { render, screen, within } from "@testing-library/react";
22
- import type { FlowConfig, FlowConversionLink } from "@working-theory/validation";
23
- import {
24
- encodePermalink,
25
- PERMALINK_VERSION,
26
- workspaceShownSetWireSchema,
27
- } from "@working-theory/validation";
28
- import type { ReactElement } from "react";
29
-
30
- const mockGet = jest.fn();
31
- const mockShown = jest.fn();
32
- jest.mock("@working-theory/api-client", () => ({
33
- __esModule: true,
34
- flows: { get: (...args: unknown[]) => mockGet(...args) },
35
- offerings: { shown: (...args: unknown[]) => mockShown(...args) },
36
- }));
37
-
38
- const mockRedirect = jest.fn((url: string) => {
39
- throw new Error(`NEXT_REDIRECT:${url}`);
40
- });
41
- jest.mock("next/navigation", () => ({
42
- __esModule: true,
43
- redirect: (url: string) => mockRedirect(url),
44
- }));
45
-
46
- // eslint-disable-next-line no-restricted-syntax -- the boundary under test is the render, not the action (save.actions.test.ts)
47
- jest.mock("../../../save.actions", () => ({ sendResultsEmailAction: jest.fn() }));
48
-
49
- jest.mock("next-intl", () => ({
50
- __esModule: true,
51
- useTranslations:
52
- () =>
53
- (key: string, values?: Record<string, unknown>): string =>
54
- values === undefined
55
- ? key
56
- : `${key}:${Object.entries(values)
57
- .map(([k, v]) => `${k}=${String(v)}`)
58
- .join(",")}`,
59
- useMessages: () => ({}),
60
- }));
61
-
62
- import Page from "../page";
63
- import type { ResultsMeeting } from "../meeting-seam";
64
- import { ResultsMeetingContext } from "../meeting-seam";
65
- import type { ResultsConversionCard, ResultsOfferingCard } from "../ResultsClient";
66
- import { ResultsClient } from "../ResultsClient";
67
-
68
- const SLUG = "readiness";
69
- const en = (s: string) => ({ en: s });
70
- const ANSWERS = { cadence: "weekly" };
71
-
72
- type ServedConfig = FlowConfig & {
73
- conversion?: "none" | "lead" | "lead-link" | "user";
74
- conversionLink?: FlowConversionLink;
75
- };
76
-
77
- /** A recommending magnet with no rows and no ending; `offers` only when asked. */
78
- function config(extra: Record<string, unknown> = {}, withOffers = false): ServedConfig {
79
- return {
80
- slug: SLUG,
81
- defaultLocale: "en",
82
- mode: "recommending",
83
- steps: [
84
- {
85
- key: "q0",
86
- type: "segmentation",
87
- copy: { title: en("How often do you ship?") },
88
- questions: [
89
- {
90
- name: "cadence",
91
- options: [
92
- { value: "monthly", label: en("Monthly") },
93
- { value: "weekly", label: en("Weekly") },
94
- ],
95
- },
96
- ],
97
- },
98
- ],
99
- ...(withOffers
100
- ? {
101
- offers: [
102
- {
103
- key: "pro",
104
- copy: { name: en("Pro") },
105
- price: { kind: "label", label: en("On request") },
106
- rules: [{ when: { answer: "cadence", eq: "weekly" }, reason: en("You ship weekly.") }],
107
- },
108
- {
109
- key: "consult",
110
- copy: { name: en("Consulting") },
111
- price: { kind: "label", label: en("Ask us") },
112
- rules: [{ when: { answer: "cadence", eq: "weekly" }, reason: en("Weekly shippers ask.") }],
113
- },
114
- ],
115
- pairings: [
116
- {
117
- offers: ["pro", "consult"],
118
- reason: en("Better together."),
119
- when: { answer: "cadence", eq: "weekly" },
120
- },
121
- ],
122
- }
123
- : {}),
124
- recommendation: { key: "result", copy: { title: en("Your result") } },
125
- conversion: "lead-link",
126
- ...extra,
127
- } as ServedConfig;
128
- }
129
-
130
- const SHOWN_SET = workspaceShownSetWireSchema.parse({
131
- productIds: ["prod_growth", "prod_scale"],
132
- recommended: { plan: null, addon: null },
133
- offerings: [
134
- {
135
- productId: "prod_growth",
136
- plan: "growth",
137
- name: "Growth",
138
- description: "Hands-on growth, every month.",
139
- marketingFeatures: ["Up to 40 hours a month", "Growth Hub"],
140
- unitLabel: null,
141
- note: null,
142
- termsNote: null,
143
- ailkGroup: "plan",
144
- ailkOrder: null,
145
- recommended: false,
146
- prices: [
147
- {
148
- priceId: "price_growth_monthly",
149
- lookupKey: "growth_monthly",
150
- plan: "growth",
151
- period: "monthly",
152
- interval: "month",
153
- amount: 120000,
154
- currency: "usd",
155
- },
156
- ],
157
- },
158
- {
159
- productId: "prod_scale",
160
- plan: "scale",
161
- name: "Scale",
162
- description: null,
163
- marketingFeatures: [],
164
- unitLabel: null,
165
- note: null,
166
- termsNote: null,
167
- ailkGroup: "plan",
168
- ailkOrder: null,
169
- recommended: false,
170
- prices: [
171
- {
172
- priceId: "price_scale_monthly",
173
- lookupKey: "scale_monthly",
174
- plan: "scale",
175
- period: "monthly",
176
- interval: "month",
177
- amount: 250000,
178
- currency: "usd",
179
- },
180
- ],
181
- },
182
- ],
183
- state: "current",
184
- snapshotAt: "2026-11-04T12:00:00.000Z",
185
- });
186
-
187
- function page(cfg: ServedConfig): Promise<ReactElement> {
188
- mockGet.mockResolvedValue({ ok: true, status: 200, body: cfg });
189
- return Page({
190
- params: Promise.resolve({
191
- locale: "en",
192
- slug: SLUG,
193
- payload: encodePermalink({ version: PERMALINK_VERSION, flowSlug: SLUG, answers: ANSWERS }),
194
- }),
195
- });
196
- }
197
-
198
- const INTRO: ResultsMeeting = {
199
- slug: "intro",
200
- title: "Intro",
201
- description: "Quick intro meeting",
202
- href: "/en/meet/intro",
203
- bookLabel: "Book 15 min",
204
- };
205
-
206
- function renderClient(
207
- cfg: ServedConfig,
208
- extra: { offeringCard?: ResultsOfferingCard; conversionCard?: ResultsConversionCard } = {},
209
- meeting?: ResultsMeeting,
210
- ): void {
211
- const client = (
212
- <ResultsClient config={cfg} locale="en" answers={ANSWERS} slug={SLUG} payload="v1-abc" {...extra} />
213
- );
214
- render(
215
- meeting !== undefined ? (
216
- <ResultsMeetingContext.Provider value={meeting}>{client}</ResultsMeetingContext.Provider>
217
- ) : (
218
- client
219
- ),
220
- );
221
- }
222
-
223
- const BRAND_FILL = "bg-(--color-brand)";
224
- const OUTLINE_FILL = "bg-transparent";
225
-
226
- beforeAll(() => {
227
- jest.useFakeTimers({ now: new Date("2026-11-04T12:00:00.000Z") });
228
- });
229
-
230
- afterAll(() => {
231
- jest.useRealTimers();
232
- });
233
-
234
- beforeEach(() => {
235
- // The page shares its shown-set read for 15 s; each case starts later.
236
- jest.setSystemTime(Date.now() + 16_000);
237
- mockGet.mockReset();
238
- mockShown.mockReset();
239
- mockRedirect.mockClear();
240
- window.sessionStorage.clear();
241
- mockShown.mockResolvedValue({ ok: true, status: 200, body: { status: "shown", shownSet: SHOWN_SET } });
242
- });
243
-
244
- describe("AC-5 — Email links to an offering: the Product card (decision 14)", () => {
245
- it("renders the shown product's name, price, description, features under What's included, and Get Started to /pricing?plan=", async () => {
246
- render(await page(config({ conversionLink: { kind: "offering", id: "growth" } })));
247
- expect(mockRedirect).not.toHaveBeenCalled();
248
- const card = screen.getByTestId("flow-results-card");
249
- expect(within(card).getByRole("heading", { name: "Growth" })).toBeInTheDocument();
250
- expect(within(card).getByTestId("flow-results-card-price")).toHaveTextContent("monthly:amount=$1,200");
251
- expect(within(card).getByTestId("flow-results-card-description")).toHaveTextContent(
252
- "Hands-on growth, every month.",
253
- );
254
- expect(within(card).getByText("whatsIncluded")).toBeInTheDocument();
255
- const features = within(card).getAllByRole("listitem").map((li) => li.textContent);
256
- expect(features).toEqual(["Up to 40 hours a month", "Growth Hub"]);
257
- const action = within(card).getByTestId("flow-results-card-action");
258
- expect(action.getAttribute("href")).toBe("/en/pricing?plan=growth");
259
- expect(action).toHaveTextContent("getStarted");
260
- expect(within(card).getByText("priceCard.eyebrow")).toBeInTheDocument();
261
- expect(screen.getAllByTestId("flow-results-card")).toHaveLength(1);
262
- });
263
-
264
- it("with a null description no description line renders", async () => {
265
- render(await page(config({ conversionLink: { kind: "offering", id: "scale" } })));
266
- const card = screen.getByTestId("flow-results-card");
267
- expect(within(card).getByRole("heading", { name: "Scale" })).toBeInTheDocument();
268
- expect(within(card).queryByTestId("flow-results-card-description")).not.toBeInTheDocument();
269
- expect(within(card).queryByText("whatsIncluded")).not.toBeInTheDocument();
270
- });
271
-
272
- it("an offering not in the shown set gives no card", async () => {
273
- render(await page(config({ conversionLink: { kind: "offering", id: "draft" } })));
274
- expect(screen.getByTestId("flow-results")).toBeInTheDocument();
275
- expect(screen.queryByTestId("flow-results-card")).not.toBeInTheDocument();
276
- });
277
-
278
- it.each(["results", "magnet"])("a %s link gives no card and no shown read", async (kind) => {
279
- render(await page(config({ conversionLink: { kind, id: kind === "results" ? "flow_12345678-1234-1234-1234-123456789abc" : "other" } })));
280
- expect(screen.queryByTestId("flow-results-card")).not.toBeInTheDocument();
281
- expect(mockShown).not.toHaveBeenCalled();
282
- });
283
- });
284
-
285
- describe("AC-5 — Email links to an appointment: the Meeting card from the scheduling seam (D-K)", () => {
286
- it("under the provider renders the meeting's title, description and a link to its page labelled with its bookLabel", () => {
287
- renderClient(config({ conversionLink: { kind: "appointment", id: "intro" } }), {}, INTRO);
288
- const card = screen.getByTestId("flow-results-card");
289
- expect(within(card).getByRole("heading", { name: "Intro" })).toBeInTheDocument();
290
- expect(within(card).getByTestId("flow-results-card-description")).toHaveTextContent("Quick intro meeting");
291
- const action = within(card).getByTestId("flow-results-card-action");
292
- expect(action.getAttribute("href")).toBe("/en/meet/intro");
293
- expect(action).toHaveTextContent("Book 15 min");
294
- expect(within(card).queryByTestId("flow-results-card-price")).not.toBeInTheDocument();
295
- });
296
-
297
- it("a slug the provider does not hold renders no card", () => {
298
- renderClient(config({ conversionLink: { kind: "appointment", id: "working" } }), {}, INTRO);
299
- expect(screen.queryByTestId("flow-results-card")).not.toBeInTheDocument();
300
- });
301
-
302
- it("a results link renders no card even with a meeting provided", () => {
303
- renderClient(config({ conversionLink: { kind: "results", id: "flow_12345678-1234-1234-1234-123456789abc" } }), {}, INTRO);
304
- expect(screen.queryByTestId("flow-results-card")).not.toBeInTheDocument();
305
- });
306
-
307
- it("no scheduling (no provider): an appointment link renders no Meeting card — the top fit renders instead", () => {
308
- renderClient(config({ conversionLink: { kind: "appointment", id: "intro" } }, true));
309
- expect(screen.queryByTestId("flow-results-card")).not.toBeInTheDocument();
310
- expect(screen.getByTestId("recommendation-card-pro")).toBeInTheDocument();
311
- });
312
- });
313
-
314
- describe("AC-5 — the signal-collectors files name no scheduling file", () => {
315
- const RESULTS_DIR = join(__dirname, "..");
316
- it.each(["page.tsx", "ResultsClient.tsx", "ResultsCard.tsx", "meeting-seam.ts"])(
317
- "%s imports neither lib/meetings nor the results layout",
318
- (file) => {
319
- const source = readFileSync(join(RESULTS_DIR, file), "utf8");
320
- expect(source).not.toMatch(/from "[^"]*lib\/meetings/);
321
- expect(source).not.toMatch(/from "\.\.\/layout"/);
322
- expect(source).not.toMatch(/from "\.\.\/ResultsMeetingsProvider"/);
323
- },
324
- );
325
- });
326
-
327
- describe("AC-5 — one card, by decision 15's order", () => {
328
- const OFFERING_CARD: ResultsOfferingCard = {
329
- offeringKey: "growth",
330
- title: "Growth (by result)",
331
- price: { amount: 120000, currency: "usd", period: "monthly" },
332
- href: "/en/pricing?plan=growth",
333
- };
334
- const PRODUCT_CARD: ResultsConversionCard = {
335
- kind: "product",
336
- name: "Scale (linked)",
337
- features: [],
338
- href: "/en/pricing?plan=scale",
339
- };
340
-
341
- it("a by-result offering row and a conversionLink together render only the by-result card", () => {
342
- renderClient(config({ conversionLink: { kind: "offering", id: "scale" } }, true), {
343
- offeringCard: OFFERING_CARD,
344
- conversionCard: PRODUCT_CARD,
345
- });
346
- const cards = screen.getAllByTestId("flow-results-card");
347
- expect(cards).toHaveLength(1);
348
- expect(within(cards[0]!).getByRole("heading", { name: "Growth (by result)" })).toBeInTheDocument();
349
- expect(screen.queryByText("Scale (linked)")).not.toBeInTheDocument();
350
- expect(screen.queryByTestId("recommendation-card-pro")).not.toBeInTheDocument();
351
- });
352
-
353
- it("a link's card beats the older offer", () => {
354
- renderClient(config({ conversionLink: { kind: "offering", id: "scale" } }, true), {
355
- conversionCard: PRODUCT_CARD,
356
- });
357
- expect(screen.getByTestId("flow-results-card")).toBeInTheDocument();
358
- expect(screen.queryByTestId("recommendation-card-pro")).not.toBeInTheDocument();
359
- });
360
-
361
- it("with neither, the top fit renders as one RecommendationCard and no other fit, pairing or side panel", () => {
362
- renderClient(config({}, true));
363
- expect(screen.getByTestId("recommendation-card-pro")).toBeInTheDocument();
364
- expect(screen.queryByTestId("recommendation-card-consult")).not.toBeInTheDocument();
365
- expect(screen.queryByTestId("recommendation-pairing")).not.toBeInTheDocument();
366
- expect(screen.queryByTestId("flow-side-panel-safe-default")).not.toBeInTheDocument();
367
- expect(screen.queryByTestId("flow-results-card")).not.toBeInTheDocument();
368
- expect(screen.getAllByTestId(/^recommendation-card-[a-z_]+$/)).toHaveLength(1);
369
- });
370
-
371
- it("with no fit and no link, no card renders", () => {
372
- renderClient(config());
373
- expect(screen.queryByTestId("flow-results-card")).not.toBeInTheDocument();
374
- expect(screen.queryAllByTestId(/^recommendation-card-[a-z_]+$/)).toHaveLength(0);
375
- });
376
- });
377
-
378
- describe("AC-5 — the primary action follows the card (decision 16)", () => {
379
- it("with a card, its button is the primary and Send it is an outline button", () => {
380
- renderClient(config({ conversionLink: { kind: "appointment", id: "intro" } }), {}, INTRO);
381
- expect(screen.getByTestId("flow-results-card-action").className).toContain(BRAND_FILL);
382
- // Decision 16 — below `md:` the dock carries the card's button; the card's own shows from `md:`.
383
- expect(screen.getByTestId("flow-results-card-action").parentElement?.className).toContain("hidden md:block");
384
- const send = screen.getByTestId("flow-results-report-send");
385
- expect(send.className).toContain(OUTLINE_FILL);
386
- expect(send.className).not.toContain(BRAND_FILL);
387
- });
388
-
389
- it("with no card, Send it is the primary", () => {
390
- renderClient(config());
391
- const send = screen.getByTestId("flow-results-report-send");
392
- expect(send.className).toContain(BRAND_FILL);
393
- expect(send.className).not.toContain(OUTLINE_FILL);
394
- });
395
-
396
- it("the card comes before the form in DOM order", () => {
397
- renderClient(config({ conversionLink: { kind: "appointment", id: "intro" } }), {}, INTRO);
398
- const card = screen.getByTestId("flow-results-card");
399
- const form = screen.getByTestId("flow-results-report");
400
- expect(card.compareDocumentPosition(form) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
401
- });
402
- });
@@ -1,293 +0,0 @@
1
- // oss: false
2
- /**
3
- * Tests for the recommender's landing on the results permalink (#9071 D3,
4
- * AC-2(a)).
5
- *
6
- * A recommending flow with an offer carrying `lookupKey` is an Offerings
7
- * recommender: its completed walk lands on `/<locale>/pricing?plan=<plan>`
8
- * while the first fit's Price is in the current shown set, else on
9
- * `/<locale>/pricing` with no badge. A flow with no such offer, or whose
10
- * first fit carries none, renders `ResultsClient` exactly as before with no
11
- * shown-set read (AC-3's `page.test.tsx` holds the legacy render unchanged).
12
- *
13
- * `redirect` throws `NEXT_REDIRECT:<url>` as in `page.test.tsx`; the clock is
14
- * jest's modern fake timers, moved 16 s between cases so the page's 15 s
15
- * shown-set read never carries over.
16
- */
17
- import { render, screen } from "@testing-library/react";
18
- import type { FlowConfig, WorkspaceShownSetWire } from "@working-theory/validation";
19
- import {
20
- encodePermalink,
21
- PERMALINK_VERSION,
22
- workspaceShownSetWireSchema,
23
- } from "@working-theory/validation";
24
- import type { ReactElement } from "react";
25
-
26
- const mockGet = jest.fn();
27
- const mockShown = jest.fn();
28
- jest.mock("@working-theory/api-client", () => ({
29
- __esModule: true,
30
- flows: { get: (...args: unknown[]) => mockGet(...args) },
31
- offerings: { shown: (...args: unknown[]) => mockShown(...args) },
32
- }));
33
-
34
- const mockRedirect = jest.fn((url: string) => {
35
- throw new Error(`NEXT_REDIRECT:${url}`);
36
- });
37
- jest.mock("next/navigation", () => ({
38
- __esModule: true,
39
- redirect: (url: string) => mockRedirect(url),
40
- }));
41
-
42
- jest.mock("next-intl", () => ({
43
- __esModule: true,
44
- useTranslations: () => (key: string) => key,
45
- useMessages: () => ({}),
46
- }));
47
-
48
- import Page from "../page";
49
-
50
- const SLUG = "recommender";
51
- const en = (s: string) => ({ en: s });
52
-
53
- type Offer = NonNullable<FlowConfig["offers"]>[number];
54
-
55
- function offer(key: string, eq: string, lookupKey?: string): Offer {
56
- return {
57
- key,
58
- copy: { name: en(key) },
59
- price: { kind: "label", label: en("$29 / month") },
60
- rules: [{ when: { answer: "team", eq }, reason: en(`Because ${eq}.`) }],
61
- ...(lookupKey !== undefined ? { lookupKey } : {}),
62
- };
63
- }
64
-
65
- function config(offers: unknown = [
66
- offer("starter", "solo", "starter_monthly"),
67
- offer("agency", "agency", "agency-pro_yearly"),
68
- ]): FlowConfig {
69
- return {
70
- slug: SLUG,
71
- defaultLocale: "en",
72
- mode: "recommending",
73
- steps: [
74
- {
75
- key: "q0",
76
- type: "segmentation",
77
- copy: { title: en("Who are you?") },
78
- questions: [
79
- {
80
- name: "team",
81
- options: [
82
- { value: "solo", label: en("Solo") },
83
- { value: "agency", label: en("Agency") },
84
- ],
85
- },
86
- ],
87
- },
88
- ],
89
- offers,
90
- } as FlowConfig;
91
- }
92
-
93
- function product(productId: string, plan: string, periods: Array<"monthly" | "yearly">) {
94
- return {
95
- productId,
96
- plan,
97
- name: plan,
98
- description: null,
99
- marketingFeatures: [],
100
- unitLabel: null,
101
- note: null,
102
- termsNote: null,
103
- ailkGroup: "plan" as const,
104
- ailkOrder: null,
105
- recommended: false,
106
- prices: periods.map((period) => ({
107
- priceId: `price_${plan}${period}`,
108
- lookupKey: `${plan}_${period}`,
109
- plan,
110
- period,
111
- interval: period === "monthly" ? ("month" as const) : ("year" as const),
112
- amount: 2900,
113
- currency: "usd",
114
- })),
115
- };
116
- }
117
-
118
- function shownSet(
119
- over: Partial<WorkspaceShownSetWire> = {},
120
- products = [
121
- product("prod_starter", "starter", ["monthly", "yearly"]),
122
- product("prod_agency", "agency-pro", ["yearly"]),
123
- ],
124
- ): WorkspaceShownSetWire {
125
- return workspaceShownSetWireSchema.parse({
126
- productIds: products.map((p) => p.productId),
127
- recommended: { plan: null, addon: null },
128
- offerings: products,
129
- state: "current",
130
- snapshotAt: "2026-10-18T12:00:00.000Z",
131
- ...over,
132
- });
133
- }
134
-
135
- const SHOWN = { ok: true, status: 200, body: { status: "shown", shownSet: shownSet() } };
136
-
137
- function payloadFor(answers: Record<string, string>): string {
138
- return encodePermalink({ version: PERMALINK_VERSION, flowSlug: SLUG, answers });
139
- }
140
-
141
- function page(answers: Record<string, string>, locale = "en"): Promise<ReactElement> {
142
- return Page({
143
- params: Promise.resolve({ locale, slug: SLUG, payload: payloadFor(answers) }),
144
- });
145
- }
146
-
147
- async function landing(answers: Record<string, string>, locale = "en"): Promise<string> {
148
- const err = await page(answers, locale).then(
149
- () => null,
150
- (e: unknown) => e,
151
- );
152
- const message = err instanceof Error ? err.message : "";
153
- if (!message.startsWith("NEXT_REDIRECT:")) throw new Error(`no redirect: ${String(err)}`);
154
- return message.slice("NEXT_REDIRECT:".length);
155
- }
156
-
157
- const originalLocales = process.env.NEXT_PUBLIC_ENABLED_LOCALES;
158
-
159
- beforeAll(() => {
160
- delete process.env.NEXT_PUBLIC_ENABLED_LOCALES;
161
- jest.useFakeTimers({ now: new Date("2026-10-18T12:00:00.000Z") });
162
- });
163
-
164
- afterAll(() => {
165
- jest.useRealTimers();
166
- if (originalLocales !== undefined) process.env.NEXT_PUBLIC_ENABLED_LOCALES = originalLocales;
167
- });
168
-
169
- beforeEach(() => {
170
- // Past the shared read's 15 s window, so no case sees another's read.
171
- jest.setSystemTime(Date.now() + 16_000);
172
- mockGet.mockReset();
173
- mockShown.mockReset();
174
- mockRedirect.mockClear();
175
- mockGet.mockResolvedValue({ ok: true, status: 200, body: config() });
176
- mockShown.mockResolvedValue(SHOWN);
177
- });
178
-
179
- afterEach(() => {
180
- for (const [url] of mockRedirect.mock.calls) {
181
- expect(url).toMatch(/^[a-z0-9/?=-]+$/);
182
- expect(url).not.toContain("_");
183
- expect(url).not.toContain("://");
184
- }
185
- });
186
-
187
- describe("#9071 AC-2(a) — a shown recommendation lands on /pricing?plan=<plan>", () => {
188
- it("solo → the starter plan", async () => {
189
- await expect(landing({ team: "solo" })).resolves.toBe("/en/pricing?plan=starter");
190
- });
191
-
192
- it("agency → the agency-pro plan", async () => {
193
- await expect(landing({ team: "agency" })).resolves.toBe("/en/pricing?plan=agency-pro");
194
- });
195
-
196
- it("a locale that is not enabled lands on the default locale", async () => {
197
- await expect(landing({ team: "solo" }, "fr")).resolves.toBe("/en/pricing?plan=starter");
198
- });
199
- });
200
-
201
- describe("#9071 AC-2(a) — a product no longer shown lands on /pricing with no badge", () => {
202
- it("agency-pro removed from the shown set", async () => {
203
- mockShown.mockResolvedValue({
204
- ok: true,
205
- status: 200,
206
- body: {
207
- status: "shown",
208
- shownSet: shownSet({}, [product("prod_starter", "starter", ["monthly", "yearly"])]),
209
- },
210
- });
211
- await expect(landing({ team: "agency" })).resolves.toBe("/en/pricing");
212
- });
213
-
214
- it.each<[string, () => unknown]>([
215
- ["unconnected", () => Promise.resolve({ ok: true, status: 200, body: { status: "unconnected" } })],
216
- ["empty", () => Promise.resolve({ ok: true, status: 200, body: { status: "empty" } })],
217
- [
218
- "an expired shown set",
219
- () =>
220
- Promise.resolve({
221
- ok: true,
222
- status: 200,
223
- body: { status: "shown", shownSet: shownSet({ state: "expired" }) },
224
- }),
225
- ],
226
- ["a 500", () => Promise.resolve({ ok: false, status: 500, error: { code: "internal_error" } })],
227
- ["a body the schema refuses", () => Promise.resolve({ ok: true, status: 200, body: { status: "shown" } })],
228
- ["a rejecting call", () => Promise.reject(new Error("ECONNREFUSED"))],
229
- ])("%s → /en/pricing", async (_label, answer) => {
230
- mockShown.mockImplementation(answer);
231
- await expect(landing({ team: "solo" })).resolves.toBe("/en/pricing");
232
- });
233
-
234
- it("a read that never settles is given up after 5 s → /en/pricing", async () => {
235
- mockShown.mockImplementation(() => new Promise(() => undefined));
236
- const outcome = landing({ team: "solo" });
237
- await jest.advanceTimersByTimeAsync(5_000);
238
- await expect(outcome).resolves.toBe("/en/pricing");
239
- });
240
-
241
- it("answers matching no rule → /en/pricing with no shown read", async () => {
242
- await expect(landing({ team: "other" })).resolves.toBe("/en/pricing");
243
- expect(mockShown).not.toHaveBeenCalled();
244
- });
245
- });
246
-
247
- describe("#9071 D3a — one shown-set read per instance per 15 seconds", () => {
248
- it("two requests at one clock share one read; one 16 s later reads again", async () => {
249
- await landing({ team: "solo" });
250
- await landing({ team: "agency" });
251
- expect(mockShown).toHaveBeenCalledTimes(1);
252
- jest.setSystemTime(Date.now() + 16_000);
253
- await landing({ team: "solo" });
254
- expect(mockShown).toHaveBeenCalledTimes(2);
255
- });
256
- });
257
-
258
- describe("#9071 C6 — a flow that is not an Offerings recommender renders as before", () => {
259
- it("a mixed flow whose first fit has no lookupKey renders ResultsClient, no redirect, no read", async () => {
260
- mockGet.mockResolvedValue({
261
- ok: true,
262
- status: 200,
263
- body: config([offer("free", "solo"), offer("agency", "agency", "agency-pro_yearly")]),
264
- });
265
- render(await page({ team: "solo" }));
266
- expect(screen.getByTestId("flow-results")).toBeInTheDocument();
267
- expect(mockRedirect).not.toHaveBeenCalled();
268
- expect(mockShown).not.toHaveBeenCalled();
269
- });
270
-
271
- it("an offer with lookupKey: null is no Offerings offer: today's page, no read", async () => {
272
- mockGet.mockResolvedValue({
273
- ok: true,
274
- status: 200,
275
- body: config([{ ...offer("starter", "solo"), lookupKey: null }]),
276
- });
277
- render(await page({ team: "solo" }));
278
- expect(screen.getByTestId("flow-results")).toBeInTheDocument();
279
- expect(mockRedirect).not.toHaveBeenCalled();
280
- expect(mockShown).not.toHaveBeenCalled();
281
- });
282
-
283
- it("offers that are not an array never reach the landing or the read", async () => {
284
- mockGet.mockResolvedValue({
285
- ok: true,
286
- status: 200,
287
- body: config({ starter: offer("starter", "solo", "starter_monthly") }),
288
- });
289
- await page({ team: "solo" }).catch(() => undefined);
290
- expect(mockRedirect).not.toHaveBeenCalled();
291
- expect(mockShown).not.toHaveBeenCalled();
292
- });
293
- });