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,497 +0,0 @@
1
- /**
2
- * The job page's apply action (#8746 D4, D5; AC-5): a submission writes one
3
- * lead through the site's lead writer with source `flow:job-application`,
4
- * `name` = first + last, and the posting's slug as the hidden `job` value.
5
- */
6
-
7
- import {
8
- __resetRateLimit,
9
- checkRateLimit,
10
- } from "../../../../src/lib/rate-limit";
11
- import { captureLeadAction } from "../[slug]/apply.actions";
12
-
13
- // #9255 — the write bot check's verdict. `checkBotId` reads Vercel's
14
- // request context, which jest has none of, so every case decides it here.
15
- const checkBotIdMock = jest.fn();
16
- jest.mock("botid/server", () => ({
17
- checkBotId: (...args: unknown[]) => checkBotIdMock(...args),
18
- }));
19
-
20
- jest.mock("@working-theory/api-client", () => ({
21
- leads: { submit: jest.fn() },
22
- visitorForwardHeaders: jest.requireActual("@working-theory/api-client")
23
- .visitorForwardHeaders,
24
- }));
25
-
26
- jest.mock("next/headers", () => ({
27
- __esModule: true,
28
- headers: jest.fn().mockResolvedValue({ get: () => null }),
29
- cookies: jest.fn().mockResolvedValue({ get: () => undefined }),
30
- }));
31
-
32
- const mockGetLocale = jest.fn();
33
- const mockGetTranslations = jest.fn();
34
- jest.mock("next-intl/server", () => ({
35
- getLocale: (...args: unknown[]) => mockGetLocale(...args),
36
- getTranslations: (...args: unknown[]) => mockGetTranslations(...args),
37
- }));
38
-
39
- const mockInviteHref = jest.fn();
40
- // eslint-disable-next-line no-restricted-syntax -- accountInviteHref reads the generated topology (build output); this file asserts the action's own decision
41
- jest.mock("../../../../lib/account-invite", () => ({
42
- accountInviteHref: (...args: unknown[]) => mockInviteHref(...args),
43
- }));
44
-
45
- import { leads } from "@working-theory/api-client";
46
- import { headers } from "next/headers";
47
- const mockSubmit = leads.submit as jest.Mock;
48
- const mockHeaders = headers as jest.Mock;
49
-
50
- const JOB = "content-strategist";
51
-
52
- function form(fields: Record<string, string>): FormData {
53
- const fd = new FormData();
54
- for (const [key, value] of Object.entries(fields)) fd.append(key, value);
55
- return fd;
56
- }
57
-
58
- const VALID = {
59
- first_name: "Ada",
60
- last_name: "Lovelace",
61
- email: "ada@example.com",
62
- consent: "true",
63
- };
64
-
65
- type SubmitBody = {
66
- source: string;
67
- email: string;
68
- consent?: boolean;
69
- payload: Record<string, unknown>;
70
- };
71
- const submitted = (): SubmitBody => mockSubmit.mock.calls[0][0] as SubmitBody;
72
-
73
- beforeEach(() => {
74
- mockSubmit.mockResolvedValue({ ok: true, status: 201, body: { ok: true } });
75
- mockGetLocale.mockResolvedValue("en");
76
- mockGetTranslations.mockResolvedValue((key: string) =>
77
- key === "trackInAccount" ? "Track this in your account" : key,
78
- );
79
- mockInviteHref.mockReturnValue("/sign-in?next=%2Faccount&email=ada%40example.com");
80
- });
81
-
82
- afterEach(() => {
83
- jest.clearAllMocks();
84
- mockHeaders.mockResolvedValue({ get: () => null });
85
- __resetRateLimit();
86
- delete process.env.AILK_LEAD_SITE;
87
- });
88
-
89
- describe("captureLeadAction on a job page (#8746 AC-5)", () => {
90
- // On Vercel, where the edge-set address is read (#9967 D1); the bot check
91
- // has its own suite below.
92
- const LIMIT_ENV_KEYS = ["VERCEL", "AILK_BOT_CHECK"] as const;
93
- const priorLimitEnv = new Map(
94
- LIMIT_ENV_KEYS.map((name) => [name, process.env[name]]),
95
- );
96
- beforeEach(() => {
97
- process.env.VERCEL = "1";
98
- process.env.AILK_BOT_CHECK = "off";
99
- });
100
- afterEach(() => {
101
- for (const [name, value] of priorLimitEnv) {
102
- if (value === undefined) delete process.env[name];
103
- else process.env[name] = value;
104
- }
105
- });
106
-
107
- it("writes one flow:job-application lead with name = first + last and the hidden job slug", async () => {
108
- const result = await captureLeadAction(JOB, null, form(VALID));
109
-
110
- expect(result).toEqual({ kind: "success" });
111
- expect(mockSubmit).toHaveBeenCalledTimes(1);
112
- const body = submitted();
113
- expect(body.source).toBe("flow:job-application");
114
- expect(body.email).toBe("ada@example.com");
115
- expect(body.payload).toEqual({
116
- name: "Ada Lovelace",
117
- first_name: "Ada",
118
- last_name: "Lovelace",
119
- job: JOB,
120
- page: "careers",
121
- });
122
- expect(body).not.toHaveProperty("siteId");
123
- });
124
-
125
- it("sends the accepted terms as the body's top-level consent: true, never inside payload (#9130)", async () => {
126
- await captureLeadAction(JOB, null, form(VALID));
127
-
128
- const body = submitted();
129
- expect(body.consent).toBe(true);
130
- expect(body.payload).not.toHaveProperty("consent");
131
- });
132
-
133
- it("carries phone and a LinkedIn URL, a bare domain gaining https://", async () => {
134
- await captureLeadAction(
135
- JOB,
136
- null,
137
- form({
138
- ...VALID,
139
- phone: "+1 555 0100",
140
- linkedin_url: "linkedin.com/in/ada",
141
- }),
142
- );
143
- expect(submitted().payload).toMatchObject({
144
- phone: "+1 555 0100",
145
- linkedin_url: "https://linkedin.com/in/ada",
146
- });
147
- });
148
-
149
- it("keeps an extra field the owner added to the magnet, and no field overrides job, name or source", async () => {
150
- await captureLeadAction(
151
- JOB,
152
- null,
153
- form({
154
- ...VALID,
155
- cover_letter: "Hello",
156
- job: "other-job",
157
- name: "Mallory",
158
- source: "web",
159
- }),
160
- );
161
- const body = submitted();
162
- expect(body.source).toBe("flow:job-application");
163
- expect(body.payload).toMatchObject({
164
- cover_letter: "Hello",
165
- job: JOB,
166
- name: "Ada Lovelace",
167
- });
168
- });
169
-
170
- it.each([
171
- ["first_name", { ...VALID, first_name: " " }],
172
- ["last_name", { ...VALID, last_name: "" }],
173
- ["email", { ...VALID, email: "not-an-email" }],
174
- ["linkedin_url", { ...VALID, linkedin_url: "not a url" }],
175
- ["linkedin_url", { ...VALID, linkedin_url: "javascript:alert(1)" }],
176
- [
177
- "linkedin_url",
178
- { ...VALID, linkedin_url: "https://linkedin.com@evil.example/in/ada" },
179
- ],
180
- ["consent", { ...VALID, consent: "" }],
181
- ])(
182
- "refuses a bad %s with a field error and sends nothing",
183
- async (field, fields) => {
184
- const result = await captureLeadAction(JOB, null, form(fields));
185
- expect(result).toMatchObject({
186
- kind: "error",
187
- fieldErrors: { [field]: expect.any(String) },
188
- });
189
- expect(mockSubmit).not.toHaveBeenCalled();
190
- },
191
- );
192
-
193
- it("refuses a job value that is not a slug, sending nothing", async () => {
194
- const result = await captureLeadAction("../../etc", null, form(VALID));
195
- expect(result).toMatchObject({ kind: "error" });
196
- expect(mockSubmit).not.toHaveBeenCalled();
197
- });
198
-
199
- it.each([[["eng-lead"]], [123]])(
200
- "refuses a bound job of the wrong type (%p), sending nothing",
201
- async (job) => {
202
- // eslint-disable-next-line no-restricted-syntax -- a tampered bound argument is exactly a value of the wrong type
203
- const tampered = job as unknown as string;
204
- const result = await captureLeadAction(tampered, null, form(VALID));
205
- expect(result).toMatchObject({ kind: "error" });
206
- expect(mockSubmit).not.toHaveBeenCalled();
207
- },
208
- );
209
-
210
- it("reads host:port without a scheme as a bare domain", async () => {
211
- await captureLeadAction(
212
- JOB,
213
- null,
214
- form({ ...VALID, linkedin_url: "www.linkedin.com:443/in/ada" }),
215
- );
216
- expect(submitted().payload).toMatchObject({
217
- linkedin_url: "https://www.linkedin.com:443/in/ada",
218
- });
219
- });
220
-
221
- it("shares /contact's per-visitor bucket", async () => {
222
- mockHeaders.mockResolvedValue({
223
- get: (name: string) =>
224
- name === "x-vercel-forwarded-for" ? "203.0.113.7" : null,
225
- });
226
- for (let i = 0; i < 30; i += 1)
227
- checkRateLimit("contact:203.0.113.7", 30, 10 * 60 * 1000);
228
- expect(await captureLeadAction(JOB, null, form(VALID))).toMatchObject({
229
- kind: "error",
230
- });
231
- expect(mockSubmit).not.toHaveBeenCalled();
232
- });
233
-
234
- it("answers a filled honeypot as success and sends nothing", async () => {
235
- const result = await captureLeadAction(
236
- JOB,
237
- null,
238
- form({ ...VALID, ailk_hp: "bot" }),
239
- );
240
- expect(result).toEqual({ kind: "success" });
241
- expect(mockSubmit).not.toHaveBeenCalled();
242
- });
243
-
244
- it("maps lead_capture_not_configured and an unreachable API to unavailable", async () => {
245
- mockSubmit.mockResolvedValueOnce({
246
- ok: false,
247
- status: 503,
248
- body: { error: "lead_capture_not_configured" },
249
- });
250
- expect(await captureLeadAction(JOB, null, form(VALID))).toEqual({
251
- kind: "unavailable",
252
- });
253
- mockSubmit.mockRejectedValueOnce(new Error("fetch failed"));
254
- expect(await captureLeadAction(JOB, null, form(VALID))).toEqual({
255
- kind: "unavailable",
256
- });
257
- });
258
-
259
- it("answers any other refusal with the generic error", async () => {
260
- mockSubmit.mockResolvedValueOnce({
261
- ok: false,
262
- status: 400,
263
- body: { error: "invalid" },
264
- });
265
- expect(await captureLeadAction(JOB, null, form(VALID))).toMatchObject({
266
- kind: "error",
267
- message: expect.any(String),
268
- });
269
- });
270
-
271
- it("limits one visitor to 30 applications per 10 minutes", async () => {
272
- mockHeaders.mockResolvedValue({
273
- get: (name: string) =>
274
- name === "x-vercel-forwarded-for" ? "203.0.113.9" : null,
275
- });
276
- for (let i = 0; i < 30; i += 1) {
277
- expect(await captureLeadAction(JOB, null, form(VALID))).toEqual({
278
- kind: "success",
279
- });
280
- }
281
- expect(await captureLeadAction(JOB, null, form(VALID))).toMatchObject({
282
- kind: "error",
283
- });
284
- expect(mockSubmit).toHaveBeenCalledTimes(30);
285
- });
286
-
287
- it("charges a visitor with no readable address /contact's shared bucket, never skips it (#9967)", async () => {
288
- // A client-sent x-forwarded-for is no address: it changes on every post.
289
- let n = 0;
290
- mockHeaders.mockImplementation(async () => {
291
- n += 1;
292
- return {
293
- get: (name: string) =>
294
- name === "x-forwarded-for" ? `10.0.${n >> 8}.${n & 255}` : null,
295
- };
296
- });
297
- for (let i = 0; i < 300; i += 1) {
298
- expect(await captureLeadAction(JOB, null, form(VALID))).toEqual({
299
- kind: "success",
300
- });
301
- }
302
- expect(await captureLeadAction(JOB, null, form(VALID))).toMatchObject({
303
- kind: "error",
304
- });
305
- expect(mockSubmit).toHaveBeenCalledTimes(300);
306
- });
307
- });
308
-
309
- describe("the thank-you's account link (#8771 AC-6)", () => {
310
- const invite = () =>
311
- mockSubmit.mockResolvedValue({
312
- ok: true,
313
- status: 201,
314
- body: { ok: true, next: { completion: "invite" } },
315
- });
316
-
317
- it("an invite answer returns the prefilled link and label", async () => {
318
- invite();
319
-
320
- const result = await captureLeadAction(JOB, null, form(VALID));
321
-
322
- expect(result).toEqual({
323
- kind: "success",
324
- next: {
325
- href: "/sign-in?next=%2Faccount&email=ada%40example.com",
326
- label: "Track this in your account",
327
- },
328
- });
329
- expect(mockInviteHref).toHaveBeenCalledWith("en", "ada@example.com");
330
- });
331
-
332
- it.each([
333
- ["no next", { ok: true }],
334
- ["a checkout next", { ok: true, next: { completion: "checkout", checkoutOffering: "retainer" } }],
335
- ])("%s: exactly { kind: 'success' }", async (_name, body) => {
336
- mockSubmit.mockResolvedValue({ ok: true, status: 201, body });
337
-
338
- await expect(captureLeadAction(JOB, null, form(VALID))).resolves.toEqual({ kind: "success" });
339
- expect(mockInviteHref).not.toHaveBeenCalled();
340
- });
341
-
342
- it("a site with no sign-in (href null) is exactly { kind: 'success' }", async () => {
343
- invite();
344
- mockInviteHref.mockReturnValue(null);
345
- await expect(captureLeadAction(JOB, null, form(VALID))).resolves.toEqual({ kind: "success" });
346
- });
347
-
348
- it.each([
349
- ["getLocale", () => mockGetLocale.mockRejectedValue(new Error("x"))],
350
- ["accountInviteHref", () => mockInviteHref.mockImplementation(() => { throw new Error("x"); })],
351
- ["getTranslations", () => mockGetTranslations.mockRejectedValue(new Error("x"))],
352
- ])("a throw from %s after the write is still a success", async (_name, arm) => {
353
- invite();
354
- arm();
355
- await expect(captureLeadAction(JOB, null, form(VALID))).resolves.toEqual({ kind: "success" });
356
- expect(mockSubmit).toHaveBeenCalledTimes(1);
357
- });
358
-
359
- it("a filled honeypot is exactly { kind: 'success' } and writes nothing", async () => {
360
- const result = await captureLeadAction(JOB, null, form({ ...VALID, ailk_hp: "http://x" }));
361
- expect(result).toEqual({ kind: "success" });
362
- expect(mockSubmit).not.toHaveBeenCalled();
363
- });
364
- });
365
-
366
- // #9255 D4 — the write bot check runs after the honeypot, the consent and
367
- // the schema, immediately before the write (spec
368
- // docs/specs/9255-an-edge-bot-challenge-in-spec.md §5.1 AC-2).
369
- describe("captureLeadAction on a job page — the write bot check (#9255)", () => {
370
- const BOT = { isHuman: false, isBot: true, isVerifiedBot: false, bypassed: false };
371
- const HUMAN = { ...BOT, isHuman: true, isBot: false };
372
- const BOT_ENV_KEYS = ["VERCEL", "AILK_BOT_CHECK", "AILK_BOOKING_BOT_CHECK"] as const;
373
- const priorBotEnv = new Map(BOT_ENV_KEYS.map((name) => [name, process.env[name]]));
374
-
375
- let botLogSpies: jest.SpyInstance[] = [];
376
-
377
- beforeEach(() => {
378
- checkBotIdMock.mockReset();
379
- for (const name of BOT_ENV_KEYS) delete process.env[name];
380
- process.env.VERCEL = "1";
381
- botLogSpies = [
382
- jest.spyOn(console, "warn").mockImplementation(() => undefined),
383
- jest.spyOn(console, "error").mockImplementation(() => undefined),
384
- ];
385
- });
386
-
387
- afterEach(() => {
388
- for (const [name, value] of priorBotEnv) {
389
- if (value === undefined) delete process.env[name];
390
- else process.env[name] = value;
391
- }
392
- for (const spy of botLogSpies) spy.mockRestore();
393
- });
394
-
395
- it("a bot gets the generic error, and nothing is sent", async () => {
396
- checkBotIdMock.mockResolvedValue(BOT);
397
- expect(await captureLeadAction(JOB, null, form(VALID))).toStrictEqual({
398
- kind: "error",
399
- message: "Something went wrong, please try again.",
400
- });
401
- expect(checkBotIdMock).toHaveBeenCalledTimes(1);
402
- expect(mockSubmit).not.toHaveBeenCalled();
403
- });
404
-
405
- it("a check that fails is unavailable, and nothing is sent", async () => {
406
- checkBotIdMock.mockRejectedValue(new Error("boom"));
407
- expect(await captureLeadAction(JOB, null, form(VALID))).toStrictEqual({ kind: "unavailable" });
408
- expect(mockSubmit).not.toHaveBeenCalled();
409
- });
410
-
411
- it("a human sends exactly what the check off sends", async () => {
412
- checkBotIdMock.mockResolvedValue(HUMAN);
413
- delete process.env.VERCEL;
414
- await captureLeadAction(JOB, null, form(VALID));
415
- process.env.VERCEL = "1";
416
- expect(await captureLeadAction(JOB, null, form(VALID))).toEqual({ kind: "success" });
417
- expect(checkBotIdMock).toHaveBeenCalledTimes(1);
418
- expect(mockSubmit).toHaveBeenCalledTimes(2);
419
- expect(mockSubmit.mock.calls[1]).toEqual(mockSubmit.mock.calls[0]);
420
- });
421
-
422
- it("a filled honeypot answers success with no check", async () => {
423
- checkBotIdMock.mockResolvedValue(BOT);
424
- expect(await captureLeadAction(JOB, null, form({ ...VALID, ailk_hp: "spam" }))).toEqual({
425
- kind: "success",
426
- });
427
- expect(checkBotIdMock).not.toHaveBeenCalled();
428
- });
429
-
430
- it("a post without consent answers the consent error with no check", async () => {
431
- checkBotIdMock.mockResolvedValue(BOT);
432
- const { consent: _consent, ...unticked } = VALID;
433
- expect(await captureLeadAction(JOB, null, form(unticked))).toEqual({
434
- kind: "error",
435
- fieldErrors: { consent: expect.any(String) },
436
- });
437
- expect(checkBotIdMock).not.toHaveBeenCalled();
438
- });
439
- });
440
-
441
- describe("captureLeadAction records the posting's named flow (#10054 D6, AC-7)", () => {
442
- const ENV_KEYS = ["VERCEL", "AILK_BOT_CHECK"] as const;
443
- const prior = new Map(ENV_KEYS.map((name) => [name, process.env[name]]));
444
- beforeEach(() => {
445
- process.env.VERCEL = "1";
446
- process.env.AILK_BOT_CHECK = "off";
447
- });
448
- afterEach(() => {
449
- for (const [name, value] of prior) {
450
- if (value === undefined) delete process.env[name];
451
- else process.env[name] = value;
452
- }
453
- });
454
-
455
- const NAMED = { job: "writer", flow: "writer-application" };
456
-
457
- it("writes applicationFlow beside job, keeping the Job application source and consent", async () => {
458
- expect(await captureLeadAction(NAMED, null, form(VALID))).toEqual({ kind: "success" });
459
- const body = submitted();
460
- expect(body.source).toBe("flow:job-application");
461
- expect(body.consent).toBe(true);
462
- expect(body.payload).toEqual({
463
- name: "Ada Lovelace",
464
- first_name: "Ada",
465
- last_name: "Lovelace",
466
- job: "writer",
467
- applicationFlow: "writer-application",
468
- page: "careers",
469
- });
470
- });
471
-
472
- it("a form field named applicationFlow does not override it", async () => {
473
- await captureLeadAction(NAMED, null, form({ ...VALID, applicationFlow: "other-flow" }));
474
- expect(submitted().payload["applicationFlow"]).toBe("writer-application");
475
- });
476
-
477
- it("a string posting writes no applicationFlow, even from a form field", async () => {
478
- await captureLeadAction(JOB, null, form({ ...VALID, applicationFlow: "other-flow" }));
479
- expect(submitted().payload).not.toHaveProperty("applicationFlow");
480
- });
481
-
482
- it.each([
483
- [{ job: "writer", flow: "Bad Flow" }],
484
- [{ job: "Bad", flow: "x" }],
485
- [{ job: "writer", flow: "a".repeat(60) }],
486
- [{ job: "writer" }],
487
- ])("%p answers the generic error with nothing sent", async (posting) => {
488
- const result = await captureLeadAction(
489
- // eslint-disable-next-line no-restricted-syntax -- a malformed bound posting is exactly a value of the wrong shape
490
- posting as unknown as { job: string; flow: string },
491
- null,
492
- form(VALID),
493
- );
494
- expect(result).toMatchObject({ kind: "error", message: expect.any(String) });
495
- expect(mockSubmit).not.toHaveBeenCalled();
496
- });
497
- });
@@ -1,172 +0,0 @@
1
- /**
2
- * /careers in sections mode (#8849 D10, AC-4): one generated `items` section
3
- * from the JobPosting records, first, searchable and filterable by employment
4
- * type and location, the facets read from the postings' first-class
5
- * frontmatter fields.
6
- *
7
- * `renderPage` is spied on, so each case reads the input the page hands it and
8
- * resolves the sections through the page's own `getPageSections`.
9
- */
10
- import React from "react";
11
- import { render, screen } from "@testing-library/react";
12
- import * as pageRenderer from "@working-theory/page-renderer";
13
-
14
- jest.mock("next/navigation", () => ({
15
- __esModule: true,
16
- notFound: jest.fn(() => {
17
- throw new Error("NEXT_NOT_FOUND");
18
- }),
19
- }));
20
-
21
- jest.mock("next-mdx-remote/rsc", () => ({
22
- __esModule: true,
23
- MDXRemote: ({ source }: { source: string }) =>
24
- React.createElement("div", { "data-testid": "mdx-rendered" }, source),
25
- }));
26
-
27
- import CareersPage from "../page";
28
-
29
- type Input = Parameters<typeof pageRenderer.renderPage>[0];
30
- type Section = Awaited<ReturnType<typeof pageRenderer.getPageSections>>[number];
31
- type GetMdxSource = typeof pageRenderer.getMdxSource;
32
- type Source = NonNullable<Awaited<ReturnType<GetMdxSource>>>;
33
- type Frontmatter = Source["frontmatter"];
34
-
35
- const SEED: Source = {
36
- frontmatter: {
37
- type: "CareersList",
38
- slug: "careers",
39
- title: "Careers",
40
- description: "Open roles.",
41
- },
42
- body: "",
43
- };
44
-
45
- const HOW_WE_WORK: Section = {
46
- type: "content-block",
47
- id: "how-we-work",
48
- data: { headline: "How we work", body: "Async." },
49
- };
50
-
51
- const POSTINGS: Record<string, Frontmatter> = {
52
- writer: {
53
- type: "JobPosting",
54
- slug: "writer",
55
- title: "Writer",
56
- description: "Write for us.",
57
- employmentType: "FULL_TIME",
58
- remote: true,
59
- location: "Remote (US)",
60
- publishedAt: "2026-10-01",
61
- },
62
- editor: {
63
- type: "JobPosting",
64
- slug: "editor",
65
- title: "Editor",
66
- description: "Edit for us.",
67
- employmentType: "PART_TIME",
68
- location: "Austin, TX",
69
- publishedAt: "2026-09-01",
70
- },
71
- };
72
-
73
- function sourceFor(postings: Record<string, Frontmatter>) {
74
- return jest.fn<ReturnType<GetMdxSource>, Parameters<GetMdxSource>>(
75
- async (type, slug) => {
76
- if (type === "CareersList") return SEED;
77
- const frontmatter = postings[slug];
78
- return frontmatter ? { frontmatter, body: "" } : null;
79
- },
80
- );
81
- }
82
-
83
- /** Render /careers and return renderPage's input and its resolved sections. */
84
- async function renderHub(
85
- slugs: string[],
86
- postings: Record<string, Frontmatter> = POSTINGS,
87
- ): Promise<{ input: Input; sections: Section[] }> {
88
- const spy = jest.spyOn(pageRenderer, "renderPage");
89
- await CareersPage({
90
- params: Promise.resolve({ locale: "en" }),
91
- getMdxSource: sourceFor(postings),
92
- getMdxSlugs: jest.fn().mockResolvedValue(slugs),
93
- getPageSections: jest.fn().mockResolvedValue([HOW_WE_WORK]),
94
- });
95
- const input = spy.mock.calls[0]![0];
96
- spy.mockRestore();
97
- const sections = await input.getPageSections!(SEED.frontmatter);
98
- return { input, sections };
99
- }
100
-
101
- /** The generated section's data, narrowed to the `items` shape. */
102
- function generated(sections: Section[]) {
103
- const first = sections[0]!;
104
- if (first.type !== "items") throw new Error(`expected items, got ${first.type}`);
105
- return first.data;
106
- }
107
-
108
- describe("/careers renders the generated, filterable grid (#8849 D10, AC-4)", () => {
109
- it("renders in sections mode, the generated section first", async () => {
110
- const { input, sections } = await renderHub(["editor", "writer"]);
111
- expect(input.bodyMode).toBeUndefined();
112
- expect(input.translationsNamespace).toBe("careers");
113
- expect(sections.map((section) => section.id)).toEqual([
114
- "open-positions",
115
- "how-we-work",
116
- ]);
117
- expect(sections[0]!.type).toBe("items");
118
- });
119
-
120
- it("builds one card per posting, newest first, with the facets from the frontmatter", async () => {
121
- const { sections } = await renderHub(["editor", "writer"]);
122
- const data = generated(sections);
123
- expect(data.items.map((item) => item.title)).toEqual(["Writer", "Editor"]);
124
- expect(data.items.map((item) => item.eyebrow)).toEqual([
125
- "Full-time · Remote (US)",
126
- "Part-time · Austin, TX",
127
- ]);
128
- expect(data.items.map((item) => item.link?.href)).toEqual([
129
- "/careers/writer",
130
- "/careers/editor",
131
- ]);
132
- expect(data.items.map((item) => item.facets)).toEqual([
133
- { type: "Full-time", location: "Remote (US)" },
134
- { type: "Part-time", location: "Austin, TX" },
135
- ]);
136
- expect(data.filter?.facets?.map((facet) => facet.key)).toEqual([
137
- "type",
138
- "location",
139
- ]);
140
- expect(data.filter?.countText.other).toBe("{count} open positions");
141
- });
142
-
143
- it("reads no facet from schema.mainEntity", async () => {
144
- const { sections } = await renderHub(["override"], {
145
- override: {
146
- type: "JobPosting",
147
- slug: "override",
148
- title: "Override",
149
- description: "Typed only in the override.",
150
- schema: { mainEntity: { employmentType: "FULL_TIME" } },
151
- },
152
- });
153
- const item = generated(sections).items[0]!;
154
- expect(item.facets).toBeUndefined();
155
- expect(item.eyebrow).toBeUndefined();
156
- });
157
-
158
- it("with no postings, renders the declared sections alone", async () => {
159
- const { sections } = await renderHub([]);
160
- expect(sections.map((section) => section.id)).toEqual(["how-we-work"]);
161
- });
162
-
163
- it("with no seed, renders the careers empty state", async () => {
164
- const element = await CareersPage({
165
- params: Promise.resolve({ locale: "en" }),
166
- getMdxSource: jest.fn().mockResolvedValue(null),
167
- getMdxSlugs: jest.fn().mockResolvedValue(["writer"]),
168
- });
169
- render(element);
170
- expect(screen.getByTestId("section-empty-state")).toBeTruthy();
171
- });
172
- });