create-ailk 0.38.0 → 0.40.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 (304) hide show
  1. package/dist/add-route.js +16 -1
  2. package/dist/body-heading.d.ts +2 -1
  3. package/dist/body-heading.js +31 -3
  4. package/dist/derive-architecture.js +3 -1
  5. package/dist/module-architecture.js +0 -3
  6. package/dist/remove-module.js +27 -14
  7. package/dist/routes.d.ts +36 -2
  8. package/dist/routes.js +269 -23
  9. package/dist/site-manifest.js +6 -4
  10. package/dist/site-roster.d.ts +11 -3
  11. package/dist/site-roster.js +48 -22
  12. package/dist/surfaces.d.ts +13 -3
  13. package/dist/surfaces.js +128 -194
  14. package/dist/sync-routes.js +22 -5
  15. package/dist/template-record.js +3 -1
  16. package/dist/topology.d.ts +11 -0
  17. package/dist/topology.js +253 -3
  18. package/package.json +3 -3
  19. package/templates/apps/web/CLAUDE.md +32 -4
  20. package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +6 -1
  21. package/templates/apps/web/__tests__/__mocks__/next-intl.ts +6 -1
  22. package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
  23. package/templates/apps/web/account.config.tsx +2 -3
  24. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
  25. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
  26. package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
  27. package/templates/apps/web/app/[locale]/layout.tsx +2 -2
  28. package/templates/apps/web/auth.config.tsx +107 -0
  29. package/templates/apps/web/auth.ts +2 -1
  30. package/templates/apps/web/i18n/request.ts +13 -2
  31. package/templates/apps/web/jest.config.cjs +10 -0
  32. package/templates/apps/web/lib/__tests__/deck-page.test.ts +9 -0
  33. package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +3 -0
  34. package/templates/apps/web/lib/__tests__/in-page-magnet-self-request.test.ts +1 -1
  35. package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +2 -2
  36. package/templates/apps/web/lib/__tests__/pricing-page.test.ts +1 -1
  37. package/templates/apps/web/lib/__tests__/server-api.test.ts +1 -1
  38. package/templates/apps/web/lib/__tests__/structured-data.test.tsx +17 -4
  39. package/templates/apps/web/lib/in-page-magnet.ts +2 -2
  40. package/templates/apps/web/lib/pricing-page.ts +3 -3
  41. package/templates/apps/web/lib/server-api.ts +1 -1
  42. package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-email.ts +1 -1
  43. package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-lines.ts +1 -1
  44. package/templates/apps/web/lib/site-header.ts +1 -1
  45. package/templates/apps/web/lib/topology.generated.ts +5 -0
  46. package/templates/apps/web/messages/en.json +0 -271
  47. package/templates/apps/web/middleware.ts +12 -25
  48. package/templates/apps/web/next.config.mjs +15 -0
  49. package/templates/apps/web/package.json +2 -0
  50. package/templates/apps/web/site-pages.config.tsx +85 -0
  51. package/templates/apps/web/types/messages.d.ts +6 -1
  52. package/templates/tools/body-heading.ts +30 -3
  53. package/versions.json +50 -48
  54. package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +0 -322
  55. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +0 -554
  56. package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/consent-actions.test.ts +0 -56
  57. package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/page.test.tsx +0 -164
  58. package/templates/apps/web/app/[locale]/(auth)/consent/consent-form.tsx +0 -132
  59. package/templates/apps/web/app/[locale]/(auth)/consent/consent.actions.ts +0 -51
  60. package/templates/apps/web/app/[locale]/(auth)/consent/page.tsx +0 -144
  61. package/templates/apps/web/app/[locale]/(auth)/forgot-password/forgot-password-card.tsx +0 -101
  62. package/templates/apps/web/app/[locale]/(auth)/forgot-password/page.tsx +0 -111
  63. package/templates/apps/web/app/[locale]/(auth)/layout.tsx +0 -81
  64. package/templates/apps/web/app/[locale]/(auth)/legal-footnote.tsx +0 -35
  65. package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +0 -179
  66. package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +0 -157
  67. package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +0 -126
  68. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/next-path.test.ts +0 -54
  69. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +0 -628
  70. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +0 -43
  71. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +0 -266
  72. package/templates/apps/web/app/[locale]/(auth)/sign-in/next-path.ts +0 -20
  73. package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +0 -234
  74. package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +0 -37
  75. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +0 -323
  76. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +0 -93
  77. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/page.test.tsx +0 -301
  78. package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +0 -309
  79. package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +0 -201
  80. package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +0 -366
  81. package/templates/apps/web/app/[locale]/(auth)/use-auth-card-flow.ts +0 -116
  82. package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +0 -94
  83. package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +0 -77
  84. package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +0 -154
  85. package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -3
  86. package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -3
  87. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -3
  88. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -2
  89. package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -3
  90. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -12
  91. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -12
  92. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -12
  93. package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -2
  94. package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -12
  95. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -3
  96. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -10
  97. package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -3
  98. package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -3
  99. package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -12
  100. package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -2
  101. package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -3
  102. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -3
  103. package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
  104. package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -3
  105. package/templates/apps/web/app/[locale]/(authed)/leads/__tests__/page.test.tsx +0 -205
  106. package/templates/apps/web/app/[locale]/(authed)/leads/components/LeadsTable.tsx +0 -137
  107. package/templates/apps/web/app/[locale]/(authed)/leads/page.tsx +0 -122
  108. package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ForbiddenState.tsx +0 -24
  109. package/templates/apps/web/app/[locale]/(authed)/waitlist/format.ts +0 -111
  110. package/templates/apps/web/app/[locale]/[slug]/[detail]/__tests__/page.test.tsx +0 -402
  111. package/templates/apps/web/app/[locale]/[slug]/[detail]/page.tsx +0 -143
  112. package/templates/apps/web/app/[locale]/[slug]/__tests__/page.test.tsx +0 -148
  113. package/templates/apps/web/app/[locale]/[slug]/page.tsx +0 -109
  114. package/templates/apps/web/app/[locale]/about/[slug]/page.tsx +0 -46
  115. package/templates/apps/web/app/[locale]/about/__tests__/about-routes.test.tsx +0 -353
  116. package/templates/apps/web/app/[locale]/about/page.tsx +0 -122
  117. package/templates/apps/web/app/[locale]/alternatives/__tests__/page.test.tsx +0 -161
  118. package/templates/apps/web/app/[locale]/alternatives/page.tsx +0 -112
  119. package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +0 -244
  120. package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +0 -325
  121. package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +0 -120
  122. package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +0 -73
  123. package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +0 -497
  124. package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +0 -172
  125. package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +0 -153
  126. package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +0 -141
  127. package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +0 -546
  128. package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +0 -189
  129. package/templates/apps/web/app/[locale]/careers/page.tsx +0 -165
  130. package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +0 -49
  131. package/templates/apps/web/app/[locale]/case-studies/__tests__/hub-children.test.tsx +0 -65
  132. package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +0 -125
  133. package/templates/apps/web/app/[locale]/case-studies/page.tsx +0 -49
  134. package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +0 -85
  135. package/templates/apps/web/app/[locale]/clients/page.tsx +0 -47
  136. package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +0 -249
  137. package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +0 -400
  138. package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-magnet.test.ts +0 -138
  139. package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-text.test.ts +0 -49
  140. package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +0 -494
  141. package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +0 -1122
  142. package/templates/apps/web/app/[locale]/contact/__tests__/intake-analytics.test.ts +0 -51
  143. package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +0 -319
  144. package/templates/apps/web/app/[locale]/contact/contact-form-magnet.ts +0 -77
  145. package/templates/apps/web/app/[locale]/contact/contact-form-text.ts +0 -52
  146. package/templates/apps/web/app/[locale]/contact/contact.actions.ts +0 -403
  147. package/templates/apps/web/app/[locale]/contact/intake-analytics.ts +0 -49
  148. package/templates/apps/web/app/[locale]/contact/intake-script.ts +0 -92
  149. package/templates/apps/web/app/[locale]/contact/page.tsx +0 -267
  150. package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +0 -50
  151. package/templates/apps/web/app/[locale]/courses/__tests__/hub-children.test.tsx +0 -32
  152. package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +0 -123
  153. package/templates/apps/web/app/[locale]/courses/page.tsx +0 -49
  154. package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +0 -57
  155. package/templates/apps/web/app/[locale]/events/__tests__/hub-children.test.tsx +0 -32
  156. package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +0 -164
  157. package/templates/apps/web/app/[locale]/events/__tests__/program-event.test.tsx +0 -120
  158. package/templates/apps/web/app/[locale]/events/page.tsx +0 -60
  159. package/templates/apps/web/app/[locale]/faq/page.tsx +0 -54
  160. package/templates/apps/web/app/[locale]/features/[slug]/page.tsx +0 -54
  161. package/templates/apps/web/app/[locale]/features/__tests__/hub-children.test.tsx +0 -32
  162. package/templates/apps/web/app/[locale]/features/page.tsx +0 -50
  163. package/templates/apps/web/app/[locale]/for/[slug]/page.tsx +0 -54
  164. package/templates/apps/web/app/[locale]/for/__tests__/hub-children.test.tsx +0 -32
  165. package/templates/apps/web/app/[locale]/for/__tests__/page-renderer-migration.test.tsx +0 -90
  166. package/templates/apps/web/app/[locale]/for/page.tsx +0 -51
  167. package/templates/apps/web/app/[locale]/glossary/page.tsx +0 -53
  168. package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +0 -50
  169. package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +0 -78
  170. package/templates/apps/web/app/[locale]/how-to/page.tsx +0 -50
  171. package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +0 -54
  172. package/templates/apps/web/app/[locale]/integrations/__tests__/hub-children.test.tsx +0 -38
  173. package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +0 -141
  174. package/templates/apps/web/app/[locale]/integrations/page.tsx +0 -49
  175. package/templates/apps/web/app/[locale]/launch-service/page.tsx +0 -44
  176. package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +0 -236
  177. package/templates/apps/web/app/[locale]/newsletter/page.tsx +0 -179
  178. package/templates/apps/web/app/[locale]/page.tsx +0 -147
  179. package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +0 -45
  180. package/templates/apps/web/app/[locale]/partners/__tests__/hub-children.test.tsx +0 -32
  181. package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +0 -125
  182. package/templates/apps/web/app/[locale]/partners/page.tsx +0 -49
  183. package/templates/apps/web/app/[locale]/portfolio/[slug]/page.tsx +0 -46
  184. package/templates/apps/web/app/[locale]/portfolio/__tests__/hub-children.test.tsx +0 -38
  185. package/templates/apps/web/app/[locale]/portfolio/page.tsx +0 -50
  186. package/templates/apps/web/app/[locale]/pricing/[slug]/__tests__/page.test.tsx +0 -324
  187. package/templates/apps/web/app/[locale]/pricing/[slug]/page.tsx +0 -87
  188. package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +0 -7
  189. package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +0 -605
  190. package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +0 -219
  191. package/templates/apps/web/app/[locale]/pricing/__tests__/pricing-pages.test.tsx +0 -215
  192. package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +0 -282
  193. package/templates/apps/web/app/[locale]/pricing/page.tsx +0 -120
  194. package/templates/apps/web/app/[locale]/privacy/page.tsx +0 -40
  195. package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +0 -50
  196. package/templates/apps/web/app/[locale]/products/__tests__/hub-children.test.tsx +0 -32
  197. package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +0 -141
  198. package/templates/apps/web/app/[locale]/products/page.tsx +0 -49
  199. package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +0 -37
  200. package/templates/apps/web/app/[locale]/projects/__tests__/hub-children.test.tsx +0 -32
  201. package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +0 -157
  202. package/templates/apps/web/app/[locale]/projects/page.tsx +0 -49
  203. package/templates/apps/web/app/[locale]/purchase-policy/page.tsx +0 -49
  204. package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +0 -54
  205. package/templates/apps/web/app/[locale]/resources/__tests__/hub-children.test.tsx +0 -38
  206. package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +0 -151
  207. package/templates/apps/web/app/[locale]/resources/page.tsx +0 -49
  208. package/templates/apps/web/app/[locale]/services/[slug]/[child]/page.tsx +0 -68
  209. package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +0 -88
  210. package/templates/apps/web/app/[locale]/services/__tests__/hub-children.test.tsx +0 -158
  211. package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +0 -187
  212. package/templates/apps/web/app/[locale]/services/__tests__/service-detail-sections.test.tsx +0 -224
  213. package/templates/apps/web/app/[locale]/services/__tests__/service-families.test.tsx +0 -368
  214. package/templates/apps/web/app/[locale]/services/page.tsx +0 -71
  215. package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +0 -49
  216. package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +0 -81
  217. package/templates/apps/web/app/[locale]/software/page.tsx +0 -49
  218. package/templates/apps/web/app/[locale]/team/[slug]/page.tsx +0 -45
  219. package/templates/apps/web/app/[locale]/team/__tests__/hub-children.test.tsx +0 -32
  220. package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +0 -161
  221. package/templates/apps/web/app/[locale]/team/page.tsx +0 -50
  222. package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +0 -54
  223. package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +0 -82
  224. package/templates/apps/web/app/[locale]/tech-articles/page.tsx +0 -49
  225. package/templates/apps/web/app/[locale]/templates/[slug]/__tests__/page.test.tsx +0 -203
  226. package/templates/apps/web/app/[locale]/templates/[slug]/page.tsx +0 -81
  227. package/templates/apps/web/app/[locale]/templates/__tests__/page.test.tsx +0 -237
  228. package/templates/apps/web/app/[locale]/templates/page.tsx +0 -114
  229. package/templates/apps/web/app/[locale]/terms/page.tsx +0 -40
  230. package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +0 -85
  231. package/templates/apps/web/app/[locale]/testimonials/page.tsx +0 -51
  232. package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +0 -136
  233. package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +0 -39
  234. package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +0 -226
  235. package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +0 -217
  236. package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +0 -106
  237. package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +0 -94
  238. package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe.actions.ts +0 -55
  239. package/templates/apps/web/app/[locale]/vs/[slug]/__tests__/page.test.tsx +0 -100
  240. package/templates/apps/web/app/[locale]/vs/[slug]/page.tsx +0 -60
  241. package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +0 -54
  242. package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +0 -82
  243. package/templates/apps/web/app/[locale]/whitepapers/page.tsx +0 -49
  244. package/templates/apps/web/app/[locale]/working-agreement/__tests__/page.test.tsx +0 -63
  245. package/templates/apps/web/app/[locale]/working-agreement/page.tsx +0 -41
  246. package/templates/apps/web/app/api/auth/[...all]/route.ts +0 -16
  247. package/templates/apps/web/app/api/auth/hub/__tests__/continuation.test.ts +0 -143
  248. package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +0 -749
  249. package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +0 -964
  250. package/templates/apps/web/app/api/auth/hub/authorize/route.ts +0 -390
  251. package/templates/apps/web/app/api/auth/hub/continuation.ts +0 -127
  252. package/templates/apps/web/app/api/auth/hub/continue/[ref]/__tests__/route.test.ts +0 -188
  253. package/templates/apps/web/app/api/auth/hub/continue/[ref]/route.ts +0 -53
  254. package/templates/apps/web/app/api/auth/hub/email/route.ts +0 -111
  255. package/templates/apps/web/app/api/auth/hub/entry-shared.ts +0 -163
  256. package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +0 -86
  257. package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +0 -368
  258. package/templates/apps/web/app/api/auth/hub/password/return.ts +0 -86
  259. package/templates/apps/web/app/api/auth/hub/password/route.ts +0 -171
  260. package/templates/apps/web/app/api/auth/hub/purchase/route.ts +0 -230
  261. package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +0 -174
  262. package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +0 -60
  263. package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +0 -97
  264. package/templates/apps/web/app/api/auth/mcp/__tests__/continuation.test.ts +0 -92
  265. package/templates/apps/web/app/api/auth/mcp/continuation.ts +0 -89
  266. package/templates/apps/web/app/api/auth/mcp/continue/[ref]/__tests__/route.test.ts +0 -59
  267. package/templates/apps/web/app/api/auth/mcp/continue/[ref]/route.ts +0 -41
  268. package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +0 -1166
  269. package/templates/apps/web/app/api/hub-session/callback/route.ts +0 -134
  270. package/templates/apps/web/app/api/hub-session/email/route.ts +0 -125
  271. package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +0 -49
  272. package/templates/apps/web/app/api/hub-session/one-tap/route.ts +0 -106
  273. package/templates/apps/web/app/api/hub-session/open/route.ts +0 -111
  274. package/templates/apps/web/app/api/hub-session/password/return/route.ts +0 -69
  275. package/templates/apps/web/app/api/hub-session/password/route.ts +0 -106
  276. package/templates/apps/web/app/api/hub-session/sign-in/route.ts +0 -91
  277. package/templates/apps/web/app/api/hub-session/sign-out/route.ts +0 -54
  278. package/templates/apps/web/components/sign-out-trigger.tsx +0 -62
  279. package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
  280. package/templates/apps/web/lib/__tests__/hub-children.fixtures.ts +0 -279
  281. package/templates/apps/web/lib/__tests__/route-family.test.ts +0 -57
  282. package/templates/apps/web/lib/__tests__/service-listing.test.ts +0 -111
  283. package/templates/apps/web/lib/__tests__/template-listing.test.ts +0 -158
  284. package/templates/apps/web/lib/auth-routes.ts +0 -125
  285. package/templates/apps/web/lib/hub-children.tsx +0 -351
  286. package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +0 -433
  287. package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +0 -332
  288. package/templates/apps/web/lib/hub-session/config.ts +0 -110
  289. package/templates/apps/web/lib/hub-session/entry.ts +0 -238
  290. package/templates/apps/web/lib/hub-session/index.ts +0 -21
  291. package/templates/apps/web/lib/hub-session/one-tap.tsx +0 -148
  292. package/templates/apps/web/lib/hub-session/reseal.ts +0 -90
  293. package/templates/apps/web/lib/hub-session/seal.ts +0 -86
  294. package/templates/apps/web/lib/hub-session/session.ts +0 -298
  295. package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +0 -277
  296. package/templates/apps/web/lib/meet-placeholder.ts +0 -5
  297. package/templates/apps/web/lib/next-path.ts +0 -35
  298. package/templates/apps/web/lib/posting-title.ts +0 -39
  299. package/templates/apps/web/lib/route-family.ts +0 -69
  300. package/templates/apps/web/lib/service-listing.ts +0 -89
  301. package/templates/apps/web/lib/template-listing.ts +0 -169
  302. package/templates/apps/web/src/lib/__tests__/lead-write.test.ts +0 -187
  303. package/templates/apps/web/src/lib/lead-write.ts +0 -90
  304. /package/templates/apps/web/{app/[locale]/contact → lib}/__tests__/site-contact-lines.test.ts +0 -0
