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,54 +0,0 @@
1
- /**
2
- * Tests for `resolveNextPath` — the /sign-in `?next=` sanitizer (#4984).
3
- * Foreign, protocol-relative, backslash, control-char, and non-string inputs
4
- * all fall back; plain in-app paths pass through unchanged.
5
- *
6
- * `hrefWithNext` (#9912 D4) — a toggle carries `?next=` only when the page's
7
- * resolved `next` is not its fallback.
8
- */
9
- import { hrefWithNext, resolveNextPath } from "../next-path";
10
-
11
- const FALLBACK = "/account";
12
-
13
- describe("resolveNextPath()", () => {
14
- it.each(["/account", "/en/account?tab=x", "/waitlist#a"])(
15
- "accepts the in-app path %p",
16
- (raw) => {
17
- expect(resolveNextPath(raw, FALLBACK)).toBe(raw);
18
- },
19
- );
20
-
21
- it.each([
22
- ["protocol-relative", "//evil.com"],
23
- ["backslash host trick", "/\\evil.com"],
24
- ["absolute URL", "https://evil.com"],
25
- ["bare host", "evil.com"],
26
- ["embedded space", "/acc ount"],
27
- ["CRLF", "/x\r\ny"],
28
- ["empty string", ""],
29
- ["undefined", undefined],
30
- ["string[] (repeated param)", ["/a"]],
31
- ])("rejects %s → fallback", (_label, raw) => {
32
- expect(resolveNextPath(raw, FALLBACK)).toBe(FALLBACK);
33
- });
34
- });
35
-
36
- describe("hrefWithNext()", () => {
37
- it("the fallback gives the bare href", () => {
38
- expect(hrefWithNext("/sign-up", "/account", "/account")).toBe("/sign-up");
39
- });
40
-
41
- it("any other next rides as ?next=, URL-encoded", () => {
42
- expect(
43
- hrefWithNext("/sign-up", "/api/auth/hub/continue/abc_-1", "/account"),
44
- ).toBe("/sign-up?next=%2Fapi%2Fauth%2Fhub%2Fcontinue%2Fabc_-1");
45
- expect(
46
- hrefWithNext("/fr/sign-in", "/fr/account?tab=x", "/fr/account"),
47
- ).toBe("/fr/sign-in?next=%2Ffr%2Faccount%3Ftab%3Dx");
48
- });
49
-
50
- it("a refused next resolves to the fallback, so its toggle is bare", () => {
51
- const next = resolveNextPath("//evil.example", FALLBACK);
52
- expect(hrefWithNext("/sign-up", next, FALLBACK)).toBe("/sign-up");
53
- });
54
- });
@@ -1,628 +0,0 @@
1
- /**
2
- * Tests for the `/[locale]/sign-in` page (#4984).
3
- *
4
- * Covers:
5
- * (a) OAuth-only (google) → sso body, exactly that provider, no email
6
- * field, no sign-up footer.
7
- * (b) google + github + email → password body with both social buttons,
8
- * still no sign-up footer.
9
- * (c) zero providers → inert card (no buttons, no form, not-configured
10
- * subhead) — never a fabricated session.
11
- * (d) provider click → `signIn.social({ provider, callbackURL: next })`;
12
- * a failed launch renders the providerFailed message.
13
- * (e) a foreign / protocol-relative `?next=` falls back to /account.
14
- * (f) password submit → `signIn.email` with the typed credentials; an
15
- * error result renders the signInFailed message.
16
- * (g) the "Forgot password?" link renders only when the reset predicate is
17
- * true — never a dead end pointing at reset's not-available state
18
- * (#6018 AC-1). (#6068 repointed that predicate from `isResetAvailable()`
19
- * to `resetSendConfigured()`; the mock below binds both to one fn, so
20
- * these cases read identically either way.)
21
- * (h) the email sign-in link (#7435): with "magic-link" active the form
22
- * renders beside the providers (or alone); a `?error=` from a failed
23
- * link maps to fixed copy and is never echoed.
24
- * (i) the hinted email (#8757 D9): a valid single `?email=` is the starting
25
- * value of every email input of the card; an invalid or repeated value,
26
- * or none, leaves them empty as before. It signs no one in.
27
- * (j) the one card (#9662): the site's logo and "Sign in to <site>" from
28
- * the deployment's own data — a crafted query parameter cannot change
29
- * the name — the "Don't have an account? Sign up" line linking
30
- * /sign-up, and the Terms + Privacy acknowledgement.
31
- * (k) the Sign up toggle (#9912 D4): it carries the validated `?next=` to
32
- * /sign-up; a `next` resolveNextPath refuses, or none, gives the bare
33
- * /sign-up.
34
- *
35
- * `next-intl/server` is mocked here against the real en.json, with `{name}`
36
- * placeholders filled from the values passed, so `signIn` copy is asserted
37
- * by its real strings and the heading by the name actually interpolated.
38
- */
39
- import { render, screen, within } from "@testing-library/react";
40
- import userEvent from "@testing-library/user-event";
41
-
42
- const mockGetActiveProviderIds = jest.fn();
43
- const mockIsResetAvailable = jest.fn();
44
- // eslint-disable-next-line no-restricted-syntax -- #507: mock-internal rewrite pending; auth-env.ts is a pure env-introspection module with no external boundary to mock instead.
45
- jest.mock("../../../../../lib/auth-env", () => ({
46
- __esModule: true,
47
- getActiveProviderIds: () => mockGetActiveProviderIds(),
48
- isResetAvailable: () => mockIsResetAvailable(),
49
- // #6068 repointed the forgot link from the flag-only `isResetAvailable()`
50
- // at the send conjunction. This is a PARTIAL module mock, so an absent
51
- // member is `undefined` rather than the real function — the page would
52
- // throw on EVERY render here, not only the two (g) cases. Bound to the SAME
53
- // jest.fn() the flag already drives, so every case below keeps the exact
54
- // truth value and the exact expectation it was written with: no assertion
55
- // in this file changes. Same remedy, same reason, as the sibling
56
- // `auth-pages.test.tsx` mock.
57
- resetSendConfigured: () => mockIsResetAvailable(),
58
- }));
59
-
60
- const mockSocial = jest.fn();
61
- const mockEmail = jest.fn();
62
- jest.mock("better-auth/react", () => ({
63
- __esModule: true,
64
- createAuthClient: () => ({
65
- signIn: {
66
- social: (...args: unknown[]) => mockSocial(...args),
67
- email: (...args: unknown[]) => mockEmail(...args),
68
- },
69
- }),
70
- }));
71
-
72
- // #8790 D2 — the spoke back link. The hub's secret and the registry read are
73
- // the two boundaries the page crosses; the continuation itself is REAL
74
- // (minted below with the same test secret), so the sealed-ref path is covered.
75
- const TEST_SECRET = "test-secret-for-the-sign-in-page-suite";
76
- // eslint-disable-next-line no-restricted-syntax -- #507: mock-internal rewrite pending; auth.ts is Better Auth's server singleton (a DB/HTTP boundary)
77
- jest.mock("../../../../../auth", () => ({
78
- __esModule: true,
79
- resolveSecret: () => TEST_SECRET,
80
- }));
81
- // #11095 D7 — the remembered-method cookie, read through `cookies()`.
82
- const mockCookies: Record<string, string> = {};
83
- jest.mock("next/headers", () => ({
84
- __esModule: true,
85
- cookies: async () => ({
86
- get: (name: string) =>
87
- name in mockCookies ? { name, value: mockCookies[name] } : undefined,
88
- }),
89
- }));
90
- const mockClientInfo = jest.fn();
91
- jest.mock("@working-theory/api-client", () => ({
92
- __esModule: true,
93
- hubSignIn: { clientInfo: (...args: unknown[]) => mockClientInfo(...args) },
94
- }));
95
- // The global shim (__tests__/__mocks__/next-intl-server.ts) returns messages
96
- // uninterpolated; this suite fills `{name}` placeholders so the heading's
97
- // organization name is the one the page actually passed (#9662).
98
- jest.mock("next-intl/server", () => {
99
- const messages = jest.requireActual("../../../../../messages/en.json") as Record<
100
- string,
101
- Record<string, string>
102
- >;
103
- return {
104
- __esModule: true,
105
- getTranslations: async ({ namespace }: { namespace: string }) => {
106
- const catalog = messages[namespace];
107
- const t = (key: string, values?: Record<string, string>): string =>
108
- (catalog?.[key] ?? `${namespace}.${key}`).replace(
109
- /\{(\w+)\}/g,
110
- (match, name: string) => values?.[name] ?? match,
111
- );
112
- t.has = (key: string): boolean => catalog?.[key] !== undefined;
113
- return t;
114
- },
115
- };
116
- });
117
-
118
- import { mintContinuation } from "../../../../api/auth/hub/continuation";
119
- import { SITE_NAME } from "../../../../../lib/site-brand";
120
- import en from "../../../../../messages/en.json";
121
- import Page, { generateMetadata } from "../page";
122
-
123
- async function renderPage(next?: string, error?: string): Promise<void> {
124
- const el = await Page({
125
- params: Promise.resolve({ locale: "en" }),
126
- searchParams: Promise.resolve({
127
- ...(next === undefined ? {} : { next }),
128
- ...(error === undefined ? {} : { error }),
129
- }),
130
- });
131
- render(el);
132
- }
133
-
134
- beforeEach(() => {
135
- for (const name of Object.keys(mockCookies)) delete mockCookies[name];
136
- mockGetActiveProviderIds.mockReset().mockReturnValue(["google"]);
137
- mockIsResetAvailable.mockReset().mockReturnValue(false);
138
- mockSocial.mockReset().mockResolvedValue({ data: {}, error: null });
139
- mockEmail.mockReset().mockResolvedValue({ data: {}, error: null });
140
- });
141
-
142
- describe("generateMetadata()", () => {
143
- it("uses the signIn namespace title + description", async () => {
144
- const meta = await generateMetadata({
145
- params: Promise.resolve({ locale: "en" }),
146
- searchParams: Promise.resolve({}),
147
- });
148
- expect(meta.title).toBe(en.signIn.title);
149
- expect(meta.description).toBe(en.signIn.description);
150
- });
151
- });
152
-
153
- describe("/sign-in page", () => {
154
- it("(a) OAuth-only: sso body with exactly the reported provider, no sign-up footer", async () => {
155
- await renderPage("/account");
156
- expect(screen.getByTestId("sign-in-page")).toBeInTheDocument();
157
- expect(screen.getByTestId("auth-card")).toBeInTheDocument();
158
- expect(screen.getByTestId("auth-sso-google")).toBeInTheDocument();
159
- expect(screen.queryByTestId("auth-sso-github")).toBeNull();
160
- expect(screen.queryByTestId("auth-email")).toBeNull();
161
- expect(screen.queryByTestId("auth-submit")).toBeNull();
162
- expect(screen.queryByTestId("auth-footer-link")).toBeNull();
163
- expect(screen.queryByText(/create an account/i)).toBeNull();
164
- expect(
165
- screen.getByRole("heading", { name: `Sign in to ${SITE_NAME}` }),
166
- ).toBeInTheDocument();
167
- });
168
-
169
- it("(b) email + OAuth: password body with both social buttons, no sign-up footer", async () => {
170
- mockGetActiveProviderIds.mockReturnValue(["google", "github", "email"]);
171
- await renderPage("/account");
172
- expect(screen.getByTestId("auth-email")).toBeInTheDocument();
173
- expect(screen.getByTestId("auth-password")).toBeInTheDocument();
174
- expect(screen.getByTestId("auth-social-row")).toBeInTheDocument();
175
- expect(screen.getByTestId("auth-social-google")).toBeInTheDocument();
176
- expect(screen.getByTestId("auth-social-github")).toBeInTheDocument();
177
- expect(screen.queryByTestId("auth-sso-stack")).toBeNull();
178
- expect(screen.queryByTestId("auth-footer-link")).toBeNull();
179
- });
180
-
181
- it("(c) zero providers: inert card with the not-configured subhead, no buttons, no form", async () => {
182
- mockGetActiveProviderIds.mockReturnValue([]);
183
- await renderPage();
184
- expect(screen.getByTestId("auth-card")).toBeInTheDocument();
185
- expect(screen.queryByTestId("auth-sso-google")).toBeNull();
186
- expect(screen.queryByTestId("auth-sso-github")).toBeNull();
187
- expect(screen.queryByTestId("auth-submit")).toBeNull();
188
- expect(screen.queryByTestId("auth-email")).toBeNull();
189
- expect(
190
- screen.getByText(en.signIn.notConfiguredSubhead),
191
- ).toBeInTheDocument();
192
- expect(mockSocial).not.toHaveBeenCalled();
193
- });
194
-
195
- it("(d) provider click launches signIn.social with the sanitised next path", async () => {
196
- const user = userEvent.setup();
197
- await renderPage("/account");
198
- await user.click(screen.getByTestId("auth-sso-google"));
199
- expect(mockSocial).toHaveBeenCalledTimes(1);
200
- expect(mockSocial).toHaveBeenCalledWith({
201
- provider: "google",
202
- callbackURL: "/account",
203
- });
204
- });
205
-
206
- it("(d) a failed provider launch renders the providerFailed message", async () => {
207
- const user = userEvent.setup();
208
- mockSocial.mockResolvedValue({ data: null, error: { message: "nope" } });
209
- await renderPage("/account");
210
- await user.click(screen.getByTestId("auth-sso-google"));
211
- expect(
212
- await screen.findByText(en.signIn.providerFailed),
213
- ).toBeInTheDocument();
214
- });
215
-
216
- it("(e) a protocol-relative ?next= falls back to /account", async () => {
217
- const user = userEvent.setup();
218
- await renderPage("//evil.com");
219
- await user.click(screen.getByTestId("auth-sso-google"));
220
- expect(mockSocial).toHaveBeenCalledWith({
221
- provider: "google",
222
- callbackURL: "/account",
223
- });
224
- });
225
-
226
- it("(f) password submit calls signIn.email and surfaces signInFailed on error", async () => {
227
- const user = userEvent.setup();
228
- mockGetActiveProviderIds.mockReturnValue(["google", "email"]);
229
- mockEmail.mockResolvedValue({ data: null, error: { message: "bad" } });
230
- await renderPage("/en/account?tab=x");
231
- await user.type(screen.getByTestId("auth-email"), "ada@example.com");
232
- await user.type(screen.getByTestId("auth-password"), "s3cr3t");
233
- await user.click(screen.getByTestId("auth-submit"));
234
- expect(mockEmail).toHaveBeenCalledWith({
235
- email: "ada@example.com",
236
- password: "s3cr3t",
237
- callbackURL: "/en/account?tab=x",
238
- });
239
- expect(await screen.findByText(en.signIn.signInFailed)).toBeInTheDocument();
240
- });
241
-
242
- it("(f) a rejected signIn.email call surfaces signInFailed too (code review, #6018)", async () => {
243
- const user = userEvent.setup();
244
- mockGetActiveProviderIds.mockReturnValue(["google", "email"]);
245
- mockEmail.mockRejectedValue(new Error("network"));
246
- await renderPage("/account");
247
- await user.type(screen.getByTestId("auth-email"), "ada@example.com");
248
- await user.type(screen.getByTestId("auth-password"), "s3cr3t");
249
- await user.click(screen.getByTestId("auth-submit"));
250
- expect(await screen.findByText(en.signIn.signInFailed)).toBeInTheDocument();
251
- });
252
-
253
- it("(g) renders the forgot link when password reset is available", async () => {
254
- mockGetActiveProviderIds.mockReturnValue(["google", "email"]);
255
- mockIsResetAvailable.mockReturnValue(true);
256
- await renderPage("/account");
257
- expect(screen.getByTestId("auth-forgot")).toHaveAttribute(
258
- "href",
259
- "/forgot-password",
260
- );
261
- });
262
-
263
- it("(g) omits the forgot link when password reset is unavailable", async () => {
264
- mockGetActiveProviderIds.mockReturnValue(["google", "email"]);
265
- mockIsResetAvailable.mockReturnValue(false);
266
- await renderPage("/account");
267
- expect(screen.getByTestId("auth-password")).toBeInTheDocument();
268
- expect(screen.queryByTestId("auth-forgot")).toBeNull();
269
- });
270
- });
271
-
272
- describe("/sign-in page — the email sign-in link (#7435)", () => {
273
- it("(h) renders no email-link form when 'magic-link' is not active", async () => {
274
- mockGetActiveProviderIds.mockReturnValue(["google", "email"]);
275
- await renderPage("/account");
276
- expect(screen.queryByTestId("auth-email-link-form")).toBeNull();
277
- });
278
-
279
- it("(h) with google + magic-link: the Google button and 'Email me a sign-in link'", async () => {
280
- mockGetActiveProviderIds.mockReturnValue(["google", "magic-link"]);
281
- await renderPage("/account");
282
- // Google sits under the "or" as a social button, no longer an SSO stack.
283
- expect(screen.getByTestId("auth-social-google")).toBeInTheDocument();
284
- expect(screen.queryByTestId("auth-sso-google")).toBeNull();
285
- expect(screen.getByTestId("auth-submit")).toHaveTextContent(
286
- en.signIn.emailLinkSubmit,
287
- );
288
- expect(en.signIn.emailLinkSubmit).toBe("Send me a magic link");
289
- // One "or" divider between the primary and Google (#8790 D5).
290
- expect(screen.getAllByTestId("auth-divider")).toHaveLength(1);
291
- expect(screen.queryByTestId("auth-email-link-divider")).toBeNull();
292
- });
293
-
294
- it("(h) with magic-link only: the form renders and the not-configured subhead does not", async () => {
295
- mockGetActiveProviderIds.mockReturnValue(["magic-link"]);
296
- await renderPage();
297
- expect(screen.getByTestId("auth-email")).toBeInTheDocument();
298
- expect(screen.queryByText(en.signIn.notConfiguredSubhead)).toBeNull();
299
- // The heading stands alone — no subhead (#8790 D3); #9662 names the site.
300
- expect(
301
- screen.getByRole("heading", { name: `Sign in to ${SITE_NAME}` }),
302
- ).toBeInTheDocument();
303
- expect(en.signIn.heading).toBe("Sign in to {site}");
304
- expect(screen.queryByTestId("auth-method-switch")).toBeNull();
305
- });
306
-
307
- it("(h) beside the password form when the password method is active too", async () => {
308
- mockGetActiveProviderIds.mockReturnValue(["google", "email", "magic-link"]);
309
- await renderPage("/account");
310
- // The sign-in link leads; the password is one quiet switch away, in place
311
- // (#8790 D4), and the typed email survives the switch.
312
- expect(screen.queryByTestId("auth-password")).toBeNull();
313
- expect(screen.getByTestId("auth-submit")).toHaveTextContent(
314
- en.signIn.emailLinkSubmit,
315
- );
316
- const user = userEvent.setup();
317
- await user.type(screen.getByTestId("auth-email"), "member@example.com");
318
- await user.click(screen.getByTestId("auth-method-switch"));
319
- expect(screen.getByTestId("auth-password")).toBeInTheDocument();
320
- expect(screen.getByTestId("auth-email")).toHaveValue("member@example.com");
321
- expect(screen.getByTestId("auth-submit")).toHaveTextContent(
322
- en.signIn.submit,
323
- );
324
- expect(screen.getByTestId("auth-method-switch")).toHaveTextContent(
325
- en.signIn.useEmailLink,
326
- );
327
- });
328
-
329
- it.each(["INVALID_TOKEN", "new_user_signup_disabled"])(
330
- "(h) ?error=%s renders the expired-link notice",
331
- async (error) => {
332
- mockGetActiveProviderIds.mockReturnValue(["google", "magic-link"]);
333
- await renderPage("/account", error);
334
- expect(screen.getByTestId("sign-in-link-notice")).toHaveTextContent(
335
- en.signIn.emailLinkExpired,
336
- );
337
- },
338
- );
339
-
340
- it("(h) any other ?error renders signInFailed and never echoes the value", async () => {
341
- mockGetActiveProviderIds.mockReturnValue(["google", "magic-link"]);
342
- await renderPage("/account", "<script>alert(1)</script>");
343
- expect(screen.getByTestId("sign-in-link-notice")).toHaveTextContent(
344
- en.signIn.signInFailed,
345
- );
346
- expect(document.body.innerHTML).not.toContain("alert(1)");
347
- expect(document.body.innerHTML).not.toContain("&lt;script");
348
- });
349
-
350
- it("(h) no ?error → no notice", async () => {
351
- mockGetActiveProviderIds.mockReturnValue(["google", "magic-link"]);
352
- await renderPage("/account");
353
- expect(screen.queryByTestId("sign-in-link-notice")).toBeNull();
354
- });
355
- });
356
-
357
- describe("/sign-in page — the spoke back link (#8790 D2)", () => {
358
- beforeEach(() => {
359
- mockClientInfo.mockReset();
360
- });
361
-
362
- it("names the spoke from the registry when the continuation opens", async () => {
363
- mockClientInfo.mockResolvedValue({
364
- ok: true,
365
- body: {
366
- clientId: "spoke_1",
367
- name: "Wendi Henry",
368
- origin: "https://wendihenry.com",
369
- },
370
- });
371
- const ref = mintContinuation(
372
- "client_id=spoke_1&response_type=code",
373
- TEST_SECRET,
374
- );
375
- await renderPage(`/api/auth/hub/continue/${ref}`);
376
- expect(mockClientInfo).toHaveBeenCalledWith("spoke_1");
377
- const back = screen.getByTestId("auth-back-link");
378
- // #11095 D5: the spoke's home — its /account would start the hub hop again.
379
- expect(back).toHaveAttribute("href", "https://wendihenry.com/");
380
- // This suite's next-intl shim returns messages uninterpolated, so the
381
- // label's shape is what is asserted here; the ICU fill is next-intl's.
382
- expect(back).toHaveTextContent(/^Back to/);
383
- });
384
-
385
- it("renders no back link when the registry does not know the client", async () => {
386
- mockClientInfo.mockResolvedValue({ ok: false, status: 404 });
387
- const ref = mintContinuation("client_id=spoke_gone", TEST_SECRET);
388
- await renderPage(`/api/auth/hub/continue/${ref}`);
389
- expect(screen.queryByTestId("auth-back-link")).toBeNull();
390
- });
391
-
392
- it("renders no back link on a direct visit", async () => {
393
- await renderPage("/account");
394
- expect(screen.queryByTestId("auth-back-link")).toBeNull();
395
- });
396
-
397
- it("renders no back link, and no error, when the continuation cannot be opened", async () => {
398
- // A continuation-shaped `next` whose ref is garbage: the secret load or
399
- // the open throws, and the page degrades to the direct-visit render.
400
- mockGetActiveProviderIds.mockReturnValue(["google", "magic-link"]);
401
- await renderPage("/api/auth/hub/continue/not-a-real-continuation");
402
- expect(screen.queryByTestId("auth-back-link")).toBeNull();
403
- expect(screen.getByTestId("auth-email")).toBeInTheDocument();
404
- });
405
- });
406
-
407
- describe("/sign-in page — the hinted email (#8757 D9)", () => {
408
- async function renderWithEmail(email?: string | string[]): Promise<void> {
409
- const el = await Page({
410
- params: Promise.resolve({ locale: "en" }),
411
- searchParams: Promise.resolve({
412
- next: "/account",
413
- ...(email === undefined ? {} : { email }),
414
- }),
415
- });
416
- render(el);
417
- }
418
-
419
- function emailInputs(): HTMLInputElement[] {
420
- return Array.from(
421
- document.querySelectorAll<HTMLInputElement>('input[type="email"]'),
422
- );
423
- }
424
-
425
- beforeEach(() => {
426
- // One email input on the card (#8790 D4): the sign-in link and the password share it.
427
- mockGetActiveProviderIds.mockReturnValue(["google", "email", "magic-link"]);
428
- });
429
-
430
- it("(i) ?email=a%40b.example → the card's email input has that value", async () => {
431
- // Next hands the page the decoded value.
432
- await renderWithEmail("a@b.example");
433
- const inputs = emailInputs();
434
- expect(inputs).toHaveLength(1);
435
- expect(screen.getByTestId("auth-email")).toHaveValue("a@b.example");
436
- for (const input of inputs) expect(input).toHaveValue("a@b.example");
437
- // A starting value only — nothing was sent.
438
- expect(mockEmail).not.toHaveBeenCalled();
439
- expect(mockSocial).not.toHaveBeenCalled();
440
- });
441
-
442
- it.each([
443
- ["an invalid value (?email=nope)", "nope"],
444
- [
445
- "a repeated value (?email=a%40b.example&email=c%40d.example)",
446
- ["a@b.example", "c@d.example"],
447
- ],
448
- ["a value carrying a query separator", "a@b.example&next=/x"],
449
- ["no parameter", undefined],
450
- ] as const)(
451
- "(i) %s → empty email inputs, as today",
452
- async (_label, email) => {
453
- await renderWithEmail(
454
- email === undefined || typeof email === "string" ? email : [...email],
455
- );
456
- const inputs = emailInputs();
457
- expect(inputs).toHaveLength(1);
458
- for (const input of inputs) {
459
- expect(input).toHaveValue("");
460
- expect(input).not.toHaveAttribute("value");
461
- }
462
- },
463
- );
464
- });
465
-
466
- describe("/sign-in page — the one card (#9662)", () => {
467
- beforeEach(() => {
468
- mockGetActiveProviderIds.mockReturnValue(["google", "email", "magic-link"]);
469
- });
470
-
471
- it("(j) renders the site's logo and 'Sign in to <site>' from the deployment's data", async () => {
472
- await renderPage("/account");
473
- expect(screen.getByTestId("auth-card-logo")).toBeInTheDocument();
474
- expect(screen.getByRole("heading", { level: 2 })).toHaveTextContent(
475
- `Sign in to ${SITE_NAME}`,
476
- );
477
- expect(screen.getByLabelText(en.signIn.email)).toBe(
478
- screen.getByTestId("auth-email"),
479
- );
480
- expect(en.signIn.email).toBe("Email");
481
- });
482
-
483
- it("(j) a crafted query parameter cannot change the organization name", async () => {
484
- const crafted = "Evil Corp";
485
- expect(SITE_NAME).not.toBe(crafted);
486
- const el = await Page({
487
- params: Promise.resolve({ locale: "en" }),
488
- searchParams: Promise.resolve({
489
- next: `/account?site=${encodeURIComponent(crafted)}`,
490
- site: crafted,
491
- organization: crafted,
492
- name: crafted,
493
- siteName: crafted,
494
- }),
495
- });
496
- render(el);
497
- expect(screen.getByRole("heading", { level: 2 })).toHaveTextContent(
498
- `Sign in to ${SITE_NAME}`,
499
- );
500
- expect(document.body.textContent).not.toContain(crafted);
501
- });
502
-
503
- it("(j) the prospect line toggles to /sign-up, with no trailing period", async () => {
504
- await renderPage("/account");
505
- expect(screen.getByTestId("auth-card-prospect")).toHaveTextContent(
506
- /^Don't have an account\? Sign up$/,
507
- );
508
- expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
509
- "href",
510
- "/sign-up",
511
- );
512
- });
513
-
514
- it("(j) 'Send me a magic link' first, the in-place password switch, then 'or' and Google", async () => {
515
- await renderPage("/account");
516
- expect(screen.getByTestId("auth-submit")).toHaveTextContent(
517
- "Send me a magic link",
518
- );
519
- expect(screen.getByTestId("auth-method-switch")).toHaveTextContent(
520
- "Sign in using password",
521
- );
522
- expect(screen.getByTestId("auth-divider")).toHaveTextContent(/^or$/);
523
- expect(screen.getByTestId("auth-social-google")).toBeInTheDocument();
524
- });
525
-
526
- it("(j) ends on the Terms of Service + Privacy Policy acknowledgement, linking the site's own routes", async () => {
527
- await renderPage("/account");
528
- const footnote = screen.getByTestId("auth-card-footnote");
529
- expect(footnote).toHaveTextContent(
530
- /^You acknowledge that you read, and agree to our Terms of Service and our Privacy Policy\.$/,
531
- );
532
- expect(
533
- within(footnote).getByRole("link", { name: "Terms of Service" }),
534
- ).toHaveAttribute("href", "/terms");
535
- expect(
536
- within(footnote).getByRole("link", { name: "Privacy Policy" }),
537
- ).toHaveAttribute("href", "/privacy");
538
- expect(within(footnote).getAllByRole("link")).toHaveLength(2);
539
- });
540
- });
541
-
542
- describe("/sign-in page — the Sign up toggle keeps the next (#9912 D4)", () => {
543
- beforeEach(() => {
544
- mockClientInfo.mockReset().mockResolvedValue({ ok: false, status: 404 });
545
- });
546
-
547
- it("(k) a continuation next rides the toggle to /sign-up, URL-encoded", async () => {
548
- const ref = mintContinuation("client_id=spoke_1", TEST_SECRET);
549
- const next = `/api/auth/hub/continue/${ref}`;
550
- await renderPage(next);
551
- expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
552
- "href",
553
- `/sign-up?next=${encodeURIComponent(next)}`,
554
- );
555
- });
556
-
557
- it("(k) an in-app next rides the toggle too", async () => {
558
- await renderPage("/account/billing");
559
- expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
560
- "href",
561
- "/sign-up?next=%2Faccount%2Fbilling",
562
- );
563
- });
564
-
565
- it.each([
566
- ["a protocol-relative next", "//evil.example"],
567
- ["an absolute next", "https://evil.example/x"],
568
- ["a backslash next", "/\\evil.example"],
569
- ["a control character", "/x\r\ny"],
570
- ])(
571
- "(k) %s fails resolveNextPath, so the toggle is the bare /sign-up",
572
- async (_label, next) => {
573
- await renderPage(next);
574
- expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
575
- "href",
576
- "/sign-up",
577
- );
578
- },
579
- );
580
-
581
- it("(k) no next: the bare /sign-up", async () => {
582
- await renderPage();
583
- expect(screen.getByTestId("auth-card-prospect-link")).toHaveAttribute(
584
- "href",
585
- "/sign-up",
586
- );
587
- });
588
- });
589
-
590
- // #11095 AC-6 (D7): a returning person's card leads with the provider they
591
- // last launched; a value that does not parse changes nothing.
592
- describe("/sign-in page — the remembered method (#11095 D7)", () => {
593
- it("with ailk-sign-in-method=google: Continue with Google first, no email field, and Use another way restores the card", async () => {
594
- const user = userEvent.setup();
595
- mockGetActiveProviderIds.mockReturnValue(["google", "magic-link"]);
596
- mockCookies["ailk-sign-in-method"] = "google";
597
- await renderPage();
598
- const lead = screen.getByTestId("auth-sso-google");
599
- expect(lead).toHaveTextContent(`${en.signIn.continueWith} ${en.signIn.google}`);
600
- expect(screen.getAllByRole("button")[0]).toBe(lead);
601
- expect(screen.queryByTestId("auth-email")).toBeNull();
602
- const another = screen.getByTestId("sign-in-use-another-way");
603
- expect(another).toHaveTextContent(en.signIn.useAnotherWay);
604
-
605
- await user.click(another);
606
- expect(screen.getByTestId("auth-email")).toBeInTheDocument();
607
- expect(screen.getByTestId("auth-social-google")).toBeInTheDocument();
608
- });
609
-
610
- it.each([
611
- ["evil", ["google", "magic-link"]],
612
- ["github", ["google", "magic-link"]],
613
- ["", ["google", "magic-link"]],
614
- ])(
615
- "a cookie of %j (not an active provider) renders exactly the no-cookie card",
616
- async (value, active) => {
617
- mockGetActiveProviderIds.mockReturnValue(active);
618
- await renderPage();
619
- const today = document.body.innerHTML;
620
- document.body.innerHTML = "";
621
-
622
- mockCookies["ailk-sign-in-method"] = value;
623
- await renderPage();
624
- expect(document.body.innerHTML).toBe(today);
625
- expect(screen.queryByTestId("sign-in-use-another-way")).toBeNull();
626
- },
627
- );
628
- });