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,162 +0,0 @@
1
- /**
2
- * Tests for /[locale]/purchase/cancel (#6084).
3
- *
4
- * D4 — reads nothing. AC-2 — states nothing was charged, links to
5
- * `/services`, noindex, every string from the `purchase` namespace.
6
- */
7
- import React from "react";
8
- import { render } from "@testing-library/react";
9
-
10
- jest.mock("next/navigation", () => ({
11
- __esModule: true,
12
- notFound: jest.fn(() => {
13
- throw new Error("NEXT_NOT_FOUND");
14
- }),
15
- }));
16
-
17
- const requestedKeys: string[] = [];
18
- jest.mock("next-intl/server", () => ({
19
- __esModule: true,
20
- getTranslations: jest.fn().mockResolvedValue((key: string) => {
21
- requestedKeys.push(key);
22
- return `copy:${key}`;
23
- }),
24
- }));
25
-
26
- const capturedSections: unknown[] = [];
27
- jest.mock("@working-theory/ui/sections", () => ({
28
- __esModule: true,
29
- SectionRenderer: ({ sections }: { sections: unknown[] }) => {
30
- capturedSections.splice(0, capturedSections.length, ...sections);
31
- return React.createElement("div", {
32
- "data-testid": "section-renderer",
33
- "data-section-count": String(sections.length),
34
- });
35
- },
36
- }));
37
-
38
- const mockGetSession = jest.fn();
39
- jest.mock("@working-theory/api-client", () => ({
40
- __esModule: true,
41
- checkout: { getSession: (...args: unknown[]) => mockGetSession(...args) },
42
- }));
43
-
44
- // Mocks the REAL boundary `resolveCommerceClaim()` itself calls
45
- // (`checkLicense` from `@working-theory/license`), not the internal wrapper
46
- // module — matching the eslint "no internal-module mocks" rule (#507).
47
- const mockCheckLicense = jest.fn();
48
- jest.mock("@working-theory/license", () => ({
49
- __esModule: true,
50
- checkLicense: (...args: unknown[]) => mockCheckLicense(...args),
51
- }));
52
-
53
- // `../../../../src/lib/commerce-sections` wraps a lazy, webpack-ignored
54
- // `import()` of the paid `@working-theory/ui-commerce` package — mocked
55
- // directly, mirroring `../__tests__/success.test.tsx`'s identical mock.
56
- const mockEnsureCommerceSectionsRegistered = jest.fn();
57
- // eslint-disable-next-line no-restricted-syntax -- see the identical exception in success.test.tsx
58
- jest.mock("../../../../src/lib/commerce-sections", () => ({
59
- __esModule: true,
60
- ensureCommerceSectionsRegistered: () =>
61
- mockEnsureCommerceSectionsRegistered(),
62
- }));
63
-
64
- import { notFound } from "next/navigation";
65
-
66
- import Page, { generateMetadata } from "../cancel/page";
67
-
68
- const mockNotFound = notFound as jest.MockedFunction<typeof notFound>;
69
-
70
- function sectionTypes(): string[] {
71
- return capturedSections.map((s) => (s as { type: string }).type);
72
- }
73
-
74
- async function renderPage() {
75
- const element = await Page({ params: Promise.resolve({ locale: "en" }) });
76
- return render(element);
77
- }
78
-
79
- describe("/purchase/cancel", () => {
80
- beforeEach(() => {
81
- capturedSections.length = 0;
82
- requestedKeys.length = 0;
83
- mockGetSession.mockReset();
84
- mockCheckLicense.mockReset();
85
- mockCheckLicense.mockResolvedValue({ revoked: false, features: ["commerce"] });
86
- mockNotFound.mockClear();
87
- mockEnsureCommerceSectionsRegistered.mockReset();
88
- mockEnsureCommerceSectionsRegistered.mockResolvedValue(true);
89
- });
90
-
91
- it("renders payment-receipt(outcome:cancel) → cta, with a primary link to /services (AC-2, D5)", async () => {
92
- await renderPage();
93
-
94
- expect(sectionTypes()).toEqual(["payment-receipt", "cta"]);
95
- const receipt = capturedSections[0] as {
96
- data: Record<string, unknown>;
97
- };
98
- expect(receipt.data.outcome).toBe("cancel");
99
- const cta = capturedSections[1] as { data: Record<string, unknown> };
100
- expect((cta.data.primaryCta as { href: string }).href).toBe("/services");
101
- });
102
-
103
- it("falls back to content-block instead of payment-receipt when @working-theory/ui-commerce is not installed", async () => {
104
- mockEnsureCommerceSectionsRegistered.mockResolvedValue(false);
105
-
106
- await renderPage();
107
-
108
- expect(sectionTypes()).toEqual(["content-block", "cta"]);
109
- const fallback = capturedSections[0] as {
110
- data: { headline: string; body: string };
111
- };
112
- expect(fallback.data.headline).toBe("copy:cancel.title");
113
- expect(fallback.data.body).toContain("copy:cancel.message");
114
- });
115
-
116
- it("reads NOTHING — no API call at all (D4)", async () => {
117
- await renderPage();
118
- expect(mockGetSession).not.toHaveBeenCalled();
119
- });
120
-
121
- it("takes every string from the purchase namespace (D4/AC-2)", async () => {
122
- await renderPage();
123
- expect(requestedKeys.length).toBeGreaterThan(0);
124
- expect(requestedKeys.every((k) => k.startsWith("cancel."))).toBe(true);
125
- });
126
-
127
- it("is not indexable", async () => {
128
- const metadata = await generateMetadata({
129
- params: Promise.resolve({ locale: "en" }),
130
- });
131
- expect(metadata.robots).toEqual({ index: false, follow: true });
132
- });
133
-
134
- it("carries no data-outcome=success and no PaymentComplete string — a cancel is not a payment claim", async () => {
135
- await renderPage();
136
- const serialized = JSON.stringify(capturedSections);
137
- expect(serialized).not.toContain('"outcome":"success"');
138
- expect(serialized).not.toContain("PaymentComplete");
139
- });
140
-
141
- // ── T-16 / D12 — the request-time commerce-claim gate ───────────────────
142
-
143
- it("answers notFound() when the commerce claim is NOT held (D12)", async () => {
144
- mockCheckLicense.mockResolvedValue({ revoked: false, features: [] });
145
-
146
- await expect(renderPage()).rejects.toThrow("NEXT_NOT_FOUND");
147
- expect(mockNotFound).toHaveBeenCalledTimes(1);
148
- });
149
-
150
- it("fail-closed: answers notFound() when the licence read THROWS", async () => {
151
- mockCheckLicense.mockRejectedValue(new Error("licence read blew up"));
152
-
153
- await expect(renderPage()).rejects.toThrow();
154
- });
155
-
156
- it("renders normally when the commerce claim IS held", async () => {
157
- mockCheckLicense.mockResolvedValue({ revoked: false, features: ["commerce"] });
158
- await renderPage();
159
- expect(mockNotFound).not.toHaveBeenCalled();
160
- expect(sectionTypes()).toEqual(["payment-receipt", "cta"]);
161
- });
162
- });
@@ -1,68 +0,0 @@
1
- /**
2
- * T-8 (#6084) — neither `/purchase/success` nor `/purchase/cancel` may hold
3
- * a TOP-LEVEL STATIC import of `@working-theory/ui-commerce`.
4
- *
5
- * Superseded from its original form (a module-scope
6
- * `registerCommerceSections()` call + a static import — the shape the pages
7
- * shipped with initially). That shape is a genuine build-breaking defect:
8
- * both pages ship in the BASE TREE (`CORE_ROUTE_DIRS`, D12), but a keyless
9
- * `create-ailk` scaffold carries NO `@working-theory/ui-commerce` dependency
10
- * by design — `packages/create-ailk/scripts/build-templates.mjs`'s
11
- * `transformPaidUiPackages()` strips it, and
12
- * `__tests__/paid-module-honest-states.test.ts`'s "#5581 U6" suite pins a
13
- * keyless scaffold declaring none of the four paid `ui-*` packages as a
14
- * dependency. Webpack resolves a static top-level import at BUILD time
15
- * regardless of whether the importing code path ever executes, so the
16
- * original shape failed every keyless customer's build with
17
- * `ERR_MODULE_NOT_FOUND` (a code-review finding on this issue's own PR).
18
- *
19
- * The fix — `../../../../src/lib/commerce-sections.ts`'s
20
- * `ensureCommerceSectionsRegistered()` — registers the module LAZILY, via a
21
- * generated paid-sections registry (`lib/paid-sections.generated.ts`, #7536),
22
- * so the build never needs the package to resolve. This test now pins the ABSENCE of the
23
- * static import (the regression this file exists to catch) and the
24
- * PRESENCE of the lazy-registration call site instead.
25
- */
26
- import { readFileSync } from "node:fs";
27
- import { join } from "node:path";
28
-
29
- const PURCHASE_DIR = join(__dirname, "..");
30
-
31
- function readPageSource(page: "success" | "cancel"): string {
32
- return readFileSync(join(PURCHASE_DIR, page, "page.tsx"), "utf8");
33
- }
34
-
35
- describe("ui-commerce registration is LAZY, never a top-level static import (T-8, D5, #6084 code-review fix)", () => {
36
- for (const page of ["success", "cancel"] as const) {
37
- it(`purchase/${page}/page.tsx holds NO static top-level import of @working-theory/ui-commerce`, () => {
38
- const source = readPageSource(page);
39
- expect(source.includes('from "@working-theory/ui-commerce"')).toBe(
40
- false,
41
- );
42
- // The retired specifier may still appear in a doc comment (warning
43
- // readers away from it); what must be absent is an actual IMPORT of it.
44
- expect(
45
- source.includes('from "@working-theory/ui/slices/commerce"'),
46
- ).toBe(false);
47
- });
48
-
49
- it(`purchase/${page}/page.tsx imports ensureCommerceSectionsRegistered from the shared lazy-registration lib`, () => {
50
- const source = readPageSource(page);
51
- expect(
52
- source.includes(
53
- 'import { ensureCommerceSectionsRegistered } from "../../../../src/lib/commerce-sections";',
54
- ),
55
- ).toBe(true);
56
- });
57
-
58
- it(`purchase/${page}/page.tsx never calls registerCommerceSections() at module scope (only through the lazy wrapper)`, () => {
59
- const source = readPageSource(page);
60
- // A doc comment MAY still name it in prose (both pages do, warning
61
- // readers off the direct call) — what must be absent is the
62
- // unindented, top-level CALL EXPRESSION statement itself.
63
- expect(
64
- source.split("\n").some((line) => line === "registerCommerceSections();"),
65
- ).toBe(false);
66
- });
67
- }
68
- });
@@ -1,411 +0,0 @@
1
- /**
2
- * Tests for /[locale]/purchase/success (#6084).
3
- *
4
- * D6's five-row degrade table is the load-bearing surface here: only a 2xx
5
- * read with `paymentStatus === "paid"` may construct a `payment-receipt`
6
- * section — AC-8 pins the negative directly (no `outcome: "success"` DOM
7
- * marker on any other reachable state). AC-1/AC-7 cover the happy path and
8
- * the never-a-dead-end guarantee; T-16 covers the D12 request-time gate in
9
- * all three states (claimed / unclaimed / a throwing read).
10
- */
11
- import React from "react";
12
- import { render } from "@testing-library/react";
13
-
14
- jest.mock("next/navigation", () => ({
15
- __esModule: true,
16
- notFound: jest.fn(() => {
17
- throw new Error("NEXT_NOT_FOUND");
18
- }),
19
- }));
20
-
21
- const mockHeadersGet = jest.fn();
22
- jest.mock("next/headers", () => ({
23
- __esModule: true,
24
- headers: jest.fn().mockResolvedValue({ get: (key: string) => mockHeadersGet(key) }),
25
- }));
26
-
27
- const requestedKeys: string[] = [];
28
- jest.mock("next-intl/server", () => ({
29
- __esModule: true,
30
- getTranslations: jest
31
- .fn()
32
- .mockResolvedValue((key: string, values?: Record<string, unknown>) => {
33
- requestedKeys.push(key);
34
- if (values) return `copy:${key}:${JSON.stringify(values)}`;
35
- return `copy:${key}`;
36
- }),
37
- }));
38
-
39
- const capturedSections: unknown[] = [];
40
- jest.mock("@working-theory/ui/sections", () => ({
41
- __esModule: true,
42
- SectionRenderer: ({ sections }: { sections: unknown[] }) => {
43
- capturedSections.splice(0, capturedSections.length, ...sections);
44
- return React.createElement("div", {
45
- "data-testid": "section-renderer",
46
- "data-section-count": String(sections.length),
47
- });
48
- },
49
- }));
50
-
51
- const mockGetSession = jest.fn();
52
- jest.mock("@working-theory/api-client", () => ({
53
- __esModule: true,
54
- checkout: { getSession: (...args: unknown[]) => mockGetSession(...args) },
55
- }));
56
-
57
- // Mocks the REAL boundary `resolveCommerceClaim()` itself calls
58
- // (`checkLicense` from `@working-theory/license`), not the internal wrapper
59
- // module — matching the eslint "no internal-module mocks" rule (#507).
60
- const mockCheckLicense = jest.fn();
61
- jest.mock("@working-theory/license", () => ({
62
- __esModule: true,
63
- checkLicense: (...args: unknown[]) => mockCheckLicense(...args),
64
- }));
65
-
66
- // `../../../../src/lib/commerce-sections` wraps a lazy, webpack-ignored
67
- // `import()` of the paid `@working-theory/ui-commerce` package — mocked
68
- // directly here (an internal wrapper, but there is no OTHER boundary to
69
- // mock: the real thing it wraps is a dynamic import expression, not an
70
- // importable named export this file could bind instead) so a test can
71
- // simulate the package being genuinely absent (a keyless scaffold) without
72
- // needing to hide a real node_modules entry.
73
- const mockEnsureCommerceSectionsRegistered = jest.fn();
74
- // The wrapped thing is a bare, webpack-ignored `import()` expression, not a
75
- // named export of some other module — there is no external HTTP/DB/env
76
- // boundary to mock instead, mirroring team-page.test.tsx's identical
77
- // exception for auth.ts's lazy singleton.
78
- // eslint-disable-next-line no-restricted-syntax -- see comment above
79
- jest.mock("../../../../src/lib/commerce-sections", () => ({
80
- __esModule: true,
81
- ensureCommerceSectionsRegistered: () =>
82
- mockEnsureCommerceSectionsRegistered(),
83
- }));
84
-
85
- import { checkout } from "@working-theory/api-client";
86
- import { notFound } from "next/navigation";
87
-
88
- import { accountInviteHref } from "../../../../lib/account-invite";
89
- import Page, { generateMetadata } from "../success/page";
90
-
91
- const mockNotFound = notFound as jest.MockedFunction<typeof notFound>;
92
- void checkout; // referenced only to satisfy the mock import above
93
-
94
- function sectionTypes(): string[] {
95
- return capturedSections.map((s) => (s as { type: string }).type);
96
- }
97
-
98
- const PAID_SESSION = {
99
- id: "cs_test_abc123",
100
- status: "complete" as const,
101
- paymentStatus: "paid" as const,
102
- currency: "usd",
103
- amountTotal: 4800,
104
- lineItems: [
105
- {
106
- description: "Pro plan",
107
- quantity: 2,
108
- amountTotal: 4800,
109
- currency: "usd",
110
- },
111
- ],
112
- };
113
-
114
- async function renderPage(sessionId?: string) {
115
- const searchParams = sessionId
116
- ? Promise.resolve({ session_id: sessionId })
117
- : Promise.resolve({});
118
- const element = await Page({
119
- params: Promise.resolve({ locale: "en" }),
120
- searchParams,
121
- });
122
- return render(element);
123
- }
124
-
125
- describe("/purchase/success", () => {
126
- beforeEach(() => {
127
- capturedSections.length = 0;
128
- requestedKeys.length = 0;
129
- mockGetSession.mockReset();
130
- mockCheckLicense.mockReset();
131
- mockCheckLicense.mockResolvedValue({ revoked: false, features: ["commerce"] });
132
- mockNotFound.mockClear();
133
- mockEnsureCommerceSectionsRegistered.mockReset();
134
- mockEnsureCommerceSectionsRegistered.mockResolvedValue(true);
135
- mockHeadersGet.mockReset();
136
- mockHeadersGet.mockReturnValue(null);
137
- });
138
-
139
- // ── AC-1 — the paid render ────────────────────────────────────────────────
140
-
141
- it("renders payment-receipt → items → cta on a 2xx paid read (AC-1)", async () => {
142
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
143
-
144
- await renderPage("cs_test_abc123");
145
-
146
- expect(sectionTypes()).toEqual(["payment-receipt", "items", "cta"]);
147
- });
148
-
149
- it("calls checkout.getSession with the exact session_id from the query, and undefined init when no forwarding header is present", async () => {
150
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
151
- mockHeadersGet.mockReturnValue(null);
152
-
153
- await renderPage("cs_test_abc123");
154
-
155
- expect(mockGetSession).toHaveBeenCalledWith("cs_test_abc123", undefined);
156
- });
157
-
158
- it("forwards the visitor's x-forwarded-for as init.headers on the server-side read (security-review finding, #6084)", async () => {
159
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
160
- mockHeadersGet.mockImplementation((key: string) =>
161
- key === "x-forwarded-for" ? "203.0.113.7" : null,
162
- );
163
-
164
- await renderPage("cs_test_abc123");
165
-
166
- expect(mockGetSession).toHaveBeenCalledWith("cs_test_abc123", {
167
- headers: { "x-forwarded-for": "203.0.113.7" },
168
- });
169
- });
170
-
171
- it("threads the session id + amount + currency into the payment-receipt section", async () => {
172
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
173
-
174
- await renderPage("cs_test_abc123");
175
-
176
- const receipt = capturedSections[0] as {
177
- type: string;
178
- data: Record<string, unknown>;
179
- };
180
- expect(receipt.type).toBe("payment-receipt");
181
- expect(receipt.data.outcome).toBe("success");
182
- expect(receipt.data.sessionId).toBe("cs_test_abc123");
183
- expect(receipt.data.amount).toEqual({ amountMinor: 4800, currency: "usd" });
184
- });
185
-
186
- it("renders one items card per paid line item, with quantity and formatted money", async () => {
187
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
188
-
189
- await renderPage("cs_test_abc123");
190
-
191
- const items = capturedSections[1] as {
192
- type: string;
193
- data: { items: { title: string; description: string }[] };
194
- };
195
- expect(items.type).toBe("items");
196
- expect(items.data.items).toHaveLength(1);
197
- expect(items.data.items[0]!.title).toBe("Pro plan");
198
- // The translated line renders through the t() mock, carrying the raw
199
- // interpolation values — quantity is threaded, and formatMoney ran (the
200
- // string contains a currency-formatted amount, not the raw minor units).
201
- expect(items.data.items[0]!.description).toContain("success.lineItem");
202
- expect(items.data.items[0]!.description).toContain('"quantity":2');
203
- });
204
-
205
- it("falls back to content-block instead of payment-receipt when @working-theory/ui-commerce is not installed", async () => {
206
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
207
- mockEnsureCommerceSectionsRegistered.mockResolvedValue(false);
208
-
209
- await renderPage("cs_test_abc123");
210
-
211
- // Never the bare `payment-receipt` type — SectionRenderer would
212
- // otherwise fall back to `ModuleAbsent`, which renders nothing in
213
- // production. The line items and CTA are unaffected either way.
214
- expect(sectionTypes()).toEqual(["content-block", "items", "cta"]);
215
- const fallback = capturedSections[0] as {
216
- type: string;
217
- data: { headline: string; body: string };
218
- };
219
- expect(fallback.data.headline).toBe("copy:success.title");
220
- expect(fallback.data.body).toContain("copy:success.message");
221
- });
222
-
223
- // ── D6 — the five-row degrade table ─────────────────────────────────────
224
-
225
- it("renders content-block → cta with NO payment-receipt when there is no session_id (D6 row 3)", async () => {
226
- await renderPage(undefined);
227
-
228
- expect(sectionTypes()).toEqual(["content-block", "cta"]);
229
- expect(mockGetSession).not.toHaveBeenCalled();
230
- });
231
-
232
- it("renders content-block → cta with NO payment-receipt on a non-2xx read (D6 row 5)", async () => {
233
- mockGetSession.mockResolvedValue({
234
- ok: false,
235
- status: 404,
236
- body: { error: "unknown-session" },
237
- });
238
-
239
- await renderPage("cs_test_unknown");
240
-
241
- expect(sectionTypes()).toEqual(["content-block", "cta"]);
242
- });
243
-
244
- it("renders content-block → cta with NO payment-receipt when checkout.getSession REJECTS (a network failure, not a non-2xx response)", async () => {
245
- // `checkout.getSession()` calls `fetch()` with no try/catch of its own
246
- // (`packages/api-client/src/http.ts`) — a network-level failure rejects
247
- // the promise rather than resolving `{ ok: false }`. Code-review finding
248
- // on this issue's PR: without a catch here, this crashes the page
249
- // instead of degrading like every other unreachable-session case.
250
- mockGetSession.mockRejectedValue(new Error("fetch failed"));
251
-
252
- await renderPage("cs_test_unreachable");
253
-
254
- expect(sectionTypes()).toEqual(["content-block", "cta"]);
255
- });
256
-
257
- it("renders content-block → items → cta with NO payment-receipt when paymentStatus is unpaid (D6 row 2)", async () => {
258
- mockGetSession.mockResolvedValue({
259
- ok: true,
260
- body: { ...PAID_SESSION, paymentStatus: "unpaid" },
261
- });
262
-
263
- await renderPage("cs_test_pending");
264
-
265
- expect(sectionTypes()).toEqual(["content-block", "items", "cta"]);
266
- });
267
-
268
- it("renders content-block → items → cta when paymentStatus is no_payment_required (D6 row 2)", async () => {
269
- mockGetSession.mockResolvedValue({
270
- ok: true,
271
- body: { ...PAID_SESSION, paymentStatus: "no_payment_required" },
272
- });
273
-
274
- await renderPage("cs_test_pending");
275
-
276
- expect(sectionTypes()).toEqual(["content-block", "items", "cta"]);
277
- });
278
-
279
- // ── AC-8 — the paid render is not forgeable ─────────────────────────────
280
-
281
- it("no session_id: the DOM carries no data-outcome=success and no PaymentComplete string (AC-8)", async () => {
282
- await renderPage(undefined);
283
-
284
- const serialized = JSON.stringify(capturedSections);
285
- expect(serialized).not.toContain('"outcome":"success"');
286
- expect(serialized).not.toContain("PaymentComplete");
287
- });
288
-
289
- it("unpaid session: the DOM carries no data-outcome=success and no PaymentComplete string (AC-8)", async () => {
290
- mockGetSession.mockResolvedValue({
291
- ok: true,
292
- body: { ...PAID_SESSION, paymentStatus: "unpaid" },
293
- });
294
-
295
- await renderPage("cs_test_pending");
296
-
297
- const serialized = JSON.stringify(capturedSections);
298
- expect(serialized).not.toContain('"outcome":"success"');
299
- expect(serialized).not.toContain("PaymentComplete");
300
- });
301
-
302
- // ── AC-7 — degrade, never crash ──────────────────────────────────────────
303
-
304
- it("every degraded row still ends in a cta section (AC-7 — never a dead end)", async () => {
305
- await renderPage(undefined);
306
- expect(sectionTypes()[sectionTypes().length - 1]).toBe("cta");
307
-
308
- mockGetSession.mockResolvedValue({ ok: false, status: 502, body: {} });
309
- await renderPage("cs_test_outage");
310
- expect(sectionTypes()[sectionTypes().length - 1]).toBe("cta");
311
- });
312
-
313
- // ── AC-2/AC-5 — noindex ───────────────────────────────────────────────────
314
-
315
- it("is not indexable", async () => {
316
- const metadata = await generateMetadata({
317
- params: Promise.resolve({ locale: "en" }),
318
- });
319
- expect(metadata.robots).toEqual({ index: false, follow: true });
320
- });
321
-
322
- // ── #11095 D9, AC-7 — "Open your account" for the paid email ─────────────
323
-
324
- it("a paid read with customerEmail renders Open your account at accountInviteHref, inside a data-sentry-block (AC-7)", async () => {
325
- mockGetSession.mockResolvedValue({
326
- ok: true,
327
- body: { ...PAID_SESSION, customerEmail: "buyer@example.com" },
328
- });
329
- const { getByTestId } = await renderPage("cs_test_abc123");
330
- const link = getByTestId("purchase-success-account");
331
- expect(link.textContent).toBe("copy:success.openAccount");
332
- const expected = accountInviteHref("en", "buyer@example.com");
333
- expect(expected).not.toBeNull();
334
- expect(link.getAttribute("href")).toBe(expected);
335
- expect(link.closest("[data-sentry-block]")).not.toBeNull();
336
- // The sections are unchanged in every state.
337
- expect(sectionTypes()).toEqual(["payment-receipt", "items", "cta"]);
338
- });
339
-
340
- it.each([
341
- ["a paid read without customerEmail", { ok: true, body: PAID_SESSION }],
342
- [
343
- "an unpaid read, even with customerEmail",
344
- {
345
- ok: true,
346
- body: { ...PAID_SESSION, paymentStatus: "unpaid", customerEmail: "buyer@example.com" },
347
- },
348
- ],
349
- ["a 404 read", { ok: false, status: 404, body: { error: "unknown-session" } }],
350
- ])("%s renders no Open your account link (AC-7)", async (_label, response) => {
351
- mockGetSession.mockResolvedValue(response);
352
- const { queryByTestId, queryByText } = await renderPage("cs_test_abc123");
353
- expect(queryByTestId("purchase-success-account")).toBeNull();
354
- expect(queryByText("copy:success.openAccount")).toBeNull();
355
- });
356
-
357
- it("a rejected read renders no Open your account link (AC-7)", async () => {
358
- mockGetSession.mockRejectedValue(new Error("network"));
359
- const { queryByTestId, queryByText } = await renderPage("cs_test_abc123");
360
- expect(queryByTestId("purchase-success-account")).toBeNull();
361
- expect(queryByText("copy:success.openAccount")).toBeNull();
362
- });
363
-
364
- it("sends no referrer (SEC-11095-5)", async () => {
365
- const metadata = await generateMetadata({
366
- params: Promise.resolve({ locale: "en" }),
367
- });
368
- expect(metadata.referrer).toBe("no-referrer");
369
- });
370
-
371
- // ── T-16 / D12 — the request-time commerce-claim gate ───────────────────
372
-
373
- it("answers notFound() when the commerce claim is NOT held, before any API call (D12)", async () => {
374
- mockCheckLicense.mockResolvedValue({ revoked: false, features: [] });
375
-
376
- await expect(renderPage("cs_test_abc123")).rejects.toThrow(
377
- "NEXT_NOT_FOUND",
378
- );
379
- expect(mockNotFound).toHaveBeenCalledTimes(1);
380
- expect(mockGetSession).not.toHaveBeenCalled();
381
- });
382
-
383
- it("renders normally when the commerce claim IS held", async () => {
384
- mockCheckLicense.mockResolvedValue({ revoked: false, features: ["commerce"] });
385
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
386
-
387
- await renderPage("cs_test_abc123");
388
-
389
- expect(mockNotFound).not.toHaveBeenCalled();
390
- expect(sectionTypes()).toEqual(["payment-receipt", "items", "cta"]);
391
- });
392
-
393
- it("fail-closed: answers notFound() when the licence read THROWS (D12's fail-closed direction)", async () => {
394
- mockCheckLicense.mockRejectedValue(new Error("licence read blew up"));
395
-
396
- await expect(renderPage("cs_test_abc123")).rejects.toThrow();
397
- // resolveCommerceClaim() itself is fail-closed (returns false on a
398
- // throw, never propagates) — this page never has to catch anything; it
399
- // just reads the resolver's own answer.
400
- });
401
-
402
- // ── FR-3 — never writes ──────────────────────────────────────────────────
403
-
404
- it("never calls prisma, stripe writes, .create(), .update() or .upsert() (FR-3, grep-style)", async () => {
405
- mockGetSession.mockResolvedValue({ ok: true, body: PAID_SESSION });
406
- await renderPage("cs_test_abc123");
407
-
408
- // The page's only Stripe-adjacent call is the READ wrapper.
409
- expect(mockGetSession).toHaveBeenCalledTimes(1);
410
- });
411
- });