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,704 +0,0 @@
1
- // oss: false
2
- /**
3
- * #8840 D8 — the standard magnet page pair (`magnet-page.tsx`).
4
- *
5
- * AC-4 — the landing renders the flow record's `landing` copy (one H1, the
6
- * line, the meta line, a CTA to `<path>/start`) with the `Assessment`
7
- * page type's `WebApplication` JSON-LD and no robots key, falling back
8
- * to step 1's title and the generic `flow` copy; the walk renders the
9
- * back arrow and the stepper on step 1 and is `noindex, follow`.
10
- * AC-5 — an unreachable hub (a rejected read or a 5xx) shows the site's
11
- * contact email on both pages, both `noindex`, and nothing throws; a
12
- * 404 is `notFound()`; one slug's read is shared for 15 seconds, and a
13
- * slug the schema refuses is never read.
14
- *
15
- * #11013 spec E (AC-1, AC-2) — the walk passes the frame's brand header and
16
- * Esc exit in place of the back arrow; a multi-step magnet's landing is the
17
- * takeover title page (`FlowFrame`, no bar, no header title) with its
18
- * JSON-LD and metadata unchanged, while a one-step flow keeps today's hero.
19
- */
20
- import { render, screen } from "@testing-library/react";
21
- import type { FlowConfig } from "@working-theory/validation";
22
- import type { ReactElement } from "react";
23
-
24
- const mockGet = jest.fn();
25
- jest.mock("@working-theory/api-client", () => ({
26
- __esModule: true,
27
- flows: { get: (...args: unknown[]) => mockGet(...args) },
28
- }));
29
-
30
- const mockRedirect = jest.fn((href: string) => {
31
- throw new Error(`NEXT_REDIRECT ${href}`);
32
- });
33
- jest.mock("next/navigation", () => ({
34
- __esModule: true,
35
- notFound: () => {
36
- throw new Error("NEXT_NOT_FOUND");
37
- },
38
- redirect: (href: string) => mockRedirect(href),
39
- useRouter: () => ({ push: jest.fn() }),
40
- }));
41
-
42
- jest.mock("next-intl/server", () => ({
43
- __esModule: true,
44
- // Echoes the values, so an interpolated message (the Time line) is observable.
45
- getTranslations: async () => (key: string, values?: Record<string, unknown>) =>
46
- values === undefined
47
- ? key
48
- : `${key}:${Object.entries(values)
49
- .map(([k, v]) => `${k}=${String(v)}`)
50
- .join(",")}`,
51
- }));
52
-
53
- // #11013 — the title page's frame, captured by props; its children render so
54
- // the heading, the line, the button and the Time line are readable.
55
- const mockFrame = jest.fn();
56
- jest.mock("@working-theory/ui", () => {
57
- const actual = jest.requireActual("@working-theory/ui");
58
- const react = require("react");
59
- return {
60
- ...actual,
61
- FlowFrame: (props: Record<string, unknown>) => {
62
- mockFrame(props);
63
- return react.createElement(
64
- "div",
65
- { "data-testid": "flow-frame", "data-takeover": String(props["takeover"] ?? false), "data-bar-mode": props["barMode"] },
66
- props["children"] as ReactElement,
67
- );
68
- },
69
- };
70
- });
71
-
72
- // The hero section's data, drawn as plain landmarks the assertions read.
73
- jest.mock("@working-theory/ui/sections", () => {
74
- const react = require("react");
75
- return {
76
- __esModule: true,
77
- SectionRenderer: ({ sections }: { sections: Array<{ data: Record<string, unknown> }> }) => {
78
- const data = sections[0]!.data as {
79
- headline: string;
80
- subheadline: string;
81
- body?: string;
82
- variant?: string;
83
- primaryCta: { label: string; href: string };
84
- };
85
- return react.createElement(
86
- "section",
87
- { "data-variant": data.variant },
88
- react.createElement("h1", null, data.headline),
89
- react.createElement("p", { "data-testid": "hero-line" }, data.subheadline),
90
- data.body !== undefined
91
- ? react.createElement("p", { "data-testid": "hero-meta" }, data.body)
92
- : null,
93
- react.createElement("a", { href: data.primaryCta.href, "data-testid": "hero-cta" }, data.primaryCta.label),
94
- );
95
- },
96
- };
97
- });
98
-
99
- const mockStepper = jest.fn();
100
- // eslint-disable-next-line no-restricted-syntax -- the walk's client wiring has its own suites; this file pins the renderer
101
- jest.mock("../FlowStepperClient", () => ({
102
- FlowStepperClient: (props: Record<string, unknown>) => {
103
- mockStepper(props);
104
- const react = require("react");
105
- return react.createElement(
106
- "div",
107
- { "data-testid": "stepper" },
108
- props["header"] as ReactElement,
109
- (props["config"] as FlowConfig).steps[0]!.copy.title["en"],
110
- );
111
- },
112
- }));
113
-
114
- // eslint-disable-next-line no-restricted-syntax -- the contact email is env-backed; its reader has its own suite
115
- jest.mock("../../../contact/site-contact-email", () => ({
116
- readSiteContactEmail: () => "hello@example.com",
117
- }));
118
-
119
- import { TOPOLOGY } from "../../../../../lib/topology.generated";
120
- import {
121
- magnetLandingMetadata,
122
- magnetStartMetadata,
123
- readMagnet,
124
- renderMagnetLanding,
125
- renderMagnetLandingMetadata,
126
- renderMagnetStart,
127
- renderMagnetStartMetadata,
128
- } from "../magnet-page";
129
-
130
- const en = (s: string) => ({ en: s });
131
-
132
- function config(withLanding = true): FlowConfig {
133
- return {
134
- slug: "growth",
135
- defaultLocale: "en",
136
- ...(withLanding
137
- ? {
138
- landing: {
139
- title: en("How ready is your team?"),
140
- description: en("Ten questions, one page of results."),
141
- meta: en("About 3 minutes · Your result arrives by email"),
142
- cta: en("Start the diagnostic"),
143
- },
144
- }
145
- : {}),
146
- steps: [
147
- {
148
- key: "team",
149
- type: "field",
150
- copy: { title: en("Who are you?") },
151
- fields: [{ name: "email", inputType: "email", required: true, mapsTo: "email", copy: { label: en("Email") } }],
152
- },
153
- ],
154
- } as FlowConfig;
155
- }
156
-
157
- /** #11013 — a three-step flow (two questions and a message step), the takeover title page. */
158
- function multiStep(withLanding = true, extraSteps: FlowConfig["steps"] = []): FlowConfig {
159
- const base = config(withLanding);
160
- return {
161
- ...base,
162
- steps: [
163
- ...base.steps,
164
- {
165
- key: "q1",
166
- type: "segmentation",
167
- copy: { title: en("How often do you ship?") },
168
- questions: [{ name: "cadence", options: [{ value: "weekly", label: en("Weekly") }] }],
169
- },
170
- { key: "note", type: "message", copy: { title: en("Nearly there") } },
171
- ...extraSteps,
172
- ],
173
- } as FlowConfig;
174
- }
175
-
176
- // One slug's read is shared for 15 seconds; each test starts an hour later.
177
- let clock = 1_800_000_000_000;
178
- jest.spyOn(Date, "now").mockImplementation(() => clock);
179
-
180
- beforeEach(() => {
181
- clock += 60 * 60 * 1000;
182
- mockGet.mockReset();
183
- mockStepper.mockReset();
184
- mockFrame.mockReset();
185
- mockGet.mockResolvedValue({ ok: true, body: config() });
186
- });
187
-
188
- const params = Promise.resolve({ locale: "en" });
189
- const REF = { slug: "growth", path: "/diagnostic" };
190
-
191
- describe("the landing (#8840 D8, AC-4)", () => {
192
- it("renders the record's landing copy, a CTA to <path>/start and the WebApplication JSON-LD", async () => {
193
- const { container } = render(
194
- await renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "en" }),
195
- );
196
- expect(screen.getAllByRole("heading", { level: 1 })).toHaveLength(1);
197
- expect(screen.getByRole("heading", { level: 1 }).textContent).toBe("How ready is your team?");
198
- expect(screen.getByTestId("hero-line").textContent).toBe("Ten questions, one page of results.");
199
- expect(screen.getByTestId("hero-meta").textContent).toBe(
200
- "About 3 minutes · Your result arrives by email",
201
- );
202
- expect(screen.getByTestId("hero-cta").getAttribute("href")).toBe("/diagnostic/start");
203
- expect(screen.getByTestId("hero-cta").textContent).toBe("Start the diagnostic");
204
- expect(container.querySelector("section")?.getAttribute("data-variant")).toBe("centered");
205
-
206
- const script = container.querySelector('script[type="application/ld+json"]');
207
- const jsonLd = JSON.parse(script!.textContent!) as { "@type": string; name: string };
208
- expect(jsonLd["@type"]).toBe("WebApplication");
209
- expect(jsonLd.name).toBe("How ready is your team?");
210
- });
211
-
212
- it("localizes the CTA for a non-default locale", async () => {
213
- render(await renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "fr" }));
214
- expect(screen.getByTestId("hero-cta").getAttribute("href")).toBe("/fr/diagnostic/start");
215
- });
216
-
217
- it("falls back to step 1's title, flow.landingIntro and flow.getStarted, with no meta line", async () => {
218
- mockGet.mockResolvedValue({ ok: true, body: config(false) });
219
- render(await renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "en" }));
220
- expect(screen.getByRole("heading", { level: 1 }).textContent).toBe("Who are you?");
221
- expect(screen.getByTestId("hero-line").textContent).toBe("landingIntro");
222
- expect(screen.getByTestId("hero-cta").textContent).toBe("getStarted");
223
- expect(screen.queryByTestId("hero-meta")).toBeNull();
224
- });
225
-
226
- it("is indexable: the metadata carries the title and no robots key", async () => {
227
- const metadata = await magnetLandingMetadata(REF)({ params });
228
- expect(metadata.robots).toBeUndefined();
229
- expect(metadata.title).toBe("How ready is your team?");
230
- });
231
- });
232
-
233
- describe("the walk (#8840 D8, AC-4)", () => {
234
- it("renders the stepper on step 1 with the frame's exit to the landing, and no back arrow (#11013)", async () => {
235
- render(await renderMagnetStart({ slug: "growth", locale: "en", backHref: "/diagnostic" }));
236
- expect(screen.queryByTestId("nav-back-link")).toBeNull();
237
- expect(screen.getByTestId("stepper").textContent).toContain("Who are you?");
238
- const props = mockStepper.mock.calls[0]![0] as Record<string, unknown>;
239
- expect(props["slug"]).toBe("growth");
240
- expect(props["exit"]).toEqual({ href: "/en/diagnostic", label: "exitLabel" });
241
- expect(props).not.toHaveProperty("hiddenValues");
242
- });
243
-
244
- it("replaces step 1's title and passes hidden values when asked", async () => {
245
- render(
246
- await renderMagnetStart({
247
- slug: "growth",
248
- locale: "en",
249
- backHref: "/careers/writer",
250
- hiddenValues: { job: "writer" },
251
- firstStepTitle: "Writer",
252
- }),
253
- );
254
- const props = mockStepper.mock.calls[0]![0] as { config: FlowConfig; hiddenValues: unknown };
255
- expect(props.config.steps[0]!.copy.title).toEqual({ en: "Writer" });
256
- expect(props.hiddenValues).toEqual({ job: "writer" });
257
- });
258
-
259
- it("is noindex, follow", async () => {
260
- const metadata = await magnetStartMetadata(REF)({ params });
261
- expect(metadata.robots).toEqual({ index: false, follow: true });
262
- });
263
- });
264
-
265
- describe("the walk carries the frame's brand header and Esc, not the back arrow (#11013 AC-1)", () => {
266
- function stepperProps(): Record<string, unknown> {
267
- expect(mockStepper).toHaveBeenCalledTimes(1);
268
- return mockStepper.mock.calls[0]![0] as Record<string, unknown>;
269
- }
270
-
271
- it("passes brand (logomark, wordmark, the landing title), exit to the back path and no header", async () => {
272
- render(await renderMagnetStart({ slug: "growth", locale: "en", backHref: "/flows/x" }));
273
- const props = stepperProps();
274
- const brand = props["brand"] as { logomark?: unknown; wordmark?: unknown; title?: string };
275
- expect(brand.logomark).toBeDefined();
276
- expect(brand.wordmark).toBeDefined();
277
- expect(brand.title).toBe("How ready is your team?");
278
- expect(props["exit"]).toEqual({ href: "/en/flows/x", label: "exitLabel" });
279
- expect(props).not.toHaveProperty("header");
280
- expect(props).not.toHaveProperty("presentation");
281
- expect(screen.queryByTestId("nav-back-link")).toBeNull();
282
- });
283
-
284
- it("a careers walk's Esc leaves for its posting, never the landing", async () => {
285
- mockGet.mockResolvedValue({ ok: true, body: { ...config(), slug: "eng-application" } });
286
- render(
287
- await renderMagnetStart({
288
- slug: "eng-application",
289
- locale: "en",
290
- backHref: "/careers/eng/apply",
291
- hiddenValues: { job: "eng" },
292
- firstStepTitle: "Engineer",
293
- }),
294
- );
295
- expect(stepperProps()["exit"]).toEqual({ href: "/en/careers/eng/apply", label: "exitLabel" });
296
- });
297
-
298
- it("the title falls back to step 1's title with no landing block; a locale that is not enabled exits on the default locale", async () => {
299
- // The exit is built through the same enabled-locale allowlist every path
300
- // the walk pushes passes (#4707); the test env enables `en` alone.
301
- mockGet.mockResolvedValue({ ok: true, body: config(false) });
302
- render(await renderMagnetStart({ slug: "growth", locale: "fr", backHref: "/flows/x" }));
303
- const props = stepperProps();
304
- expect((props["brand"] as { title?: string }).title).toBe("Who are you?");
305
- expect(props["exit"]).toEqual({ href: "/en/flows/x", label: "exitLabel" });
306
- });
307
-
308
- it("forwards presentation when the page passes one", async () => {
309
- render(await renderMagnetStart({ slug: "growth", locale: "en", backHref: "/flows/x", presentation: "full" }));
310
- expect(stepperProps()["presentation"]).toBe("full");
311
- });
312
-
313
- it("the unavailable path still renders NavBackLink above the contact email", async () => {
314
- process.env.AILK_API_URL = "https://hub.example";
315
- try {
316
- mockGet.mockResolvedValue({ ok: false, status: 503, body: null });
317
- render(await renderMagnetStart({ slug: "growth", locale: "en", backHref: "/flows/x" }));
318
- } finally {
319
- delete process.env.AILK_API_URL;
320
- }
321
- const back = screen.getByTestId("nav-back-link");
322
- const fallback = screen.getByTestId("contact-fallback");
323
- expect(back.getAttribute("href")).toBe("/flows/x");
324
- expect(back.compareDocumentPosition(fallback) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
325
- expect(mockStepper).not.toHaveBeenCalled();
326
- });
327
- });
328
-
329
- describe("a multi-step magnet's title page is the takeover window (#11013 AC-2)", () => {
330
- function frameProps(): Record<string, unknown> {
331
- expect(mockFrame).toHaveBeenCalledTimes(1);
332
- return mockFrame.mock.calls[0]![0] as Record<string, unknown>;
333
- }
334
-
335
- it("renders FlowFrame with takeover, no bar, a brand with no title and an exit to the site's home", async () => {
336
- mockGet.mockResolvedValue({ ok: true, body: multiStep() });
337
- render(await renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "en" }));
338
- const props = frameProps();
339
- expect(props["takeover"]).toBe(true);
340
- expect(props["barMode"]).toBe("none");
341
- const brand = props["brand"] as { logomark?: unknown; wordmark?: unknown; title?: string };
342
- expect(brand.logomark).toBeDefined();
343
- expect(brand.wordmark).toBeDefined();
344
- expect(brand).not.toHaveProperty("title");
345
- expect(props["exit"]).toEqual({ href: "/en", label: "exitLabel" });
346
- expect(screen.queryByTestId("hero-cta")).toBeNull();
347
- });
348
-
349
- it("inside it: one h1, the description, the button to the start path, then the Time line", async () => {
350
- mockGet.mockResolvedValue({ ok: true, body: multiStep() });
351
- render(await renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "en" }));
352
- const headings = screen.getAllByRole("heading", { level: 1 });
353
- expect(headings).toHaveLength(1);
354
- expect(headings[0]!.textContent).toBe("How ready is your team?");
355
- expect(screen.getByTestId("flow-title-description").textContent).toBe("Ten questions, one page of results.");
356
- const cta = screen.getByTestId("flow-title-cta");
357
- expect(cta.getAttribute("href")).toBe("/diagnostic/start");
358
- expect(cta.textContent).toBe("Start the diagnostic");
359
- const time = screen.getByTestId("flow-title-time");
360
- expect(cta.compareDocumentPosition(time) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
361
- expect(screen.getByTestId("flow-frame")).toContainElement(time);
362
- });
363
-
364
- it("the Time line is landing.meta when set", async () => {
365
- mockGet.mockResolvedValue({ ok: true, body: multiStep() });
366
- render(await renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "en" }));
367
- expect(screen.getByTestId("flow-title-time").textContent).toBe("About 3 minutes · Your result arrives by email");
368
- });
369
-
370
- it("without landing.meta the Time line counts the steps that are not message steps, ÷ 5", async () => {
371
- const questions = Array.from({ length: 27 }, (_, i) => ({
372
- key: `q${i + 2}`,
373
- type: "segmentation",
374
- copy: { title: en(`Q${i + 2}`) },
375
- questions: [{ name: `a${i}`, options: [{ value: "x", label: en("X") }] }],
376
- })) as FlowConfig["steps"];
377
- // 2 + 27 = 29 counted steps, plus one message step that is not counted.
378
- mockGet.mockResolvedValue({ ok: true, body: multiStep(false, questions) });
379
- render(await renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "en" }));
380
- expect(screen.getByTestId("flow-title-time").textContent).toBe("landingTime:minutes=6");
381
- });
382
-
383
- it("a short flow reads at least one minute", async () => {
384
- mockGet.mockResolvedValue({ ok: true, body: multiStep(false) });
385
- render(await renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "en" }));
386
- expect(screen.getByTestId("flow-title-time").textContent).toBe("landingTime:minutes=1");
387
- });
388
-
389
- it("keeps the WebApplication JSON-LD and the metadata as before, and stays indexable", async () => {
390
- mockGet.mockResolvedValue({ ok: true, body: multiStep() });
391
- const { container } = render(
392
- await renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "en" }),
393
- );
394
- const script = container.querySelector('script[type="application/ld+json"]');
395
- const jsonLd = JSON.parse(script!.textContent!) as { "@type": string; name: string; description: string };
396
- expect(jsonLd["@type"]).toBe("WebApplication");
397
- expect(jsonLd.name).toBe("How ready is your team?");
398
- expect(jsonLd.description).toBe("Ten questions, one page of results.");
399
- const metadata = await renderMagnetLandingMetadata({ slug: "growth", locale: "en" });
400
- expect(metadata).toEqual({ title: "How ready is your team?", description: "Ten questions, one page of results." });
401
- });
402
-
403
- it("localizes the start path as the hero did; a locale that is not enabled exits on the default locale", async () => {
404
- mockGet.mockResolvedValue({ ok: true, body: multiStep() });
405
- render(await renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "fr" }));
406
- expect(screen.getByTestId("flow-title-cta").getAttribute("href")).toBe("/fr/diagnostic/start");
407
- expect(frameProps()["exit"]).toEqual({ href: "/en", label: "exitLabel" });
408
- });
409
-
410
- it("a one-step flow's landing renders today's hero section with no FlowFrame", async () => {
411
- render(await renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "en" }));
412
- expect(mockFrame).not.toHaveBeenCalled();
413
- expect(screen.getByTestId("hero-cta").getAttribute("href")).toBe("/diagnostic/start");
414
- expect(screen.queryByTestId("flow-title-page")).toBeNull();
415
- });
416
- });
417
-
418
- describe("an unreachable hub shows the contact email (#8840 D8, AC-5)", () => {
419
- // #9219 — a configured hub, so a rejected read or a plain 503 is an outage
420
- // (`unavailable`), not a site with no hub to ask.
421
- let savedOrigin: string | undefined;
422
- beforeEach(() => {
423
- savedOrigin = process.env.AILK_API_URL;
424
- process.env.AILK_API_URL = "https://hub.example";
425
- });
426
- afterEach(() => {
427
- if (savedOrigin === undefined) delete process.env.AILK_API_URL;
428
- else process.env.AILK_API_URL = savedOrigin;
429
- });
430
-
431
- it.each([
432
- ["a rejected read", () => mockGet.mockRejectedValue(new TypeError("fetch failed"))],
433
- ["a 503", () => mockGet.mockResolvedValue({ ok: false, status: 503, body: null })],
434
- // #9219 — a hub that is not configured is its own read kind, and a magnet
435
- // pair treats it exactly as an outage.
436
- [
437
- "a 503 flows_not_configured",
438
- () =>
439
- mockGet.mockResolvedValue({
440
- ok: false,
441
- status: 503,
442
- body: { ok: false, error: { code: "flows_not_configured", message: "x" } },
443
- }),
444
- ],
445
- ])("%s: both pages render ContactFallback and both are noindex", async (_label, arrange) => {
446
- arrange();
447
- const landing = render(
448
- await renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "en" }),
449
- );
450
- expect(screen.getByTestId("contact-fallback").textContent).toContain("hello@example.com");
451
- expect(screen.getByTestId("contact-fallback").textContent).toContain("unavailableHeading");
452
- landing.unmount();
453
-
454
- render(await renderMagnetStart({ slug: "growth", locale: "en", backHref: "/diagnostic" }));
455
- expect(screen.getByTestId("contact-fallback").textContent).toContain("hello@example.com");
456
- expect(screen.getByTestId("nav-back-link")).toBeTruthy();
457
- expect(mockStepper).not.toHaveBeenCalled();
458
-
459
- expect((await magnetLandingMetadata(REF)({ params })).robots).toEqual({ index: false, follow: true });
460
- expect((await magnetStartMetadata(REF)({ params })).robots).toEqual({ index: false, follow: true });
461
- });
462
-
463
- it("a 404 is notFound() on both pages, not an outage", async () => {
464
- mockGet.mockResolvedValue({ ok: false, status: 404, body: null });
465
- await expect(
466
- renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "en" }),
467
- ).rejects.toThrow("NEXT_NOT_FOUND");
468
- await expect(
469
- renderMagnetStart({ slug: "growth", locale: "en", backHref: "/diagnostic" }),
470
- ).rejects.toThrow("NEXT_NOT_FOUND");
471
- });
472
-
473
- // #10990 AC-3 — a blocked hub's answers that are not a served flow, and
474
- // refusals that are not a 404, are an outage: the contact email, never the
475
- // hero, a throw or notFound().
476
- it.each([
477
- ["a 2xx with a null body", { ok: true, body: null }],
478
- ["a 2xx with no body", { ok: true, body: undefined }],
479
- ["a 2xx with {}", { ok: true, body: {} }],
480
- ["a 2xx with no steps", { ok: true, body: { slug: "growth", steps: [] } }],
481
- ["a 2xx with no slug", { ok: true, body: { steps: config().steps } }],
482
- ["a 403", { ok: false, status: 403, body: null }],
483
- ["a 429", { ok: false, status: 429, body: null }],
484
- ])("%s: both pages render ContactFallback, no notFound(), noindex (#10990)", async (_label, answer) => {
485
- mockGet.mockResolvedValue(answer);
486
- const landing = render(
487
- await renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "en" }),
488
- );
489
- expect(screen.getByTestId("contact-fallback").textContent).toContain("hello@example.com");
490
- landing.unmount();
491
-
492
- render(await renderMagnetStart({ slug: "growth", locale: "en", backHref: "/diagnostic" }));
493
- expect(screen.getByTestId("contact-fallback").textContent).toContain("hello@example.com");
494
- expect(mockStepper).not.toHaveBeenCalled();
495
-
496
- expect((await magnetLandingMetadata(REF)({ params })).robots).toEqual({ index: false, follow: true });
497
- });
498
-
499
- it("a read that never answers gives the contact email after 5 seconds, not before (#10990)", async () => {
500
- jest.useFakeTimers({ doNotFake: ["Date"] });
501
- try {
502
- mockGet.mockReturnValue(new Promise(() => undefined));
503
- let settled = false;
504
- const rendering = renderMagnetLanding({ slug: "growth", path: "/diagnostic", locale: "en" }).then(
505
- (element) => {
506
- settled = true;
507
- return element;
508
- },
509
- );
510
- await jest.advanceTimersByTimeAsync(4_999);
511
- expect(settled).toBe(false);
512
- await jest.advanceTimersByTimeAsync(1);
513
- render(await rendering);
514
- expect(screen.getByTestId("contact-fallback").textContent).toContain("hello@example.com");
515
- } finally {
516
- jest.useRealTimers();
517
- }
518
- });
519
- });
520
-
521
- describe("a walk that exists apart from its flow passes a title (#9219)", () => {
522
- const titled = { slug: "growth", locale: "en", backHref: "/careers", title: "Job application" };
523
-
524
- it.each([
525
- ["a 404", () => mockGet.mockResolvedValue({ ok: false, status: 404, body: null })],
526
- ["a rejected read", () => mockGet.mockRejectedValue(new TypeError("fetch failed"))],
527
- ["a 503", () => mockGet.mockResolvedValue({ ok: false, status: 503, body: null })],
528
- ])("%s: the contact email under the page's own <h1>, never a 404", async (_label, arrange) => {
529
- arrange();
530
- render(await renderMagnetStart(titled));
531
- expect(screen.getByRole("heading", { level: 1 }).textContent).toBe("Job application");
532
- expect(screen.getByTestId("contact-fallback").textContent).toContain("hello@example.com");
533
- expect(screen.getByTestId("nav-back-link").getAttribute("href")).toBe("/careers");
534
- expect(mockStepper).not.toHaveBeenCalled();
535
- });
536
-
537
- it("the fallback's metadata carries the title and stays noindex", async () => {
538
- mockGet.mockRejectedValue(new TypeError("fetch failed"));
539
- const metadata = await renderMagnetStartMetadata({ slug: "growth", locale: "en", title: "Job application" });
540
- expect(metadata).toEqual({ title: "Job application", robots: { index: false, follow: true } });
541
- });
542
-
543
- it("a served flow still walks, with no extra heading", async () => {
544
- render(await renderMagnetStart(titled));
545
- expect(mockStepper).toHaveBeenCalledTimes(1);
546
- expect(screen.queryByRole("heading", { level: 1 })).toBeNull();
547
- });
548
-
549
- it("without a title an unreachable hub renders no <h1> of its own, and a 404 stays notFound()", async () => {
550
- mockGet.mockRejectedValue(new TypeError("fetch failed"));
551
- render(await renderMagnetStart({ slug: "growth", locale: "en", backHref: "/diagnostic" }));
552
- expect(screen.queryByRole("heading", { level: 1 })).toBeNull();
553
-
554
- clock += 60 * 60 * 1000;
555
- mockGet.mockResolvedValue({ ok: false, status: 404, body: null });
556
- await expect(
557
- renderMagnetStart({ slug: "growth", locale: "en", backHref: "/diagnostic" }),
558
- ).rejects.toThrow("NEXT_NOT_FOUND");
559
- });
560
- });
561
-
562
- describe("the shared read (#8840 D8, AC-5)", () => {
563
- it("two calls within 15 seconds make one flows.get call", async () => {
564
- await readMagnet("growth");
565
- clock += 14_000;
566
- await readMagnet("growth");
567
- expect(mockGet).toHaveBeenCalledTimes(1);
568
- clock += 2_000;
569
- await readMagnet("growth");
570
- expect(mockGet).toHaveBeenCalledTimes(2);
571
- });
572
-
573
- it("holds at most 256 slugs: past the cap a read is made but not shared", async () => {
574
- for (let i = 0; i < 300; i += 1) await readMagnet(`slug-${i}`);
575
- expect(mockGet).toHaveBeenCalledTimes(300);
576
- await readMagnet("slug-0");
577
- expect(mockGet).toHaveBeenCalledTimes(300);
578
- await readMagnet("slug-299");
579
- expect(mockGet).toHaveBeenCalledTimes(301);
580
- });
581
-
582
- it("a slug the schema refuses is absent with no read", async () => {
583
- await expect(readMagnet("Bad_Slug")).resolves.toEqual({ kind: "absent" });
584
- await expect(readMagnet("Bad_Slug")).resolves.toEqual({ kind: "absent" });
585
- expect(mockGet).not.toHaveBeenCalled();
586
- });
587
- });
588
-
589
- describe("the read tells a hub that is not configured from one that is down (#9219)", () => {
590
- const ORIGIN_NAMES = ["AILK_API_URL", "NEXT_PUBLIC_AILK_API_URL", "NEXT_PUBLIC_API_URL"] as const;
591
- const saved: Record<string, string | undefined> = {};
592
- beforeEach(() => {
593
- for (const name of ORIGIN_NAMES) {
594
- saved[name] = process.env[name];
595
- delete process.env[name];
596
- }
597
- });
598
- afterEach(() => {
599
- for (const name of ORIGIN_NAMES) {
600
- if (saved[name] === undefined) delete process.env[name];
601
- else process.env[name] = saved[name];
602
- }
603
- });
604
-
605
- const notConfigured503 = {
606
- ok: false,
607
- status: 503,
608
- body: { ok: false, error: { code: "flows_not_configured", message: "x" } },
609
- };
610
-
611
- it("a 503 flows_not_configured is not-configured, origin set or not", async () => {
612
- process.env.AILK_API_URL = "https://hub.example";
613
- mockGet.mockResolvedValue(notConfigured503);
614
- await expect(readMagnet("growth")).resolves.toEqual({ kind: "not-configured" });
615
- });
616
-
617
- // #9480 — the browser-facing name is read through the topology seam
618
- // (#7874 D12). The committed seam is the hub render; #8060 — a spoke render
619
- // reads no NEXT_PUBLIC_AILK_API_URL, so a spoke scaffold leaves that row out.
620
- const CONFIGURED_BY =
621
- TOPOLOGY === "hub"
622
- ? ORIGIN_NAMES
623
- : ORIGIN_NAMES.filter((name) => name !== "NEXT_PUBLIC_AILK_API_URL");
624
-
625
- it.each(CONFIGURED_BY)("with %s set, a 5xx or a throw is unavailable", async (name) => {
626
- process.env[name] = "https://hub.example";
627
- mockGet.mockResolvedValue({ ok: false, status: 503, body: null });
628
- await expect(readMagnet("growth")).resolves.toEqual({ kind: "unavailable" });
629
- clock += 60_000;
630
- mockGet.mockRejectedValue(new TypeError("fetch failed"));
631
- await expect(readMagnet("growth")).resolves.toEqual({ kind: "unavailable" });
632
- });
633
-
634
- it("with no API origin, a 5xx or a throw is not-configured", async () => {
635
- mockGet.mockResolvedValue({ ok: false, status: 502, body: null });
636
- await expect(readMagnet("growth")).resolves.toEqual({ kind: "not-configured" });
637
- clock += 60_000;
638
- mockGet.mockRejectedValue(new TypeError("fetch failed"));
639
- await expect(readMagnet("growth")).resolves.toEqual({ kind: "not-configured" });
640
- });
641
-
642
- it("on a spoke (the seam's spoke render), NEXT_PUBLIC_AILK_API_URL alone is not-configured", async () => {
643
- process.env.NEXT_PUBLIC_AILK_API_URL = "https://hub.example";
644
- mockGet.mockResolvedValue({ ok: false, status: 503, body: null });
645
- await jest.isolateModulesAsync(async () => {
646
- jest.doMock("../../../../../lib/api-origin.generated", () => ({
647
- browserApiOrigin: (): string | undefined => undefined,
648
- }));
649
- const spoke = await import("../magnet-page");
650
- await expect(spoke.readMagnet("growth")).resolves.toEqual({ kind: "not-configured" });
651
- });
652
- });
653
-
654
- it("with no API origin, a 404 is still absent and a served flow still ok", async () => {
655
- mockGet.mockResolvedValue({ ok: false, status: 404, body: null });
656
- await expect(readMagnet("growth")).resolves.toEqual({ kind: "absent" });
657
- clock += 60_000;
658
- mockGet.mockResolvedValue({ ok: true, body: config() });
659
- await expect(readMagnet("growth")).resolves.toMatchObject({ kind: "ok" });
660
- });
661
- });
662
-
663
- describe("a deliverable flow leaves the pair for /reports (#8848 D7, AC-4)", () => {
664
- function deliverableConfig(): FlowConfig {
665
- // As served: a gated block's target is projected out (#8848 D2).
666
- const served = { ...config(), slug: "q3", deliverable: { kind: "page", gated: true, title: en("Q3 report") } };
667
- // eslint-disable-next-line no-restricted-syntax -- a served gated block omits its target, which FlowConfig cannot express
668
- return served as unknown as FlowConfig;
669
- }
670
-
671
- beforeEach(() => {
672
- mockRedirect.mockClear();
673
- mockGet.mockResolvedValue({ ok: true, body: deliverableConfig() });
674
- });
675
-
676
- it("renderMagnetLanding redirects to /reports/<slug>", async () => {
677
- await expect(renderMagnetLanding({ slug: "q3", path: "/flows/q3", locale: "en" })).rejects.toThrow(
678
- "NEXT_REDIRECT /reports/q3",
679
- );
680
- await expect(renderMagnetLanding({ slug: "q3", path: "/flows/q3", locale: "fr" })).rejects.toThrow(
681
- "NEXT_REDIRECT /fr/reports/q3",
682
- );
683
- });
684
-
685
- it("renderMagnetStart redirects to /reports/<slug>/start", async () => {
686
- await expect(renderMagnetStart({ slug: "q3", locale: "en", backHref: "/flows/q3" })).rejects.toThrow(
687
- "NEXT_REDIRECT /reports/q3/start",
688
- );
689
- });
690
-
691
- it("renderMagnetStart with asDeliverable renders the walk", async () => {
692
- render(await renderMagnetStart({ slug: "q3", locale: "en", backHref: "/reports/q3", asDeliverable: true }));
693
- expect(mockRedirect).not.toHaveBeenCalled();
694
- const props = mockStepper.mock.calls[0]![0] as Record<string, unknown>;
695
- expect(props["exit"]).toEqual({ href: "/en/reports/q3", label: "exitLabel" });
696
- expect(screen.getByTestId("stepper")).toBeTruthy();
697
- });
698
-
699
- it("a config with no block renders as today", async () => {
700
- mockGet.mockResolvedValue({ ok: true, body: config() });
701
- render(await renderMagnetStart({ slug: "growth", locale: "en", backHref: "/diagnostic" }));
702
- expect(mockRedirect).not.toHaveBeenCalled();
703
- });
704
- });