@@ -1,136 +0,0 @@
1
- /**
2
- * Tests for the ThankYouPage detail route (#3960 D6, AC3).
3
- *
4
- * - Populated: getMdxSource returns a real source → renderPage sections mode
5
- * composes the page (JSON-LD + SectionRenderer), no notFound() call.
6
- * - Unknown slug: getMdxSource returns null → renderPage's own detail-route
7
- * branch (no translationsNamespace passed) calls notFound().
8
- */
9
- import React from "react";
10
- import { render } from "@testing-library/react";
11
-
12
- jest.mock("next/navigation", () => ({
13
- __esModule: true,
14
- notFound: jest.fn(() => {
15
- throw new Error("NEXT_NOT_FOUND");
16
- }),
17
- }));
18
-
19
- jest.mock("@working-theory/ui", () => ({
20
- // #7789: renderPage's fallback page head renders inside the section Container.
21
- Container: ({ children }: { children?: React.ReactNode }) =>
22
- React.createElement("div", null, children),
23
- // #4446/#4447: renderPage's own fallback/empty-state title now composes
24
- // Heading (mobile type-budget classes, #4417) instead of a bare <h1>.
25
- Heading: ({
26
- children,
27
- level,
28
- }: {
29
- children: React.ReactNode;
30
- level: number;
31
- }): React.ReactElement =>
32
- React.createElement(`h${level}`, null, children),
33
- SectionRenderer: ({ sections }: { sections: unknown[] }) =>
34
- React.createElement("div", {
35
- "data-testid": "section-renderer",
36
- "data-section-count": String(sections.length),
37
- }),
38
- }));
39
-
40
-
41
- import { existsSync, readFileSync } from "node:fs";
42
- import { join } from "node:path";
43
- import { notFound } from "next/navigation";
44
- import ThankYouSlugPage, { generateMetadata } from "../page";
45
-
46
- const mockNotFound = notFound as jest.MockedFunction<typeof notFound>;
47
-
48
- function makeThankYouSource(slug: string) {
49
- return {
50
- frontmatter: {
51
- type: "ThankYouPage" as const,
52
- slug,
53
- title: "You're all set",
54
- description: "Thanks — we'll be in touch shortly.",
55
- sections: [],
56
- },
57
- body: "",
58
- };
59
- }
60
-
61
- describe("ThankYouSlugPage — detail route", () => {
62
- beforeEach(() => {
63
- mockNotFound.mockClear();
64
- });
65
-
66
- it("renders a seed page through renderPage sections mode", async () => {
67
- const source = makeThankYouSource("flow-thanks");
68
- const getMdxSourcePopulated = jest.fn().mockResolvedValue(source);
69
-
70
- const element = await ThankYouSlugPage({
71
- params: Promise.resolve({ locale: "en", slug: "flow-thanks" }),
72
- getMdxSource: getMdxSourcePopulated,
73
- });
74
- const { container } = render(element);
75
-
76
- expect(getMdxSourcePopulated).toHaveBeenCalledWith(
77
- "ThankYouPage",
78
- "flow-thanks",
79
- "en",
80
- );
81
- expect(mockNotFound).not.toHaveBeenCalled();
82
- expect(
83
- container.querySelector('[data-testid="section-renderer"]'),
84
- ).not.toBeNull();
85
- expect(container.querySelector('[data-testid="json-ld"]')).not.toBeNull();
86
- });
87
-
88
- it("unknown slug calls notFound()", async () => {
89
- const getMdxSourceNull = jest.fn().mockResolvedValue(null);
90
-
91
- await expect(
92
- ThankYouSlugPage({
93
- params: Promise.resolve({ locale: "en", slug: "unknown-slug" }),
94
- getMdxSource: getMdxSourceNull,
95
- }),
96
- ).rejects.toThrow("NEXT_NOT_FOUND");
97
- expect(mockNotFound).toHaveBeenCalled();
98
- });
99
-
100
- it("renders no account hand-off: a user magnet's walk lands on sign-up itself (#10826 D6)", async () => {
101
- const getMdxSource = jest.fn().mockResolvedValue(makeThankYouSource("flow-thanks"));
102
-
103
- const element = await ThankYouSlugPage({
104
- params: Promise.resolve({ locale: "en", slug: "flow-thanks" }),
105
- getMdxSource,
106
- });
107
- const { container } = render(element);
108
-
109
- expect(container.querySelector('[data-testid="account-invite-link"]')).toBeNull();
110
- expect(existsSync(join(__dirname, "..", "AccountInviteLink.tsx"))).toBe(false);
111
- });
112
-
113
- it("stays a server page: the module has no client directive (#8771)", () => {
114
- const source = readFileSync(join(__dirname, "..", "page.tsx"), "utf8");
115
- expect(source).not.toMatch(/["']use client["']/);
116
- });
117
- });
118
-
119
- // #10617 AC-1 — the route's own metadata, read from the real seed, carries
120
- // the noindex directive the page-renderer gives every ThankYouPage.
121
- // The scaffold matrix runs this suite inside a scaffold that ships no
122
- // flow-thanks seed (#10763), so the test skips where the seed does not exist.
123
- const SEED = join(
124
- __dirname, "..", "..", "..", "..", "..", "..", "..",
125
- "content", "en", "ThankYouPage", "flow-thanks.mdx",
126
- );
127
- const itWithSeed = existsSync(SEED) ? it : it.skip;
128
-
129
- describe("ThankYouSlugPage — generateMetadata (#10617)", () => {
130
- itWithSeed("carries robots noindex, follow", async () => {
131
- const metadata = await generateMetadata({
132
- params: Promise.resolve({ locale: "en", slug: "flow-thanks" }),
133
- });
134
- expect(metadata.robots).toEqual({ index: false, follow: true });
135
- });
136
- });
@@ -1,39 +0,0 @@
1
- // ThankYouPage detail page (#3960 D6) — the segment-keyed flow-completion
2
- // redirect target. Sections-mode renderPage (the ContactPage pattern),
3
- // rendered on request under the cookie-reading locale layout; [slug]/page.tsx's
4
- // header says why there is no static-params export (#7379). Unknown slugs 404
5
- // via renderPage's own detail-route branch (no translationsNamespace passed
6
- // — renderPage calls notFound() itself when getMdxSource resolves null).
7
- // `renderPageMetadata` makes every ThankYouPage `noindex, follow` (#10617).
8
- import type { getMdxSource as defaultGetMdxSource } from "@working-theory/page-renderer";
9
- import { renderPage, renderPageMetadata } from "@working-theory/page-renderer";
10
- import type { Metadata } from "next";
11
- import type { ReactElement } from "react";
12
-
13
- interface Props {
14
- params: Promise<{ locale: string; slug: string }>;
15
- getMdxSource?: typeof defaultGetMdxSource;
16
- }
17
-
18
- export async function generateMetadata({
19
- params,
20
- }: Pick<Props, "params">): Promise<Metadata> {
21
- const { locale, slug } = await params;
22
- return renderPageMetadata({ type: "ThankYouPage", slug, locale });
23
- }
24
-
25
- export default async function Page({
26
- params,
27
- getMdxSource,
28
- }: Props): Promise<ReactElement> {
29
- const { locale, slug } = await params;
30
- // #10826 D6 — no account hand-off: a `user` magnet's walk lands on sign-up
31
- // itself, so the walk writes no `/thanks` link any more.
32
- return renderPage({
33
- type: "ThankYouPage",
34
- slug,
35
- locale,
36
- populatedDescriptionTestId: "thank-you-description",
37
- ...(getMdxSource !== undefined && { getMdxSource }),
38
- });
39
- }
@@ -1,226 +0,0 @@
1
- /**
2
- * @jest-environment node
3
- * @jest-environment-options {"customExportConditions": ["react-server", "node", "require", "default"]}
4
- */
5
- // /[locale]/unsubscribe → real RSC render regression test (#8438 D17, the
6
- // #7402 class).
7
- //
8
- // The create-ailk scaffold matrix's `organization-product · Free` leg answered
9
- // `GET /unsubscribe` with a 500: `page.tsx` (a Server Component) handed
10
- // `UnsubscribeButton` ("use client") a `labels.done` FUNCTION, and React
11
- // refuses to serialize a function into the Flight payload ("Functions cannot
12
- // be passed directly to Client Components"). `unsubscribe.test.tsx` renders
13
- // the island in the same jsdom process, so it never crosses the boundary and
14
- // stayed green while the real page crashed.
15
- //
16
- // This suite runs the page through React's own Flight serializer — the same
17
- // `react-server-dom-webpack` server Next uses — under the `react-server`
18
- // export condition, with every `"use client"` module in the render graph
19
- // replaced by a real client reference, exactly as
20
- // `apps/web/__tests__/signed-in-nav-rsc-boundary.test.tsx` does for the
21
- // layout. A function crossing any server→client edge throws the production
22
- // error here.
23
-
24
- import fs from "node:fs";
25
- import path from "node:path";
26
- import { Writable } from "node:stream";
27
-
28
- import type { ReactElement, ReactNode } from "react";
29
-
30
- // Next's compiled Flight server ships no types; it is the renderer Next itself runs.
31
- const flight =
32
- require("next/dist/compiled/react-server-dom-webpack/server.node") as {
33
- createClientModuleProxy: (moduleId: string) => Record<string, unknown>;
34
- renderToPipeableStream: (
35
- model: ReactNode,
36
- manifest: unknown,
37
- options: { onError: (error: unknown) => void },
38
- ) => { pipe: (destination: Writable) => void };
39
- };
40
-
41
- // ── The "use client" boundary ────────────────────────────────────────────────
42
-
43
- const REPO_ROOT = path.resolve(__dirname, "../../../../../..");
44
-
45
- /** This app and every workspace package its imports can resolve into. */
46
- const WORKSPACE_DIRS = [
47
- path.join(REPO_ROOT, "apps/web"),
48
- // `packages-paid` is absent from the public tree the strip derives.
49
- ...["packages", "packages-paid"]
50
- .map((dir) => path.join(REPO_ROOT, dir))
51
- .filter((dir) => fs.existsSync(dir))
52
- .flatMap((dir) => fs.readdirSync(dir).map((pkg) => path.join(dir, pkg))),
53
- ];
54
-
55
- /** A file's directive prologue opens with "use client" (comments may precede it). */
56
- const USE_CLIENT = /^(?:\s|\/\/[^\n]*\n|\/\*[\s\S]*?\*\/)*["']use client["']/;
57
-
58
- /**
59
- * Every source module that marks itself `"use client"` in the trees jest maps
60
- * this app's imports onto: the app itself and the workspace packages' `src/`.
61
- */
62
- function clientModules(): string[] {
63
- const roots = WORKSPACE_DIRS.map((dir) =>
64
- dir.endsWith(path.join("apps", "web")) ? dir : path.join(dir, "src"),
65
- );
66
- const found: string[] = [];
67
- const walk = (dir: string): void => {
68
- if (!fs.existsSync(dir)) return;
69
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
70
- if (["node_modules", ".next", "__tests__", "dist"].includes(entry.name))
71
- continue;
72
- const full = path.join(dir, entry.name);
73
- if (entry.isDirectory()) walk(full);
74
- else if (
75
- /\.tsx?$/.test(entry.name) &&
76
- !/\.(stories|test)\.tsx?$/.test(entry.name)
77
- ) {
78
- if (USE_CLIENT.test(fs.readFileSync(full, "utf8"))) found.push(full);
79
- }
80
- }
81
- };
82
- roots.forEach(walk);
83
- return found;
84
- }
85
-
86
- /**
87
- * The installed `@working-theory/*` packages' built `dist/` trees — the shape a
88
- * create-ailk scaffold runs this test in (#8557). There jest maps nothing onto
89
- * `src/`: `@working-theory/ui` is a tarball under `node_modules`, and its
90
- * Radix-backed primitives carry the directive in their built files. Unmocked,
91
- * they load as server code under the `react-server` condition and throw
92
- * (`React.createContext is not a function`). In the monorepo the symlinked
93
- * workspace package's `dist/` (when built) is walked too; those files are never
94
- * reached, since jest maps the imports onto `src/`, so the extra mocks are inert.
95
- */
96
- function installedClientModules(): string[] {
97
- const scope = path.join(REPO_ROOT, "apps/web/node_modules/@working-theory");
98
- if (!fs.existsSync(scope)) return [];
99
- const found: string[] = [];
100
- const walk = (dir: string): void => {
101
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
102
- const full = path.join(dir, entry.name);
103
- if (entry.isDirectory()) walk(full);
104
- else if (/\.(?:m|c)?js$/.test(entry.name)) {
105
- if (USE_CLIENT.test(fs.readFileSync(full, "utf8"))) found.push(full);
106
- }
107
- }
108
- };
109
- for (const pkg of fs.readdirSync(scope)) {
110
- let dist: string;
111
- try {
112
- dist = path.join(fs.realpathSync(path.join(scope, pkg)), "dist");
113
- } catch {
114
- continue;
115
- }
116
- if (fs.existsSync(dist)) walk(dist);
117
- }
118
- return found;
119
- }
120
-
121
- for (const file of [...clientModules(), ...installedClientModules()]) {
122
- jest.doMock(file, () => flight.createClientModuleProxy(file));
123
- }
124
- // Third-party client entries the primitives barrel reaches (`next/image` via
125
- // `Image.tsx`). pnpm can link a physically distinct `next` per workspace, so
126
- // each entry is mocked at every copy a workspace resolves.
127
- for (const specifier of ["next/link", "next/image", "next/script"]) {
128
- const copies = new Set<string>();
129
- for (const dir of WORKSPACE_DIRS) {
130
- try {
131
- copies.add(require.resolve(specifier, { paths: [dir] }));
132
- } catch {
133
- // This workspace does not depend on `next`.
134
- }
135
- }
136
- for (const file of copies) {
137
- jest.doMock(file, () => flight.createClientModuleProxy(specifier));
138
- }
139
- }
140
- // `next-intl` is path-independent: jest.config.cjs maps every copy onto one stub.
141
- jest.doMock("next-intl", () => flight.createClientModuleProxy("next-intl"));
142
- // #8847 D12 — the page reads the newsletter magnet through
143
- // `lib/in-page-magnet`, whose module graph reaches `contact.actions`' import
144
- // of `next/navigation`. Next serves server code that entry's react-server
145
- // build; under jest it is the client build, which needs a React context, so
146
- // it is stubbed as `signed-in-nav-rsc-boundary.test.tsx` stubs it.
147
- jest.doMock("next/navigation", () => ({
148
- redirect: () => {
149
- throw new Error("redirect");
150
- },
151
- notFound: () => {
152
- throw new Error("NEXT_NOT_FOUND");
153
- },
154
- }));
155
-
156
- // ── Render ───────────────────────────────────────────────────────────────────
157
-
158
- /** Any client-reference id resolves to a chunk-less manifest entry. */
159
- const CLIENT_MANIFEST = new Proxy(
160
- {},
161
- { get: (_target, id) => ({ id: String(id), chunks: [], name: "*" }) },
162
- );
163
-
164
- interface FlightResult {
165
- errors: string[];
166
- payload: string;
167
- }
168
-
169
- /** Serialize the unsubscribe page to a Flight payload, collecting render errors. */
170
- async function renderPageToFlight(
171
- token: string | undefined,
172
- ): Promise<FlightResult> {
173
- // Required, not imported: an `import` would be hoisted above the doMock calls.
174
- const { default: UnsubscribePage } = require("../page") as {
175
- default: (props: {
176
- params: Promise<{ locale: string }>;
177
- searchParams: Promise<{ t?: string }>;
178
- }) => Promise<ReactElement>;
179
- };
180
-
181
- const errors: string[] = [];
182
- const chunks: string[] = [];
183
- await new Promise<void>((resolve, reject) => {
184
- const destination = new Writable({
185
- write(chunk: Buffer, _encoding, done) {
186
- chunks.push(chunk.toString());
187
- done();
188
- },
189
- final(done) {
190
- done();
191
- resolve();
192
- },
193
- });
194
- destination.on("error", reject);
195
- flight
196
- .renderToPipeableStream(
197
- <UnsubscribePage
198
- params={Promise.resolve({ locale: "en" })}
199
- searchParams={Promise.resolve(
200
- token === undefined ? {} : { t: token },
201
- )}
202
- />,
203
- CLIENT_MANIFEST,
204
- { onError: (error) => void errors.push(String(error)) },
205
- )
206
- .pipe(destination);
207
- });
208
- return { errors, payload: chunks.join("") };
209
- }
210
-
211
- describe("/[locale]/unsubscribe crosses the RSC → client boundary cleanly", () => {
212
- it("serializes with a token: nothing callable is handed to the island", async () => {
213
- const { errors, payload } = await renderPageToFlight("tok_1");
214
- expect(errors).toEqual([]);
215
- expect(payload).toContain("unsubscribe-page");
216
- // #8847 D12 — the island gets the token and the magnet's copy as strings.
217
- const props = /"token":"tok_1"[^}]*}/.exec(payload)?.[0] ?? "";
218
- expect(props).toContain('"cta":"Unsubscribe"');
219
- expect(props).toContain('"doneHeadline":"You\'re unsubscribed."');
220
- });
221
-
222
- it("serializes with no token", async () => {
223
- const { errors } = await renderPageToFlight(undefined);
224
- expect(errors).toEqual([]);
225
- });
226
- });
@@ -1,217 +0,0 @@
1
- /**
2
- * Tests for /[locale]/unsubscribe (#8438 D17, AC-3 unsubscribe).
3
- */
4
- import { render, screen, waitFor } from "@testing-library/react";
5
- import userEvent from "@testing-library/user-event";
6
-
7
- /**
8
- * One interpolating translator for both halves of the page: the server half
9
- * (`getTranslations`, the heading and lead) and the client island
10
- * (`useTranslations`, whose done line formats `{description}` in). The
11
- * workspace's mapped `next-intl` stub ignores ICU values, so it is replaced
12
- * here, the way this file already replaces `next-intl/server`.
13
- */
14
- function mockTranslator(ns: string): (key: string, values?: Record<string, unknown>) => string {
15
- const msgs: unknown = require("../../../../messages/en.json");
16
- const dig = (obj: unknown, path: string): unknown =>
17
- path.split(".").reduce<unknown>(
18
- (acc, k) => (acc !== null && typeof acc === "object" ? (acc as Record<string, unknown>)[k] : undefined),
19
- obj,
20
- );
21
- const messages = dig(msgs, ns);
22
- return (key, values) => {
23
- const value = dig(messages, key);
24
- if (typeof value !== "string") return `${ns}.${key}`;
25
- return value.replace(/\{(\w+)\}/g, (m, name: string) =>
26
- values && name in values ? String(values[name]) : m,
27
- );
28
- };
29
- }
30
-
31
- jest.mock("next-intl/server", () => ({
32
- __esModule: true,
33
- getTranslations: async (arg: string | { namespace?: string; locale?: string }) =>
34
- mockTranslator(typeof arg === "string" ? arg : (arg.namespace ?? "")),
35
- }));
36
-
37
- jest.mock("next-intl", () => ({
38
- __esModule: true,
39
- useTranslations: (ns: string) => mockTranslator(ns),
40
- }));
41
-
42
- const mockUnsubscribe = jest.fn();
43
- const mockFlowsGet = jest.fn();
44
- jest.mock("@working-theory/api-client", () => ({
45
- __esModule: true,
46
- consent: { unsubscribe: (...args: unknown[]) => mockUnsubscribe(...args) },
47
- flows: { get: (...args: unknown[]) => mockFlowsGet(...args) },
48
- visitorForwardHeaders: () => undefined,
49
- }));
50
-
51
- jest.mock("next/headers", () => ({
52
- __esModule: true,
53
- headers: jest.fn().mockResolvedValue(new Headers()),
54
- }));
55
-
56
- import Page, { generateMetadata } from "../page";
57
-
58
- const ok = <T,>(body: T) => ({ ok: true, body });
59
- const refusal = (status: number) => ({ ok: false, status, body: null });
60
-
61
- // #8847 D12 — the page's newsletter-magnet read is shared for a few seconds
62
- // per module instance; each test starts an hour later so none sees another's.
63
- let clock = 1_900_000_000_000;
64
- jest.spyOn(Date, "now").mockImplementation(() => clock);
65
-
66
- beforeEach(() => {
67
- clock += 60 * 60 * 1000;
68
- mockUnsubscribe.mockReset();
69
- // The hub unreadable: the seeded newsletterFlowConfig's unsubscribe copy.
70
- mockFlowsGet.mockReset().mockRejectedValue(new Error("hub down"));
71
- });
72
-
73
- async function renderPage(token: string | undefined): Promise<void> {
74
- render(
75
- await Page({
76
- params: Promise.resolve({ locale: "en" }),
77
- searchParams: Promise.resolve(token === undefined ? {} : { t: token }),
78
- }),
79
- );
80
- }
81
-
82
- describe("metadata — noindex, no-referrer (D17, SEC-8438-9)", () => {
83
- it("is noindex and sends no-referrer", async () => {
84
- const meta = await generateMetadata({
85
- params: Promise.resolve({ locale: "en" }),
86
- searchParams: Promise.resolve({}),
87
- });
88
- expect(meta.robots).toEqual({ index: false, follow: true });
89
- expect(meta.referrer).toBe("no-referrer");
90
- });
91
- });
92
-
93
- describe("the page performs no write on GET", () => {
94
- it("renders with no call to unsubscribeAction", async () => {
95
- await renderPage("tok_1");
96
- expect(mockUnsubscribe).not.toHaveBeenCalled();
97
- expect(screen.getByTestId("unsubscribe-page")).toBeInTheDocument();
98
- expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("Unsubscribe");
99
- expect(screen.getByText("Stop getting the newsletter by email?")).toBeInTheDocument();
100
- });
101
- });
102
-
103
- describe("with no token", () => {
104
- it("shows the invalid-link line and no button", async () => {
105
- await renderPage(undefined);
106
- expect(screen.getByTestId("unsubscribe-invalid")).toHaveTextContent("This link isn't valid.");
107
- expect(screen.queryByTestId("unsubscribe-button")).not.toBeInTheDocument();
108
- expect(mockUnsubscribe).not.toHaveBeenCalled();
109
- });
110
- });
111
-
112
- describe("clicking Unsubscribe", () => {
113
- it("a changed answer shows the magnet's done message (#8847 D12)", async () => {
114
- mockUnsubscribe.mockResolvedValue(
115
- ok({ purpose: { id: "marketing_email", description: "product news and offers" }, changed: true }),
116
- );
117
- await renderPage("tok_1");
118
- await userEvent.click(screen.getByTestId("unsubscribe-button"));
119
- expect(mockUnsubscribe).toHaveBeenCalledWith({ token: "tok_1" });
120
- expect(await screen.findByTestId("unsubscribe-done")).toHaveTextContent(
121
- "You're unsubscribed.You won't get the newsletter any more.",
122
- );
123
- });
124
-
125
- it("changed: false shows the already-unsubscribed line, with no second write implied", async () => {
126
- mockUnsubscribe.mockResolvedValue(
127
- ok({ purpose: { id: "marketing_email", description: "product news and offers" }, changed: false }),
128
- );
129
- await renderPage("tok_1");
130
- await userEvent.click(screen.getByTestId("unsubscribe-button"));
131
- expect(await screen.findByTestId("unsubscribe-already")).toHaveTextContent(
132
- "You were already unsubscribed.",
133
- );
134
- });
135
-
136
- it("any 400 shows the invalid-link line", async () => {
137
- mockUnsubscribe.mockResolvedValue(refusal(400));
138
- await renderPage("tok_1");
139
- await userEvent.click(screen.getByTestId("unsubscribe-button"));
140
- expect(await screen.findByTestId("unsubscribe-invalid")).toHaveTextContent("This link isn't valid.");
141
- });
142
-
143
- it("a 429 (rate-limited) shows the unavailable line, never the invalid-link line", async () => {
144
- mockUnsubscribe.mockResolvedValue(refusal(429));
145
- await renderPage("tok_1");
146
- await userEvent.click(screen.getByTestId("unsubscribe-button"));
147
- expect(await screen.findByTestId("unsubscribe-unavailable")).toHaveTextContent(
148
- "Unsubscribing isn't available right now.",
149
- );
150
- expect(screen.queryByTestId("unsubscribe-invalid")).not.toBeInTheDocument();
151
- });
152
-
153
- it("a 5xx shows the unavailable line", async () => {
154
- mockUnsubscribe.mockResolvedValue(refusal(503));
155
- await renderPage("tok_1");
156
- await userEvent.click(screen.getByTestId("unsubscribe-button"));
157
- expect(await screen.findByTestId("unsubscribe-unavailable")).toHaveTextContent(
158
- "Unsubscribing isn't available right now.",
159
- );
160
- });
161
-
162
- it("a thrown error shows the unavailable line, never a crash", async () => {
163
- mockUnsubscribe.mockRejectedValue(new TypeError("fetch failed"));
164
- await renderPage("tok_1");
165
- await userEvent.click(screen.getByTestId("unsubscribe-button"));
166
- expect(await screen.findByTestId("unsubscribe-unavailable")).toBeInTheDocument();
167
- });
168
- });
169
-
170
- describe("the copy comes from the newsletter magnet (#8847 D12, AC-7)", () => {
171
- const unsubscribe = {
172
- title: { en: "Leave" },
173
- body: { en: "Sure?" },
174
- cta: { en: "Leave now" },
175
- done: { headline: { en: "Gone." } },
176
- };
177
-
178
- beforeEach(() => {
179
- const { newsletterFlowConfig } = jest.requireActual("@working-theory/validation") as {
180
- newsletterFlowConfig: Record<string, unknown>;
181
- };
182
- const { completionEmail: _omitted, ...body } = newsletterFlowConfig;
183
- mockFlowsGet.mockReset().mockResolvedValue({ ok: true, status: 200, body: { ...body, unsubscribe } });
184
- });
185
-
186
- it("the title, line and button are the served block's, and so is the done message", async () => {
187
- mockUnsubscribe.mockResolvedValue(
188
- ok({ purpose: { id: "newsletter", description: "This site's newsletter by email" }, changed: true }),
189
- );
190
- await renderPage("tok_1");
191
- expect(mockFlowsGet).toHaveBeenCalledWith("newsletter");
192
- expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("Leave");
193
- expect(screen.getByText("Sure?")).toBeInTheDocument();
194
- expect(screen.getByTestId("unsubscribe-button")).toHaveTextContent("Leave now");
195
- await userEvent.click(screen.getByTestId("unsubscribe-button"));
196
- expect(await screen.findByTestId("unsubscribe-done")).toHaveTextContent("Gone.");
197
- });
198
-
199
- it("generateMetadata's title is the served block's", async () => {
200
- const meta = await generateMetadata({
201
- params: Promise.resolve({ locale: "en" }),
202
- searchParams: Promise.resolve({}),
203
- });
204
- expect(meta.title).toBe("Leave");
205
- });
206
-
207
- it("already still shows the catalog's line", async () => {
208
- mockUnsubscribe.mockResolvedValue(
209
- ok({ purpose: { id: "newsletter", description: "This site's newsletter by email" }, changed: false }),
210
- );
211
- await renderPage("tok_1");
212
- await userEvent.click(screen.getByTestId("unsubscribe-button"));
213
- expect(await screen.findByTestId("unsubscribe-already")).toHaveTextContent(
214
- "You were already unsubscribed.",
215
- );
216
- });
217
- });