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.
- package/dist/add-route.js +16 -1
- package/dist/body-heading.d.ts +2 -1
- package/dist/body-heading.js +31 -3
- package/dist/derive-architecture.js +3 -1
- package/dist/module-architecture.js +0 -3
- package/dist/remove-module.js +27 -14
- package/dist/routes.d.ts +36 -2
- package/dist/routes.js +269 -23
- package/dist/site-manifest.js +6 -4
- package/dist/site-roster.d.ts +11 -3
- package/dist/site-roster.js +48 -22
- package/dist/surfaces.d.ts +13 -3
- package/dist/surfaces.js +128 -194
- package/dist/sync-routes.js +22 -5
- package/dist/template-record.js +3 -1
- package/dist/topology.d.ts +11 -0
- package/dist/topology.js +253 -3
- package/package.json +3 -3
- package/templates/apps/web/CLAUDE.md +32 -4
- package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +6 -1
- package/templates/apps/web/__tests__/__mocks__/next-intl.ts +6 -1
- package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
- package/templates/apps/web/account.config.tsx +2 -3
- package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
- package/templates/apps/web/app/[locale]/layout.tsx +2 -2
- package/templates/apps/web/auth.config.tsx +107 -0
- package/templates/apps/web/auth.ts +2 -1
- package/templates/apps/web/i18n/request.ts +13 -2
- package/templates/apps/web/jest.config.cjs +10 -0
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +9 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +3 -0
- package/templates/apps/web/lib/__tests__/in-page-magnet-self-request.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +2 -2
- package/templates/apps/web/lib/__tests__/pricing-page.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/server-api.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +17 -4
- package/templates/apps/web/lib/in-page-magnet.ts +2 -2
- package/templates/apps/web/lib/pricing-page.ts +3 -3
- package/templates/apps/web/lib/server-api.ts +1 -1
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-email.ts +1 -1
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-lines.ts +1 -1
- package/templates/apps/web/lib/site-header.ts +1 -1
- package/templates/apps/web/lib/topology.generated.ts +5 -0
- package/templates/apps/web/messages/en.json +0 -271
- package/templates/apps/web/middleware.ts +12 -25
- package/templates/apps/web/next.config.mjs +15 -0
- package/templates/apps/web/package.json +2 -0
- package/templates/apps/web/site-pages.config.tsx +85 -0
- package/templates/apps/web/types/messages.d.ts +6 -1
- package/templates/tools/body-heading.ts +30 -3
- package/versions.json +50 -48
- package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +0 -322
- package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +0 -554
- package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/consent-actions.test.ts +0 -56
- package/templates/apps/web/app/[locale]/(auth)/consent/__tests__/page.test.tsx +0 -164
- package/templates/apps/web/app/[locale]/(auth)/consent/consent-form.tsx +0 -132
- package/templates/apps/web/app/[locale]/(auth)/consent/consent.actions.ts +0 -51
- package/templates/apps/web/app/[locale]/(auth)/consent/page.tsx +0 -144
- package/templates/apps/web/app/[locale]/(auth)/forgot-password/forgot-password-card.tsx +0 -101
- package/templates/apps/web/app/[locale]/(auth)/forgot-password/page.tsx +0 -111
- package/templates/apps/web/app/[locale]/(auth)/layout.tsx +0 -81
- package/templates/apps/web/app/[locale]/(auth)/legal-footnote.tsx +0 -35
- package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +0 -179
- package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +0 -157
- package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +0 -126
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/next-path.test.ts +0 -54
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +0 -628
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +0 -43
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(auth)/sign-in/next-path.ts +0 -20
- package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +0 -234
- package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +0 -323
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +0 -93
- package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/page.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +0 -309
- package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +0 -201
- package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +0 -366
- package/templates/apps/web/app/[locale]/(auth)/use-auth-card-flow.ts +0 -116
- package/templates/apps/web/app/[locale]/(auth)/verify-email/__tests__/actions.test.ts +0 -94
- package/templates/apps/web/app/[locale]/(auth)/verify-email/actions.ts +0 -77
- package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +0 -154
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -10
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/leads/__tests__/page.test.tsx +0 -205
- package/templates/apps/web/app/[locale]/(authed)/leads/components/LeadsTable.tsx +0 -137
- package/templates/apps/web/app/[locale]/(authed)/leads/page.tsx +0 -122
- package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ForbiddenState.tsx +0 -24
- package/templates/apps/web/app/[locale]/(authed)/waitlist/format.ts +0 -111
- package/templates/apps/web/app/[locale]/[slug]/[detail]/__tests__/page.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/[slug]/[detail]/page.tsx +0 -143
- package/templates/apps/web/app/[locale]/[slug]/__tests__/page.test.tsx +0 -148
- package/templates/apps/web/app/[locale]/[slug]/page.tsx +0 -109
- package/templates/apps/web/app/[locale]/about/[slug]/page.tsx +0 -46
- package/templates/apps/web/app/[locale]/about/__tests__/about-routes.test.tsx +0 -353
- package/templates/apps/web/app/[locale]/about/page.tsx +0 -122
- package/templates/apps/web/app/[locale]/alternatives/__tests__/page.test.tsx +0 -161
- package/templates/apps/web/app/[locale]/alternatives/page.tsx +0 -112
- package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +0 -244
- package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +0 -325
- package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +0 -120
- package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +0 -73
- package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +0 -497
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +0 -172
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +0 -153
- package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +0 -141
- package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +0 -546
- package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +0 -189
- package/templates/apps/web/app/[locale]/careers/page.tsx +0 -165
- package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/case-studies/__tests__/hub-children.test.tsx +0 -65
- package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +0 -125
- package/templates/apps/web/app/[locale]/case-studies/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +0 -85
- package/templates/apps/web/app/[locale]/clients/page.tsx +0 -47
- package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +0 -249
- package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +0 -400
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-magnet.test.ts +0 -138
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-text.test.ts +0 -49
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +0 -494
- package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +0 -1122
- package/templates/apps/web/app/[locale]/contact/__tests__/intake-analytics.test.ts +0 -51
- package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +0 -319
- package/templates/apps/web/app/[locale]/contact/contact-form-magnet.ts +0 -77
- package/templates/apps/web/app/[locale]/contact/contact-form-text.ts +0 -52
- package/templates/apps/web/app/[locale]/contact/contact.actions.ts +0 -403
- package/templates/apps/web/app/[locale]/contact/intake-analytics.ts +0 -49
- package/templates/apps/web/app/[locale]/contact/intake-script.ts +0 -92
- package/templates/apps/web/app/[locale]/contact/page.tsx +0 -267
- package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/courses/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +0 -123
- package/templates/apps/web/app/[locale]/courses/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +0 -57
- package/templates/apps/web/app/[locale]/events/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +0 -164
- package/templates/apps/web/app/[locale]/events/__tests__/program-event.test.tsx +0 -120
- package/templates/apps/web/app/[locale]/events/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/faq/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/features/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/features/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/features/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/for/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/for/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/for/__tests__/page-renderer-migration.test.tsx +0 -90
- package/templates/apps/web/app/[locale]/for/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/glossary/page.tsx +0 -53
- package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +0 -78
- package/templates/apps/web/app/[locale]/how-to/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/integrations/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/integrations/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/launch-service/page.tsx +0 -44
- package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +0 -236
- package/templates/apps/web/app/[locale]/newsletter/page.tsx +0 -179
- package/templates/apps/web/app/[locale]/page.tsx +0 -147
- package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +0 -45
- package/templates/apps/web/app/[locale]/partners/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +0 -125
- package/templates/apps/web/app/[locale]/partners/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/portfolio/[slug]/page.tsx +0 -46
- package/templates/apps/web/app/[locale]/portfolio/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/portfolio/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/pricing/[slug]/__tests__/page.test.tsx +0 -324
- package/templates/apps/web/app/[locale]/pricing/[slug]/page.tsx +0 -87
- package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +0 -7
- package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +0 -605
- package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +0 -219
- package/templates/apps/web/app/[locale]/pricing/__tests__/pricing-pages.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +0 -282
- package/templates/apps/web/app/[locale]/pricing/page.tsx +0 -120
- package/templates/apps/web/app/[locale]/privacy/page.tsx +0 -40
- package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/products/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/products/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +0 -37
- package/templates/apps/web/app/[locale]/projects/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +0 -157
- package/templates/apps/web/app/[locale]/projects/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/purchase-policy/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/resources/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +0 -151
- package/templates/apps/web/app/[locale]/resources/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/services/[slug]/[child]/page.tsx +0 -68
- package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +0 -88
- package/templates/apps/web/app/[locale]/services/__tests__/hub-children.test.tsx +0 -158
- package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +0 -187
- package/templates/apps/web/app/[locale]/services/__tests__/service-detail-sections.test.tsx +0 -224
- package/templates/apps/web/app/[locale]/services/__tests__/service-families.test.tsx +0 -368
- package/templates/apps/web/app/[locale]/services/page.tsx +0 -71
- package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +0 -81
- package/templates/apps/web/app/[locale]/software/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/team/[slug]/page.tsx +0 -45
- package/templates/apps/web/app/[locale]/team/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +0 -161
- package/templates/apps/web/app/[locale]/team/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +0 -82
- package/templates/apps/web/app/[locale]/tech-articles/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/templates/[slug]/__tests__/page.test.tsx +0 -203
- package/templates/apps/web/app/[locale]/templates/[slug]/page.tsx +0 -81
- package/templates/apps/web/app/[locale]/templates/__tests__/page.test.tsx +0 -237
- package/templates/apps/web/app/[locale]/templates/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/terms/page.tsx +0 -40
- package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +0 -85
- package/templates/apps/web/app/[locale]/testimonials/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +0 -136
- package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +0 -39
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +0 -226
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +0 -217
- package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +0 -106
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +0 -94
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe.actions.ts +0 -55
- package/templates/apps/web/app/[locale]/vs/[slug]/__tests__/page.test.tsx +0 -100
- package/templates/apps/web/app/[locale]/vs/[slug]/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +0 -82
- package/templates/apps/web/app/[locale]/whitepapers/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/working-agreement/__tests__/page.test.tsx +0 -63
- package/templates/apps/web/app/[locale]/working-agreement/page.tsx +0 -41
- package/templates/apps/web/app/api/auth/[...all]/route.ts +0 -16
- package/templates/apps/web/app/api/auth/hub/__tests__/continuation.test.ts +0 -143
- package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +0 -749
- package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +0 -964
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +0 -390
- package/templates/apps/web/app/api/auth/hub/continuation.ts +0 -127
- package/templates/apps/web/app/api/auth/hub/continue/[ref]/__tests__/route.test.ts +0 -188
- package/templates/apps/web/app/api/auth/hub/continue/[ref]/route.ts +0 -53
- package/templates/apps/web/app/api/auth/hub/email/route.ts +0 -111
- package/templates/apps/web/app/api/auth/hub/entry-shared.ts +0 -163
- package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +0 -86
- package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +0 -368
- package/templates/apps/web/app/api/auth/hub/password/return.ts +0 -86
- package/templates/apps/web/app/api/auth/hub/password/route.ts +0 -171
- package/templates/apps/web/app/api/auth/hub/purchase/route.ts +0 -230
- package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +0 -174
- package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +0 -60
- package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +0 -97
- package/templates/apps/web/app/api/auth/mcp/__tests__/continuation.test.ts +0 -92
- package/templates/apps/web/app/api/auth/mcp/continuation.ts +0 -89
- package/templates/apps/web/app/api/auth/mcp/continue/[ref]/__tests__/route.test.ts +0 -59
- package/templates/apps/web/app/api/auth/mcp/continue/[ref]/route.ts +0 -41
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +0 -1166
- package/templates/apps/web/app/api/hub-session/callback/route.ts +0 -134
- package/templates/apps/web/app/api/hub-session/email/route.ts +0 -125
- package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +0 -49
- package/templates/apps/web/app/api/hub-session/one-tap/route.ts +0 -106
- package/templates/apps/web/app/api/hub-session/open/route.ts +0 -111
- package/templates/apps/web/app/api/hub-session/password/return/route.ts +0 -69
- package/templates/apps/web/app/api/hub-session/password/route.ts +0 -106
- package/templates/apps/web/app/api/hub-session/sign-in/route.ts +0 -91
- package/templates/apps/web/app/api/hub-session/sign-out/route.ts +0 -54
- package/templates/apps/web/components/sign-out-trigger.tsx +0 -62
- package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
- package/templates/apps/web/lib/__tests__/hub-children.fixtures.ts +0 -279
- package/templates/apps/web/lib/__tests__/route-family.test.ts +0 -57
- package/templates/apps/web/lib/__tests__/service-listing.test.ts +0 -111
- package/templates/apps/web/lib/__tests__/template-listing.test.ts +0 -158
- package/templates/apps/web/lib/auth-routes.ts +0 -125
- package/templates/apps/web/lib/hub-children.tsx +0 -351
- package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +0 -433
- package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +0 -332
- package/templates/apps/web/lib/hub-session/config.ts +0 -110
- package/templates/apps/web/lib/hub-session/entry.ts +0 -238
- package/templates/apps/web/lib/hub-session/index.ts +0 -21
- package/templates/apps/web/lib/hub-session/one-tap.tsx +0 -148
- package/templates/apps/web/lib/hub-session/reseal.ts +0 -90
- package/templates/apps/web/lib/hub-session/seal.ts +0 -86
- package/templates/apps/web/lib/hub-session/session.ts +0 -298
- package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +0 -277
- package/templates/apps/web/lib/meet-placeholder.ts +0 -5
- package/templates/apps/web/lib/next-path.ts +0 -35
- package/templates/apps/web/lib/posting-title.ts +0 -39
- package/templates/apps/web/lib/route-family.ts +0 -69
- package/templates/apps/web/lib/service-listing.ts +0 -89
- package/templates/apps/web/lib/template-listing.ts +0 -169
- package/templates/apps/web/src/lib/__tests__/lead-write.test.ts +0 -187
- package/templates/apps/web/src/lib/lead-write.ts +0 -90
- /package/templates/apps/web/{app/[locale]/contact → lib}/__tests__/site-contact-lines.test.ts +0 -0
|
@@ -1,494 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* contact/page.tsx over the Contact form magnet (#8661 D6) — AC-3 and AC-5.
|
|
3
|
-
*
|
|
4
|
-
* Unlike `page-renderer-migration.test.tsx`, this suite renders the REAL
|
|
5
|
-
* `LeadCaptureForm` and binds the REAL `captureLeadAction`, so the hidden
|
|
6
|
-
* `source` input, the fields and a submit are all visible. Mocked
|
|
7
|
-
* boundaries: `@working-theory/api-client` (`flows.get`, `leads.captureStatus`,
|
|
8
|
-
* `leads.submit`), `next/headers`, `next-intl/server` (over the real English
|
|
9
|
-
* catalog), the `_site.mdx` contact-email read, and the page-renderer's
|
|
10
|
-
* content loaders (injected).
|
|
11
|
-
*/
|
|
12
|
-
import React from "react";
|
|
13
|
-
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
14
|
-
import {
|
|
15
|
-
CONTACT_FORM_TERMS_STATEMENT,
|
|
16
|
-
contactFormFlowConfig,
|
|
17
|
-
type FlowConfig,
|
|
18
|
-
} from "@working-theory/validation";
|
|
19
|
-
|
|
20
|
-
jest.mock("next/navigation", () => ({
|
|
21
|
-
__esModule: true,
|
|
22
|
-
notFound: jest.fn(() => {
|
|
23
|
-
throw new Error("NEXT_NOT_FOUND");
|
|
24
|
-
}),
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
jest.mock("next-mdx-remote/rsc", () => ({
|
|
28
|
-
__esModule: true,
|
|
29
|
-
MDXRemote: ({ source }: { source: string }) =>
|
|
30
|
-
React.createElement("div", { "data-testid": "mdx-rendered" }, source),
|
|
31
|
-
}));
|
|
32
|
-
|
|
33
|
-
jest.mock("@working-theory/api-client", () => ({
|
|
34
|
-
flows: { get: jest.fn() },
|
|
35
|
-
leads: { captureStatus: jest.fn(), submit: jest.fn() },
|
|
36
|
-
visitorForwardHeaders: () => undefined,
|
|
37
|
-
}));
|
|
38
|
-
|
|
39
|
-
jest.mock("next/headers", () => ({
|
|
40
|
-
__esModule: true,
|
|
41
|
-
headers: jest.fn().mockResolvedValue({ get: () => null }),
|
|
42
|
-
cookies: jest.fn().mockResolvedValue({ get: () => undefined }),
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
// The real English catalog, so the page's own strings render as they ship.
|
|
46
|
-
jest.mock("next-intl/server", () => {
|
|
47
|
-
const messages = jest.requireActual("../../../../messages/en.json") as Record<
|
|
48
|
-
string,
|
|
49
|
-
Record<string, unknown>
|
|
50
|
-
>;
|
|
51
|
-
return {
|
|
52
|
-
getTranslations: async (arg: string | { namespace: string }) => {
|
|
53
|
-
const ns = messages[typeof arg === "string" ? arg : arg.namespace] ?? {};
|
|
54
|
-
return (key: string, values?: Record<string, string>) =>
|
|
55
|
-
String(ns[key] ?? key).replace(/\{(\w+)\}/g, (m, name: string) => values?.[name] ?? m);
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// eslint-disable-next-line no-restricted-syntax -- test-seam mock: the real read is a node:fs frontmatter parse of content/_site.mdx; narrowest possible scope
|
|
61
|
-
jest.mock("../site-contact-email", () => ({
|
|
62
|
-
readSiteContactEmail: jest.fn().mockReturnValue(undefined),
|
|
63
|
-
}));
|
|
64
|
-
|
|
65
|
-
import { flows, leads } from "@working-theory/api-client";
|
|
66
|
-
import { localeHref } from "@working-theory/ui";
|
|
67
|
-
|
|
68
|
-
import { contactFormFromConfig } from "../contact-form-magnet";
|
|
69
|
-
import * as pageModule from "../page";
|
|
70
|
-
import ContactPage from "../page";
|
|
71
|
-
|
|
72
|
-
const mockFlowsGet = flows.get as jest.Mock;
|
|
73
|
-
const mockCaptureStatus = leads.captureStatus as jest.Mock;
|
|
74
|
-
const mockSubmit = leads.submit as jest.Mock;
|
|
75
|
-
|
|
76
|
-
type FieldStep = Extract<FlowConfig["steps"][number], { type: "field" }>;
|
|
77
|
-
|
|
78
|
-
const source = {
|
|
79
|
-
frontmatter: {
|
|
80
|
-
type: "ContactPage" as const,
|
|
81
|
-
slug: "contact",
|
|
82
|
-
title: "Contact Us",
|
|
83
|
-
description: "Get in touch.",
|
|
84
|
-
},
|
|
85
|
-
body: "",
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/** The seeded config with its subject relabelled. */
|
|
89
|
-
function configWithSubjectLabel(label: string): FlowConfig {
|
|
90
|
-
const config = JSON.parse(JSON.stringify(contactFormFlowConfig)) as FlowConfig;
|
|
91
|
-
const subject = (config.steps[0] as FieldStep).fields.find((f) => f.name === "subject")!;
|
|
92
|
-
subject.copy.label = { en: label };
|
|
93
|
-
return config;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const served = (config: FlowConfig) => ({ ok: true, status: 200, body: config });
|
|
97
|
-
|
|
98
|
-
async function renderPage(sections: unknown[] = []) {
|
|
99
|
-
const element = await ContactPage({
|
|
100
|
-
params: Promise.resolve({ locale: "en" }),
|
|
101
|
-
getMdxSource: jest.fn().mockResolvedValue(source),
|
|
102
|
-
getPageSections: jest.fn().mockResolvedValue(sections),
|
|
103
|
-
});
|
|
104
|
-
return render(element);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function sourceInput(): HTMLInputElement | null {
|
|
108
|
-
return document.querySelector<HTMLInputElement>("input[name='source']");
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function fieldNames(): string[] {
|
|
112
|
-
return Array.from(
|
|
113
|
-
screen.getByTestId("lead-capture-form").querySelectorAll<HTMLElement>("[data-testid^='field-']"),
|
|
114
|
-
).map((el) => el.dataset.testid!.slice("field-".length));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async function tickAndSubmit(values: Record<string, string>) {
|
|
118
|
-
for (const [name, value] of Object.entries(values)) {
|
|
119
|
-
fireEvent.change(screen.getByTestId(`field-${name}`), { target: { value } });
|
|
120
|
-
}
|
|
121
|
-
fireEvent.click(screen.getByTestId("contact-consent"));
|
|
122
|
-
await act(async () => {
|
|
123
|
-
fireEvent.submit(screen.getByTestId("lead-capture-form"));
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// #8731 — the page shares its two hub reads for a few seconds, per module
|
|
128
|
-
// instance. Each test starts an hour later so none sees another's read.
|
|
129
|
-
let clock = 1_800_000_000_000;
|
|
130
|
-
const nowSpy = jest.spyOn(Date, "now");
|
|
131
|
-
|
|
132
|
-
beforeEach(() => {
|
|
133
|
-
jest.clearAllMocks();
|
|
134
|
-
clock += 60 * 60 * 1000;
|
|
135
|
-
nowSpy.mockImplementation(() => clock);
|
|
136
|
-
mockCaptureStatus.mockResolvedValue({
|
|
137
|
-
ok: true,
|
|
138
|
-
status: 200,
|
|
139
|
-
body: { ok: true, data: { contact: true, newsletter: false } },
|
|
140
|
-
});
|
|
141
|
-
mockSubmit.mockResolvedValue({ ok: true, body: { id: "lead_1", persisted: "db" } });
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
describe("contact/page — rendering (AC-3)", () => {
|
|
145
|
-
it("is rendered on every request, never ISR", () => {
|
|
146
|
-
expect(pageModule.dynamic).toBe("force-dynamic");
|
|
147
|
-
expect("revalidate" in pageModule).toBe(false);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it("renders the served magnet's fields, and stamps the post flow:contact", async () => {
|
|
151
|
-
mockFlowsGet.mockResolvedValue(served(configWithSubjectLabel("Topic")));
|
|
152
|
-
|
|
153
|
-
await renderPage();
|
|
154
|
-
|
|
155
|
-
expect(mockFlowsGet).toHaveBeenCalledWith("contact");
|
|
156
|
-
expect(fieldNames()).toEqual(["name", "email", "subject", "message"]);
|
|
157
|
-
expect(screen.getByTestId("lead-capture-form")).toHaveTextContent("Topic");
|
|
158
|
-
expect(sourceInput()).toHaveAttribute("type", "hidden");
|
|
159
|
-
expect(sourceInput()!.value).toBe("flow:contact");
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("the magnet wins over a content section's declared fields", async () => {
|
|
163
|
-
mockFlowsGet.mockResolvedValue(served(configWithSubjectLabel("Topic")));
|
|
164
|
-
|
|
165
|
-
await renderPage([
|
|
166
|
-
{
|
|
167
|
-
id: "contact-form",
|
|
168
|
-
type: "contact-form",
|
|
169
|
-
data: { fields: [{ name: "company", label: "Company", type: "text" }] },
|
|
170
|
-
},
|
|
171
|
-
]);
|
|
172
|
-
|
|
173
|
-
expect(fieldNames()).toEqual(["name", "email", "subject", "message"]);
|
|
174
|
-
expect(screen.queryByTestId("field-company")).toBeNull();
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it("a burst of views makes one hub read of each kind, not one per view (#8731)", async () => {
|
|
178
|
-
mockFlowsGet.mockResolvedValue(served(configWithSubjectLabel("Topic")));
|
|
179
|
-
for (let i = 0; i < 25; i += 1) {
|
|
180
|
-
const view = await renderPage();
|
|
181
|
-
expect(screen.getByTestId("lead-capture-form")).toHaveTextContent("Topic");
|
|
182
|
-
view.unmount();
|
|
183
|
-
}
|
|
184
|
-
expect(mockFlowsGet).toHaveBeenCalledTimes(1);
|
|
185
|
-
expect(mockCaptureStatus).toHaveBeenCalledTimes(1);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it("concurrent views share one in-flight read of each (#8731)", async () => {
|
|
189
|
-
mockFlowsGet.mockResolvedValue(served(contactFormFlowConfig));
|
|
190
|
-
await Promise.all([renderPage(), renderPage(), renderPage()]);
|
|
191
|
-
expect(mockFlowsGet).toHaveBeenCalledTimes(1);
|
|
192
|
-
expect(mockCaptureStatus).toHaveBeenCalledTimes(1);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it("an Admin edit shows once the shared read expires (#8731)", async () => {
|
|
196
|
-
mockFlowsGet.mockResolvedValueOnce(served(configWithSubjectLabel("Topic")));
|
|
197
|
-
const first = await renderPage();
|
|
198
|
-
expect(screen.getByTestId("lead-capture-form")).toHaveTextContent("Topic");
|
|
199
|
-
first.unmount();
|
|
200
|
-
|
|
201
|
-
mockFlowsGet.mockResolvedValueOnce(served(configWithSubjectLabel("Reason")));
|
|
202
|
-
clock += 60_000;
|
|
203
|
-
await renderPage();
|
|
204
|
-
const form = screen.getByTestId("lead-capture-form");
|
|
205
|
-
expect(form).toHaveTextContent("Reason");
|
|
206
|
-
expect(form).not.toHaveTextContent("Topic");
|
|
207
|
-
expect(mockFlowsGet).toHaveBeenCalledTimes(2);
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it("a failed read is shared too, so an unreachable hub is not retried per view (#8731)", async () => {
|
|
211
|
-
mockFlowsGet.mockRejectedValue(new Error("hub down"));
|
|
212
|
-
mockCaptureStatus.mockRejectedValue(new Error("hub down"));
|
|
213
|
-
for (let i = 0; i < 5; i += 1) {
|
|
214
|
-
const view = await renderPage();
|
|
215
|
-
expect(screen.getByTestId("lead-capture-form")).toBeInTheDocument();
|
|
216
|
-
view.unmount();
|
|
217
|
-
}
|
|
218
|
-
expect(mockFlowsGet).toHaveBeenCalledTimes(1);
|
|
219
|
-
expect(mockCaptureStatus).toHaveBeenCalledTimes(1);
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it("links Terms and Privacy Policy in the two-link statement (#8847 D2)", async () => {
|
|
223
|
-
mockFlowsGet.mockResolvedValue(served(contactFormFlowConfig));
|
|
224
|
-
|
|
225
|
-
await renderPage();
|
|
226
|
-
|
|
227
|
-
expect(screen.getByTestId("consent-policy-link-terms")).toHaveAttribute(
|
|
228
|
-
"href",
|
|
229
|
-
localeHref("en", "/terms"),
|
|
230
|
-
);
|
|
231
|
-
expect(screen.getByTestId("consent-policy-link-privacy")).toHaveAttribute(
|
|
232
|
-
"href",
|
|
233
|
-
localeHref("en", "/privacy"),
|
|
234
|
-
);
|
|
235
|
-
expect(screen.queryByTestId("consent-policy-link-working_agreement")).toBeNull();
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it("a magnet-driven post reaches leads.submit as flow:contact with its subject", async () => {
|
|
239
|
-
mockFlowsGet.mockResolvedValue(served(contactFormFlowConfig));
|
|
240
|
-
|
|
241
|
-
await renderPage();
|
|
242
|
-
await tickAndSubmit({ name: "Ada", email: "ada@example.com" });
|
|
243
|
-
|
|
244
|
-
await waitFor(() => expect(mockSubmit).toHaveBeenCalledTimes(1));
|
|
245
|
-
expect(mockSubmit.mock.calls[0][0]).toMatchObject({ source: "flow:contact" });
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
describe("contact/page — fallback (AC-5)", () => {
|
|
250
|
-
const builtIn = contactFormFromConfig(contactFormFlowConfig, "en")!;
|
|
251
|
-
|
|
252
|
-
it.each([
|
|
253
|
-
["answers 404", () => mockFlowsGet.mockResolvedValue({ ok: false, status: 404, body: {} })],
|
|
254
|
-
["rejects", () => mockFlowsGet.mockRejectedValue(new Error("ECONNREFUSED"))],
|
|
255
|
-
[
|
|
256
|
-
"serves a config the form cannot use",
|
|
257
|
-
() => {
|
|
258
|
-
const config = JSON.parse(JSON.stringify(contactFormFlowConfig)) as FlowConfig;
|
|
259
|
-
const step = config.steps[0] as FieldStep;
|
|
260
|
-
step.fields = step.fields.filter((f) => f.name !== "name");
|
|
261
|
-
mockFlowsGet.mockResolvedValue(served(config));
|
|
262
|
-
},
|
|
263
|
-
],
|
|
264
|
-
])("flows.get %s → the built-in form, posted as web", async (_label, arrange) => {
|
|
265
|
-
arrange();
|
|
266
|
-
|
|
267
|
-
await renderPage();
|
|
268
|
-
|
|
269
|
-
const form = screen.getByTestId("lead-capture-form");
|
|
270
|
-
expect(fieldNames()).toEqual(builtIn.fields.map((f) => f.name));
|
|
271
|
-
for (const field of builtIn.fields) expect(form).toHaveTextContent(field.label);
|
|
272
|
-
const subject = builtIn.fields.find((f) => f.name === "subject")!;
|
|
273
|
-
const native = form.querySelector("select");
|
|
274
|
-
if (native) {
|
|
275
|
-
const values = Array.from(native.querySelectorAll("option"))
|
|
276
|
-
.map((o) => o.value)
|
|
277
|
-
.filter(Boolean);
|
|
278
|
-
expect(values).toEqual(
|
|
279
|
-
subject.options!.map((o) => (typeof o === "string" ? o : o.value)),
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
expect(
|
|
283
|
-
document.getElementById("lead-capture-consent-statement")!.textContent,
|
|
284
|
-
).toBe(CONTACT_FORM_TERMS_STATEMENT.replace(/\[([^\]]+)\]\([a-z_]+\)/g, "$1"));
|
|
285
|
-
expect(sourceInput()).toBeNull();
|
|
286
|
-
|
|
287
|
-
await tickAndSubmit({ name: "Ada", email: "ada@example.com" });
|
|
288
|
-
|
|
289
|
-
await waitFor(() => expect(mockSubmit).toHaveBeenCalledTimes(1));
|
|
290
|
-
expect(mockSubmit.mock.calls[0][0]).toMatchObject({ source: "contact-form" });
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
it("with no magnet, a section's declared fields still apply", async () => {
|
|
294
|
-
mockFlowsGet.mockResolvedValue({ ok: false, status: 404, body: {} });
|
|
295
|
-
|
|
296
|
-
await renderPage([
|
|
297
|
-
{
|
|
298
|
-
id: "contact-form",
|
|
299
|
-
type: "contact-form",
|
|
300
|
-
data: {
|
|
301
|
-
fields: [
|
|
302
|
-
{ name: "name", label: "Name", type: "text" },
|
|
303
|
-
{ name: "email", label: "Email", type: "email" },
|
|
304
|
-
{ name: "company", label: "Company", type: "text" },
|
|
305
|
-
],
|
|
306
|
-
submitLabel: "Request a demo",
|
|
307
|
-
},
|
|
308
|
-
},
|
|
309
|
-
]);
|
|
310
|
-
|
|
311
|
-
expect(fieldNames()).toEqual(["name", "email", "company"]);
|
|
312
|
-
expect(screen.getByTestId("contact-submit")).toHaveTextContent("Request a demo");
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it("the built-in form takes its labels from the contact catalog and ends on the built-in ending (#8847 D7)", async () => {
|
|
316
|
-
mockFlowsGet.mockResolvedValue({ ok: false, status: 404, body: {} });
|
|
317
|
-
const messages = jest.requireActual("../../../../messages/en.json") as {
|
|
318
|
-
contact: Record<string, string>;
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
await renderPage([
|
|
322
|
-
{
|
|
323
|
-
id: "contact-form",
|
|
324
|
-
type: "contact-form",
|
|
325
|
-
data: { fields: [], submitLabel: "Say hello", successMessage: "Got it, thanks." },
|
|
326
|
-
},
|
|
327
|
-
]);
|
|
328
|
-
|
|
329
|
-
const form = screen.getByTestId("lead-capture-form");
|
|
330
|
-
expect(form).toHaveTextContent(messages.contact.nameLabel!);
|
|
331
|
-
expect(form).toHaveTextContent(messages.contact.messageLabel!);
|
|
332
|
-
expect(screen.getByTestId("contact-submit")).toHaveTextContent(messages.contact.sendMessage!);
|
|
333
|
-
|
|
334
|
-
await tickAndSubmit({ name: "Ada", email: "ada@example.com" });
|
|
335
|
-
await waitFor(() =>
|
|
336
|
-
expect(screen.getByTestId("contact-success-headline")).toHaveTextContent("Message sent."),
|
|
337
|
-
);
|
|
338
|
-
expect(document.body).not.toHaveTextContent("Got it, thanks.");
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
it("a magnet's submit label and ending win over the section's copy (#8847 D7)", async () => {
|
|
342
|
-
mockFlowsGet.mockResolvedValue(served(contactFormFlowConfig));
|
|
343
|
-
|
|
344
|
-
await renderPage([
|
|
345
|
-
{
|
|
346
|
-
id: "contact-form",
|
|
347
|
-
type: "contact-form",
|
|
348
|
-
data: { fields: [], submitLabel: "Say hello", successMessage: "Got it, thanks." },
|
|
349
|
-
},
|
|
350
|
-
]);
|
|
351
|
-
|
|
352
|
-
expect(screen.getByTestId("contact-submit")).toHaveTextContent(
|
|
353
|
-
contactFormFromConfig(contactFormFlowConfig, "en")!.submitLabel!,
|
|
354
|
-
);
|
|
355
|
-
|
|
356
|
-
await tickAndSubmit({ name: "Ada", email: "ada@example.com" });
|
|
357
|
-
await waitFor(() =>
|
|
358
|
-
expect(screen.getByTestId("contact-success-headline")).toHaveTextContent("Message sent."),
|
|
359
|
-
);
|
|
360
|
-
expect(document.body).not.toHaveTextContent("Got it, thanks.");
|
|
361
|
-
});
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
// ── #8847 AC-2 — /contact is the magnet ─────────────────────────────────────
|
|
365
|
-
|
|
366
|
-
/** A served Contact form whose every visible fact differs from the default. */
|
|
367
|
-
function sayHelloConfig(): FlowConfig {
|
|
368
|
-
const config = JSON.parse(JSON.stringify(contactFormFlowConfig)) as FlowConfig;
|
|
369
|
-
const step = config.steps[0] as FieldStep;
|
|
370
|
-
step.copy = { title: { en: "Say hello" }, body: { en: "Two days, tops." }, cta: { en: "Send" } };
|
|
371
|
-
step.fields.find((f) => f.name === "terms")!.copy.label = { en: "I agree to the [Terms](terms)." };
|
|
372
|
-
config.ending = { default: { kind: "screen", headline: { en: "Got it, {name}." } } };
|
|
373
|
-
return config;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
const COLUMN_SECTION = {
|
|
377
|
-
id: "contact-form",
|
|
378
|
-
type: "contact-form",
|
|
379
|
-
data: { variant: "column", headline: "Old heading", description: "Old line", fields: [] },
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
async function renderColumnPage() {
|
|
383
|
-
const element = await ContactPage({
|
|
384
|
-
params: Promise.resolve({ locale: "en" }),
|
|
385
|
-
getMdxSource: jest.fn().mockResolvedValue({
|
|
386
|
-
...source,
|
|
387
|
-
frontmatter: { ...source.frontmatter, title: "Old title" },
|
|
388
|
-
}),
|
|
389
|
-
getPageSections: jest.fn().mockResolvedValue([COLUMN_SECTION]),
|
|
390
|
-
});
|
|
391
|
-
return render(element);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
describe("contact/page — every visible fact comes from the magnet (#8847 AC-2)", () => {
|
|
395
|
-
it("the H1, the line, the consent and the ending are the served magnet's", async () => {
|
|
396
|
-
mockFlowsGet.mockResolvedValue(served(sayHelloConfig()));
|
|
397
|
-
|
|
398
|
-
await renderColumnPage();
|
|
399
|
-
|
|
400
|
-
const headings = screen.getAllByRole("heading", { level: 1 });
|
|
401
|
-
expect(headings).toHaveLength(1);
|
|
402
|
-
expect(headings[0]).toHaveTextContent("Say hello");
|
|
403
|
-
expect(screen.getByTestId("contact-form-column")).toHaveTextContent("Two days, tops.");
|
|
404
|
-
expect(
|
|
405
|
-
document.getElementById("lead-capture-consent-statement")!.textContent,
|
|
406
|
-
).toBe("I agree to the Terms.");
|
|
407
|
-
expect(screen.getByTestId("consent-policy-link-terms")).toBeInTheDocument();
|
|
408
|
-
for (const old of ["Old heading", "Old line", "Old title"]) {
|
|
409
|
-
expect(document.body).not.toHaveTextContent(old);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
await tickAndSubmit({ name: "Ada", email: "ada@example.com" });
|
|
413
|
-
await waitFor(() =>
|
|
414
|
-
expect(screen.getByTestId("contact-success-headline")).toHaveTextContent("Got it, Ada."),
|
|
415
|
-
);
|
|
416
|
-
const messages = jest.requireActual("../../../../messages/en.json") as {
|
|
417
|
-
contact: Record<string, string>;
|
|
418
|
-
};
|
|
419
|
-
expect(document.body).not.toHaveTextContent(messages.contact.successMessage!);
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
it("generateMetadata's title is the magnet's step title", async () => {
|
|
423
|
-
mockFlowsGet.mockResolvedValue(served(sayHelloConfig()));
|
|
424
|
-
|
|
425
|
-
const metadata = await pageModule.generateMetadata({
|
|
426
|
-
params: Promise.resolve({ locale: "en" }),
|
|
427
|
-
getMdxSource: jest.fn().mockResolvedValue({
|
|
428
|
-
...source,
|
|
429
|
-
frontmatter: { ...source.frontmatter, title: "Old title" },
|
|
430
|
-
}),
|
|
431
|
-
getPageSections: jest.fn().mockResolvedValue([COLUMN_SECTION]),
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
expect(String((metadata.title as { absolute?: string })?.absolute ?? metadata.title)).toContain(
|
|
435
|
-
"Say hello",
|
|
436
|
-
);
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
it("with the hub unreadable, the built-in config's title and two-link statement render", async () => {
|
|
440
|
-
mockFlowsGet.mockRejectedValue(new Error("hub down"));
|
|
441
|
-
|
|
442
|
-
await renderColumnPage();
|
|
443
|
-
|
|
444
|
-
expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("Get in touch");
|
|
445
|
-
expect(
|
|
446
|
-
document.getElementById("lead-capture-consent-statement")!.textContent,
|
|
447
|
-
).toBe("I accept the Terms and Privacy Policy.");
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
it("under the form, 'Prefer email?' links the _site.mdx contact email; absent with none", async () => {
|
|
451
|
-
const { readSiteContactEmail } = jest.requireMock("../site-contact-email") as {
|
|
452
|
-
readSiteContactEmail: jest.Mock;
|
|
453
|
-
};
|
|
454
|
-
mockFlowsGet.mockResolvedValue(served(contactFormFlowConfig));
|
|
455
|
-
readSiteContactEmail.mockReturnValue("hi@x.co");
|
|
456
|
-
|
|
457
|
-
const view = await renderColumnPage();
|
|
458
|
-
|
|
459
|
-
const line = screen.getByTestId("contact-prefer-email");
|
|
460
|
-
expect(line).toHaveTextContent("Prefer email? hi@x.co");
|
|
461
|
-
expect(line.querySelector("a")).toHaveAttribute("href", "mailto:hi@x.co");
|
|
462
|
-
view.unmount();
|
|
463
|
-
|
|
464
|
-
readSiteContactEmail.mockReturnValue(undefined);
|
|
465
|
-
await renderColumnPage();
|
|
466
|
-
expect(screen.queryByTestId("contact-prefer-email")).toBeNull();
|
|
467
|
-
});
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
describe("contact/page — the column look (#8661 D12)", () => {
|
|
471
|
-
it("a column section gets the stacked look and an enabled Send", async () => {
|
|
472
|
-
mockFlowsGet.mockResolvedValue(served(contactFormFlowConfig));
|
|
473
|
-
|
|
474
|
-
await renderPage([
|
|
475
|
-
{
|
|
476
|
-
id: "contact",
|
|
477
|
-
type: "contact-form",
|
|
478
|
-
data: { variant: "column", headline: "Contact Us", description: "Say hello.", fields: [] },
|
|
479
|
-
},
|
|
480
|
-
]);
|
|
481
|
-
|
|
482
|
-
expect(screen.getByTestId("lead-capture-form")).toHaveAttribute("data-look", "column");
|
|
483
|
-
expect(screen.getByTestId("contact-submit")).toBeEnabled();
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
it("a standard page keeps Send disabled until ticked", async () => {
|
|
487
|
-
mockFlowsGet.mockResolvedValue(served(contactFormFlowConfig));
|
|
488
|
-
|
|
489
|
-
await renderPage();
|
|
490
|
-
|
|
491
|
-
expect(screen.getByTestId("lead-capture-form")).not.toHaveAttribute("data-look");
|
|
492
|
-
expect(screen.getByTestId("contact-submit")).toBeDisabled();
|
|
493
|
-
});
|
|
494
|
-
});
|