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,301 +0,0 @@
1
- /**
2
- * `/sign-up`'s method and its failed-link notice (#9667 D6, AC-3).
3
- *
4
- * With the email sign-in link active, an open `/sign-up` renders AuthCard's
5
- * one-field "Send me a magic link" body; without it, #9662's password or
6
- * provider body. A failed link lands back here with `?error=<code>`, mapped
7
- * to fixed copy and never echoed.
8
- *
9
- * #9912 D4, D5: the page reads `?next=` through `resolveNextPath`, as
10
- * `/sign-in` does. The "Sign in" toggle (open and closed card) carries it, and
11
- * the password, Google and magic-link paths each hand it to Better Auth as
12
- * `callbackURL`, the magic link's failed-link return keeping it too. A `next`
13
- * resolveNextPath refuses, or none, gives `/account` and the bare links.
14
- *
15
- * `next-intl/server` is mocked globally (apps/web/__tests__/setup.ts) against
16
- * the real en.json.
17
- */
18
- import { render, screen } from "@testing-library/react";
19
- import userEvent from "@testing-library/user-event";
20
-
21
- const mockGetActiveProviderIds = jest.fn();
22
- const mockIsSignUpOpen = jest.fn();
23
- // eslint-disable-next-line no-restricted-syntax -- #507: auth-env.ts is a pure env-introspection module with no external boundary to mock instead.
24
- jest.mock("../../../../../lib/auth-env", () => ({
25
- __esModule: true,
26
- getActiveProviderIds: () => mockGetActiveProviderIds(),
27
- isSignUpOpen: () => mockIsSignUpOpen(),
28
- isResetAvailable: () => false,
29
- resetSendConfigured: () => false,
30
- }));
31
-
32
- const mockSocial = jest.fn();
33
- const mockSignUpEmail = jest.fn();
34
- const mockFetch = jest.fn();
35
- jest.mock("better-auth/react", () => ({
36
- __esModule: true,
37
- createAuthClient: () => ({
38
- signIn: {
39
- social: (...args: unknown[]) => mockSocial(...args),
40
- email: jest.fn(),
41
- },
42
- signUp: { email: (...args: unknown[]) => mockSignUpEmail(...args) },
43
- $fetch: (...args: unknown[]) => mockFetch(...args),
44
- }),
45
- }));
46
-
47
- import en from "../../../../../messages/en.json";
48
- import SignUpPage from "../page";
49
-
50
- async function renderSignUp(
51
- searchParams: Record<string, string | string[]> = {},
52
- ): Promise<void> {
53
- render(
54
- await SignUpPage({
55
- params: Promise.resolve({ locale: "en" }),
56
- searchParams: Promise.resolve(searchParams),
57
- }),
58
- );
59
- }
60
-
61
- beforeEach(() => {
62
- mockGetActiveProviderIds.mockReset();
63
- mockIsSignUpOpen.mockReset().mockReturnValue(true);
64
- mockSocial.mockReset().mockResolvedValue({ data: {}, error: null });
65
- mockSignUpEmail.mockReset().mockResolvedValue({ data: {}, error: null });
66
- mockFetch.mockReset().mockResolvedValue({ data: {}, error: null });
67
- });
68
-
69
- describe("the method (D6)", () => {
70
- it('with "magic-link" active: one Email field, Send me a magic link, no password, the agreements, "or" + Google', async () => {
71
- mockGetActiveProviderIds.mockReturnValue(["google", "email", "magic-link"]);
72
- await renderSignUp();
73
- expect(screen.getByTestId("auth-submit")).toHaveTextContent(
74
- en.auth.magicLinkSubmit,
75
- );
76
- expect(screen.queryByTestId("auth-password")).toBeNull();
77
- expect(screen.getByTestId("sign-up-agreements")).toBeInTheDocument();
78
- expect(screen.getByTestId("auth-divider")).toHaveTextContent(
79
- en.auth.orContinue,
80
- );
81
- expect(screen.getByTestId("auth-social-google")).toBeInTheDocument();
82
- });
83
-
84
- it('with only ["google", "email"]: the password body', async () => {
85
- mockGetActiveProviderIds.mockReturnValue(["google", "email"]);
86
- await renderSignUp();
87
- expect(screen.getByTestId("auth-password")).toBeInTheDocument();
88
- expect(screen.getByTestId("auth-submit")).toHaveTextContent(
89
- en.auth.signUpSubmit,
90
- );
91
- });
92
- });
93
-
94
- describe("the failed-link notice (D6)", () => {
95
- beforeEach(() => {
96
- mockGetActiveProviderIds.mockReturnValue(["magic-link"]);
97
- });
98
-
99
- it.each([
100
- ["INVALID_TOKEN", en.auth.signUpLinkExpired],
101
- ["new_user_signup_disabled", en.auth.signUpLinkExpired],
102
- ["AGREEMENTS_REQUIRED", en.auth.signUpAgreementsRequired],
103
- ["AGREEMENTS_UNAVAILABLE", en.auth.signUpFailed],
104
- ])("?error=%s renders its copy", async (error, copy) => {
105
- await renderSignUp({ error });
106
- expect(screen.getByTestId("sign-up-link-notice")).toHaveTextContent(copy);
107
- });
108
-
109
- it("a repeated error reads its first value, and the raw value is never echoed", async () => {
110
- await renderSignUp({ error: ["INVALID_TOKEN", "<b>x</b>"] });
111
- const notice = screen.getByTestId("sign-up-link-notice");
112
- expect(notice).toHaveTextContent(en.auth.signUpLinkExpired);
113
- expect(notice).not.toHaveTextContent("INVALID_TOKEN");
114
- });
115
-
116
- it("no error, no notice", async () => {
117
- await renderSignUp();
118
- expect(screen.queryByTestId("sign-up-link-notice")).toBeNull();
119
- });
120
-
121
- it("the password method shows no link notice", async () => {
122
- mockGetActiveProviderIds.mockReturnValue(["email"]);
123
- await renderSignUp({ error: "INVALID_TOKEN" });
124
- expect(screen.queryByTestId("sign-up-link-notice")).toBeNull();
125
- });
126
- });
127
-
128
- /** A continue path as the hub's authorize step hands it (#8146). */
129
- const CONTINUATION = "/api/auth/hub/continue/AbC-123_xyz";
130
-
131
- /** The three values `resolveNextPath` refuses that a toggle must never echo. */
132
- const REFUSED: ReadonlyArray<[string, string]> = [
133
- ["a protocol-relative next", "//evil.example"],
134
- ["an absolute next", "https://evil.example/x"],
135
- ["a backslash next", "/\\evil.example"],
136
- ];
137
-
138
- /** Each query that carries no `next` a toggle may echo: the refused three, and none. */
139
- const UNCARRIED: Array<[string, Record<string, string>]> = [
140
- ...REFUSED.map(([label, next]): [string, Record<string, string>] => [
141
- label,
142
- { next },
143
- ]),
144
- ["no next", {}],
145
- ];
146
-
147
- /** The completion cases with no `next` to honour: one refused, and none. */
148
- const TO_ACCOUNT: Array<[string, Record<string, string>]> = [
149
- ["a refused next", { next: "//evil.example" }],
150
- ["no next", {}],
151
- ];
152
-
153
- describe("the Sign in toggle keeps the next (#9912 D4)", () => {
154
- beforeEach(() => {
155
- mockGetActiveProviderIds.mockReturnValue(["google", "email"]);
156
- });
157
-
158
- it("carries a validated next on the open card", async () => {
159
- await renderSignUp({ next: "/account/billing" });
160
- expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
161
- "href",
162
- "/sign-in?next=%2Faccount%2Fbilling",
163
- );
164
- });
165
-
166
- it("carries a validated next on the closed (invitation) card", async () => {
167
- mockIsSignUpOpen.mockReturnValue(false);
168
- await renderSignUp({ next: "/account/billing" });
169
- expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
170
- "href",
171
- "/sign-in?next=%2Faccount%2Fbilling",
172
- );
173
- });
174
-
175
- it.each(UNCARRIED)(
176
- "%s gives the bare /sign-in on the open card",
177
- async (_label, query) => {
178
- await renderSignUp(query);
179
- expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
180
- "href",
181
- "/sign-in",
182
- );
183
- },
184
- );
185
-
186
- it.each(UNCARRIED)(
187
- "%s gives the bare /sign-in on the closed card",
188
- async (_label, query) => {
189
- mockIsSignUpOpen.mockReturnValue(false);
190
- await renderSignUp(query);
191
- expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
192
- "href",
193
- "/sign-in",
194
- );
195
- },
196
- );
197
- });
198
-
199
- describe("sign-up completion follows the validated next (#9912 D5)", () => {
200
- async function tickTerms(): Promise<void> {
201
- await userEvent.setup().click(screen.getByTestId("consent-account_terms"));
202
- }
203
-
204
- async function submitPassword(): Promise<void> {
205
- const user = userEvent.setup();
206
- await tickTerms();
207
- await user.type(screen.getByTestId("auth-email"), "ada@example.com");
208
- await user.type(
209
- screen.getByTestId("auth-password"),
210
- "correct horse battery staple",
211
- );
212
- await user.click(screen.getByTestId("auth-submit"));
213
- }
214
-
215
- async function clickGoogle(): Promise<void> {
216
- await tickTerms();
217
- await userEvent.setup().click(screen.getByTestId("auth-social-google"));
218
- }
219
-
220
- async function submitLink(): Promise<void> {
221
- const user = userEvent.setup();
222
- await tickTerms();
223
- await user.type(screen.getByTestId("auth-email"), "ada@example.com");
224
- await user.click(screen.getByTestId("auth-submit"));
225
- }
226
-
227
- describe("with a continuation next", () => {
228
- it("password: signUp.email's callbackURL is the next", async () => {
229
- mockGetActiveProviderIds.mockReturnValue(["google", "email"]);
230
- await renderSignUp({ next: CONTINUATION });
231
- await submitPassword();
232
- expect(mockSignUpEmail).toHaveBeenCalledTimes(1);
233
- expect(mockSignUpEmail.mock.calls[0][0]).toMatchObject({
234
- callbackURL: CONTINUATION,
235
- });
236
- });
237
-
238
- it("Google: signIn.social's callbackURL is the next", async () => {
239
- mockGetActiveProviderIds.mockReturnValue(["google", "email"]);
240
- await renderSignUp({ next: CONTINUATION });
241
- await clickGoogle();
242
- expect(mockSocial).toHaveBeenCalledTimes(1);
243
- expect(mockSocial.mock.calls[0][0]).toMatchObject({
244
- provider: "google",
245
- callbackURL: CONTINUATION,
246
- });
247
- });
248
-
249
- it("magic link: the request's callbackURL is the next and its failed-link return keeps it", async () => {
250
- mockGetActiveProviderIds.mockReturnValue(["google", "magic-link"]);
251
- await renderSignUp({ next: CONTINUATION });
252
- await submitLink();
253
- expect(mockFetch).toHaveBeenCalledTimes(1);
254
- const [path, init] = mockFetch.mock.calls[0] as [
255
- string,
256
- { body: Record<string, unknown> },
257
- ];
258
- expect(path).toBe("/sign-in/magic-link");
259
- expect(init.body.callbackURL).toBe(CONTINUATION);
260
- expect(init.body.errorCallbackURL).toBe(
261
- `/sign-up?next=${encodeURIComponent(CONTINUATION)}`,
262
- );
263
- });
264
- });
265
-
266
- describe.each(TO_ACCOUNT)("with %s", (_label, query) => {
267
- it("password: callbackURL /account", async () => {
268
- mockGetActiveProviderIds.mockReturnValue(["google", "email"]);
269
- await renderSignUp(query);
270
- await submitPassword();
271
- expect(mockSignUpEmail).toHaveBeenCalledTimes(1);
272
- expect(mockSignUpEmail.mock.calls[0][0]).toMatchObject({
273
- callbackURL: "/account",
274
- });
275
- });
276
-
277
- it("Google: callbackURL /account", async () => {
278
- mockGetActiveProviderIds.mockReturnValue(["google", "email"]);
279
- await renderSignUp(query);
280
- await clickGoogle();
281
- expect(mockSocial).toHaveBeenCalledTimes(1);
282
- expect(mockSocial.mock.calls[0][0]).toMatchObject({
283
- provider: "google",
284
- callbackURL: "/account",
285
- });
286
- });
287
-
288
- it("magic link: callbackURL /account and the bare /sign-up return", async () => {
289
- mockGetActiveProviderIds.mockReturnValue(["google", "magic-link"]);
290
- await renderSignUp(query);
291
- await submitLink();
292
- expect(mockFetch).toHaveBeenCalledTimes(1);
293
- const [, init] = mockFetch.mock.calls[0] as [
294
- string,
295
- { body: Record<string, unknown> },
296
- ];
297
- expect(init.body.callbackURL).toBe("/account");
298
- expect(init.body.errorCallbackURL).toBe("/sign-up");
299
- });
300
- });
301
- });
@@ -1,309 +0,0 @@
1
- /**
2
- * Tests for SignUpCard's sign-up agreements (#8438 D13, AC-3; #8765 D10,
3
- * AC-1).
4
- *
5
- * Every submit — the password form and each OAuth provider — is gated by
6
- * the site's `signUp` agreements, rendered as a `ConsentGroup` below
7
- * `AuthCard`. Nothing happens on any entry point until every required
8
- * agreement is ticked. The ticked ids then travel to the server, which
9
- * decides: in the sign-up body, and in a provider launch's `additionalData`.
10
- * A server refusal (`AGREEMENTS_REQUIRED`) is shown on the agreements. No
11
- * cookie carries them any more.
12
- */
13
- import { render, screen, waitFor, within } from "@testing-library/react";
14
- import userEvent from "@testing-library/user-event";
15
-
16
- import messages from "../../../../../messages/en.json";
17
-
18
- const mockSignUpEmail = jest.fn();
19
- const mockSignInSocial = jest.fn();
20
- const mockFetch = jest.fn();
21
- jest.mock("better-auth/react", () => ({
22
- __esModule: true,
23
- createAuthClient: () => ({
24
- signUp: { email: (...args: unknown[]) => mockSignUpEmail(...args) },
25
- signIn: { social: (...args: unknown[]) => mockSignInSocial(...args) },
26
- $fetch: (...args: unknown[]) => mockFetch(...args),
27
- }),
28
- }));
29
-
30
- import { SignUpCard, type SignUpCardProps } from "../sign-up-card";
31
-
32
- const AGREEMENT = {
33
- id: "account_terms",
34
- required: true,
35
- statement: "You agree to our Terms and Privacy Policy.",
36
- };
37
-
38
- function props(overrides: Partial<SignUpCardProps> = {}): SignUpCardProps {
39
- return {
40
- providers: ["google"],
41
- method: "password",
42
- next: "/account",
43
- prospect: { prompt: "Already have an account?", linkLabel: "Sign in", href: "/sign-in" },
44
- footnote: <span>You acknowledge our terms.</span>,
45
- labels: {
46
- signUpHeading: "Sign up",
47
- signUpSubmit: "Sign up",
48
- ssoPrefix: "Continue with",
49
- google: "Google",
50
- github: "GitHub",
51
- email: "Email",
52
- password: "Password",
53
- orContinue: "or continue with",
54
- },
55
- notConfiguredSubhead: "Sign-up is not configured.",
56
- errorLabels: {
57
- signUpFailed: "Sign-up failed.",
58
- providerFailed: "Provider failed.",
59
- agreementsRequired: messages.auth.signUpAgreementsRequired,
60
- },
61
- agreements: [AGREEMENT],
62
- agreementPolicies: { terms: "/terms", privacy: "/privacy" },
63
- agreementsLegend: "Agreements",
64
- locale: "en",
65
- ...overrides,
66
- };
67
- }
68
-
69
- async function fillAndSubmit(): Promise<void> {
70
- const user = userEvent.setup();
71
- await user.type(screen.getByTestId("auth-email"), "ada@example.com");
72
- await user.type(screen.getByTestId("auth-password"), "correct horse battery staple");
73
- await user.click(screen.getByTestId("auth-submit"));
74
- }
75
-
76
- async function tick(purposeId: string): Promise<void> {
77
- const user = userEvent.setup();
78
- await user.click(screen.getByTestId(`consent-${purposeId}`));
79
- }
80
-
81
- beforeEach(() => {
82
- mockSignUpEmail.mockReset().mockResolvedValue({ data: { status: true }, error: null });
83
- mockSignInSocial.mockReset().mockResolvedValue({ data: { status: true }, error: null });
84
- });
85
-
86
- describe("the password submit is gated (AC-3)", () => {
87
- it("renders the agreement, unticked, and the card marked disabled", () => {
88
- render(<SignUpCard {...props()} />);
89
- expect(screen.getByTestId("consent-account_terms")).toHaveAttribute("aria-checked", "false");
90
- expect(screen.getByTestId("sign-up-card-gate")).toHaveAttribute("aria-disabled", "true");
91
- });
92
-
93
- it("does nothing on submit while the agreement is unticked", async () => {
94
- render(<SignUpCard {...props()} />);
95
- await fillAndSubmit();
96
- expect(mockSignUpEmail).not.toHaveBeenCalled();
97
- });
98
-
99
- it("signs up once every required agreement is ticked, the body carrying agreements and locale (#8765 AC-1)", async () => {
100
- render(<SignUpCard {...props()} />);
101
- await tick("account_terms");
102
- expect(screen.getByTestId("sign-up-card-gate")).toHaveAttribute("aria-disabled", "false");
103
- await fillAndSubmit();
104
- expect(mockSignUpEmail).toHaveBeenCalledWith({
105
- email: "ada@example.com",
106
- password: "correct horse battery staple",
107
- name: "ada@example.com",
108
- callbackURL: "/account",
109
- agreements: ["account_terms"],
110
- locale: "en",
111
- });
112
- });
113
-
114
- it("sets no cookie — the server writes the grant with the user (#8765 AC-1)", async () => {
115
- render(<SignUpCard {...props()} />);
116
- await tick("account_terms");
117
- await fillAndSubmit();
118
- expect(mockSignUpEmail).toHaveBeenCalledTimes(1);
119
- expect(document.cookie).toBe("");
120
- });
121
-
122
- it("re-disables after unticking", async () => {
123
- render(<SignUpCard {...props()} />);
124
- await tick("account_terms");
125
- await tick("account_terms");
126
- expect(screen.getByTestId("sign-up-card-gate")).toHaveAttribute("aria-disabled", "true");
127
- await fillAndSubmit();
128
- expect(mockSignUpEmail).not.toHaveBeenCalled();
129
- });
130
-
131
- it("with two required agreements, both must be ticked", async () => {
132
- render(
133
- <SignUpCard
134
- {...props({
135
- agreements: [
136
- AGREEMENT,
137
- { id: "service_terms", required: true, statement: "You agree to being contacted." },
138
- ],
139
- })}
140
- />,
141
- );
142
- await tick("account_terms");
143
- await fillAndSubmit();
144
- expect(mockSignUpEmail).not.toHaveBeenCalled();
145
- await tick("service_terms");
146
- await fillAndSubmit();
147
- expect(mockSignUpEmail).toHaveBeenCalledTimes(1);
148
- });
149
-
150
- });
151
-
152
- describe("the server's answer (#8765 AC-1)", () => {
153
- it("an AGREEMENTS_REQUIRED refusal renders auth.signUpAgreementsRequired inside sign-up-agreements, not on the password field", async () => {
154
- mockSignUpEmail.mockResolvedValue({
155
- data: null,
156
- error: { code: "AGREEMENTS_REQUIRED", message: "Accept the agreements to create an account.", status: 400 },
157
- });
158
- render(<SignUpCard {...props()} />);
159
- await tick("account_terms");
160
- await fillAndSubmit();
161
- const agreements = screen.getByTestId("sign-up-agreements");
162
- await waitFor(() =>
163
- expect(within(agreements).getByRole("alert")).toHaveTextContent(
164
- messages.auth.signUpAgreementsRequired,
165
- ),
166
- );
167
- expect(screen.queryByText("Sign-up failed.")).not.toBeInTheDocument();
168
- });
169
-
170
- it("any other failure keeps the password-field message and no agreements error", async () => {
171
- mockSignUpEmail.mockResolvedValue({
172
- data: null,
173
- error: { code: "PASSWORD_TOO_SHORT", message: "Password too short", status: 400 },
174
- });
175
- render(<SignUpCard {...props()} />);
176
- await tick("account_terms");
177
- await fillAndSubmit();
178
- expect(await screen.findByText("Sign-up failed.")).toBeInTheDocument();
179
- expect(within(screen.getByTestId("sign-up-agreements")).queryByRole("alert")).toBeNull();
180
- });
181
- });
182
-
183
- describe("provider buttons are gated too (AC-3)", () => {
184
- it("a click on Google does nothing while unticked", async () => {
185
- render(<SignUpCard {...props({ method: "sso", providers: ["google"] })} />);
186
- const user = userEvent.setup();
187
- await user.click(screen.getByTestId("auth-sso-google"));
188
- expect(mockSignInSocial).not.toHaveBeenCalled();
189
- });
190
-
191
- it("launches the provider once ticked, the agreements in its additionalData (#8765 AC-1)", async () => {
192
- render(<SignUpCard {...props({ method: "sso", providers: ["google"] })} />);
193
- await tick("account_terms");
194
- const user = userEvent.setup();
195
- await user.click(screen.getByTestId("auth-sso-google"));
196
- expect(mockSignInSocial).toHaveBeenCalledWith({
197
- provider: "google",
198
- callbackURL: "/account",
199
- additionalData: { agreements: ["account_terms"], locale: "en" },
200
- });
201
- expect(document.cookie).toBe("");
202
- });
203
- });
204
-
205
- describe("the magic-link method (#9667 AC-3)", () => {
206
- const linkProps = (overrides: Partial<SignUpCardProps> = {}) =>
207
- props({
208
- method: "magic-link",
209
- labels: {
210
- ...props().labels,
211
- magicLinkSubmit: messages.auth.magicLinkSubmit,
212
- emailLinkDivider: messages.auth.orContinue,
213
- },
214
- errorCallbackURL: "/sign-up",
215
- linkLabels: {
216
- sentHeading: messages.auth.sentHeading,
217
- sentSubhead: messages.auth.sentSubhead,
218
- sentBody: messages.auth.signUpLinkSentBody,
219
- back: messages.auth.signUpLinkBack,
220
- failed: messages.auth.signUpLinkFailed,
221
- rateLimited: messages.auth.signUpLinkRateLimited,
222
- },
223
- ...overrides,
224
- });
225
-
226
- async function requestLink(): Promise<void> {
227
- const user = userEvent.setup();
228
- await user.type(screen.getByTestId("auth-email"), "ada@example.com");
229
- await user.click(screen.getByTestId("auth-submit"));
230
- }
231
-
232
- beforeEach(() => {
233
- mockFetch.mockReset().mockResolvedValue({ data: { status: true }, error: null });
234
- });
235
-
236
- it("renders one Email field, Send me a magic link, no password, the agreements and the providers", () => {
237
- render(<SignUpCard {...linkProps()} />);
238
- expect(screen.getByTestId("auth-submit")).toHaveTextContent(messages.auth.magicLinkSubmit);
239
- expect(screen.queryByTestId("auth-password")).toBeNull();
240
- expect(screen.getByTestId("sign-up-agreements")).toBeInTheDocument();
241
- expect(screen.getByTestId("auth-divider")).toHaveTextContent(messages.auth.orContinue);
242
- expect(screen.getByTestId("auth-social-google")).toBeInTheDocument();
243
- });
244
-
245
- it("does nothing while the agreement is unticked", async () => {
246
- render(<SignUpCard {...linkProps()} />);
247
- await requestLink();
248
- expect(mockFetch).not.toHaveBeenCalled();
249
- });
250
-
251
- it("once ticked, POSTs /sign-in/magic-link once with the agreements in metadata, then shows the sent card", async () => {
252
- render(<SignUpCard {...linkProps()} />);
253
- await tick("account_terms");
254
- await requestLink();
255
- expect(mockFetch).toHaveBeenCalledTimes(1);
256
- expect(mockFetch).toHaveBeenCalledWith("/sign-in/magic-link", {
257
- method: "POST",
258
- body: {
259
- email: "ada@example.com",
260
- name: "ada@example.com",
261
- callbackURL: "/account",
262
- errorCallbackURL: "/sign-up",
263
- metadata: { agreements: ["account_terms"], locale: "en" },
264
- },
265
- });
266
- expect(await screen.findByTestId("auth-sent-body")).toHaveTextContent(
267
- messages.auth.signUpLinkSentBody,
268
- );
269
- expect(mockSignUpEmail).not.toHaveBeenCalled();
270
- });
271
-
272
- it("an AGREEMENTS_REQUIRED answer is shown on the agreements", async () => {
273
- mockFetch.mockResolvedValue({
274
- data: null,
275
- error: { code: "AGREEMENTS_REQUIRED", status: 400 },
276
- });
277
- render(<SignUpCard {...linkProps()} />);
278
- await tick("account_terms");
279
- await requestLink();
280
- const agreements = screen.getByTestId("sign-up-agreements");
281
- await waitFor(() =>
282
- expect(within(agreements).getByRole("alert")).toHaveTextContent(
283
- messages.auth.signUpAgreementsRequired,
284
- ),
285
- );
286
- });
287
-
288
- it.each([
289
- [429, messages.auth.signUpLinkRateLimited],
290
- [400, messages.auth.signUpLinkFailed],
291
- ])("a %s answer shows its copy and no sent card", async (status, copy) => {
292
- mockFetch.mockResolvedValue({
293
- data: null,
294
- error: { code: status === 400 ? "SIGN_UP_CLOSED" : undefined, status },
295
- });
296
- render(<SignUpCard {...linkProps()} />);
297
- await tick("account_terms");
298
- await requestLink();
299
- expect(await screen.findByText(copy)).toBeInTheDocument();
300
- expect(screen.queryByTestId("auth-sent-body")).toBeNull();
301
- });
302
-
303
- it("renders a link notice above the card", () => {
304
- render(<SignUpCard {...linkProps({ linkNotice: messages.auth.signUpLinkExpired })} />);
305
- expect(screen.getByTestId("sign-up-link-notice")).toHaveTextContent(
306
- messages.auth.signUpLinkExpired,
307
- );
308
- });
309
- });