create-ailk 0.21.0 → 0.23.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/component-catalog.json +186 -8
- package/component-catalog.md +9 -7
- package/dist/add-module.js +20 -14
- package/dist/add-route.d.ts +55 -1
- package/dist/add-route.js +294 -12
- package/dist/cli.js +27 -10
- package/dist/derive-architecture.d.ts +12 -3
- package/dist/derive-architecture.js +20 -8
- package/dist/design-package.js +7 -2
- package/dist/lib/design-checks.js +4 -2
- package/dist/lib/env-catalog.js +5 -5
- package/dist/lib/npm-auth.d.ts +9 -0
- package/dist/lib/npm-auth.js +48 -0
- package/dist/lib/scaffold-render-sweep.d.ts +3 -2
- package/dist/lib/scaffold-render-sweep.js +5 -8
- package/dist/module-architecture.js +99 -9
- package/dist/paid-sections.d.ts +21 -2
- package/dist/paid-sections.js +69 -7
- package/dist/programmatic.js +19 -5
- package/dist/seed-flows.d.ts +4 -1
- package/dist/seed-flows.js +50 -4
- package/dist/site-chrome.d.ts +8 -0
- package/dist/site-chrome.js +17 -1
- package/dist/spoke-checkout.d.ts +65 -41
- package/dist/spoke-checkout.js +208 -430
- package/dist/starter-grid.d.ts +0 -3
- package/dist/starter-grid.js +24 -14
- package/dist/surfaces.js +52 -26
- package/dist/sync-routes.d.ts +38 -1
- package/dist/sync-routes.js +187 -13
- package/dist/template-record.d.ts +4 -3
- package/dist/template-record.js +8 -4
- package/dist/topology.js +25 -1
- package/dist/update.js +15 -0
- package/package.json +3 -3
- package/site-templates/_base/content/en/NewsletterSignup/newsletter.mdx +4 -49
- package/site-templates/_base/content/en/Pricing/pricing.mdx +3 -21
- package/site-templates/designs/minimalism/DESIGN.md +1 -1
- package/site-templates/marketing-site/TEMPLATE-MANIFEST.json +23 -20
- package/site-templates/marketing-site/TEMPLATE-MANIFEST.md +28 -14
- package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.json +15 -39
- package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.md +38 -34
- package/site-templates/marketing-site-free/content/en/NewsletterSignup/newsletter.mdx +6 -43
- package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.json +14 -31
- package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.md +26 -25
- package/site-templates/shapes/local-business-service/content/en/NewsletterSignup/newsletter.mdx +6 -43
- package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.json +14 -31
- package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.md +26 -25
- package/site-templates/shapes/organization-service/content/en/NewsletterSignup/newsletter.mdx +6 -43
- package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.json +14 -31
- package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.md +26 -25
- package/site-templates/shapes/person-service/content/en/NewsletterSignup/newsletter.mdx +6 -43
- package/templates/.env.example +9 -7
- package/templates/.github/workflows/ci.yml +13 -0
- package/templates/README.md +1 -0
- package/templates/_gitignore +4 -0
- package/templates/apps/api/.env.example +27 -0
- package/templates/apps/api/CLAUDE.md +87 -17
- package/templates/apps/api/package.json +1 -0
- package/templates/apps/api/src/__tests__/factories/in-memory-prisma.ts +2 -0
- package/templates/apps/api/src/bin/stripe-connections-rekey.ts +45 -0
- package/templates/apps/api/src/config/__tests__/stripe-connection-key.test.ts +185 -0
- package/templates/apps/api/src/config/index.ts +109 -0
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +3 -0
- package/templates/apps/api/src/lib/__tests__/consent-store.test.ts +19 -0
- package/templates/apps/api/src/lib/__tests__/flow-completion-store.test.ts +149 -0
- package/templates/apps/api/src/lib/__tests__/flow-rename-race.db.test.ts +116 -0
- package/templates/apps/api/src/lib/consent-store.ts +28 -0
- package/templates/apps/api/src/lib/error-serializer.ts +74 -7
- package/templates/apps/api/src/lib/flow-completion-store.ts +136 -0
- package/templates/apps/api/src/lib/hub-sign-in-store.ts +38 -2
- package/templates/apps/api/src/lib/proposal-paid-store.ts +21 -4
- package/templates/apps/api/src/lib/stripe.ts +74 -4
- package/templates/apps/api/src/lib/webhook-idempotency.ts +66 -2
- package/templates/apps/api/src/middleware/__tests__/auth.hub-session-path.test.ts +14 -3
- package/templates/apps/api/src/middleware/__tests__/rate-limit.test.ts +218 -0
- package/templates/apps/api/src/middleware/__tests__/write-budget.test.ts +174 -0
- package/templates/apps/api/src/middleware/auth.ts +13 -6
- package/templates/apps/api/src/middleware/rate-limit.ts +226 -4
- package/templates/apps/api/src/openapi/spec.ts +33 -3
- package/templates/apps/api/src/routes/auth/__tests__/hub-sign-in.test.ts +49 -0
- package/templates/apps/api/src/routes/auth/hub-sign-in.ts +41 -0
- package/templates/apps/api/src/routes/billing/plan-checkout.ts +325 -0
- package/templates/apps/api/src/routes/checkout/__tests__/live-key.test.ts +11 -0
- package/templates/apps/api/src/routes/checkout/__tests__/offerings-authorization.test.ts +1300 -0
- package/templates/apps/api/src/routes/checkout/__tests__/session.test.ts +11 -0
- package/templates/apps/api/src/routes/checkout/__tests__/sessions.test.ts +49 -0
- package/templates/apps/api/src/routes/checkout/session.ts +57 -25
- package/templates/apps/api/src/routes/checkout/sessions.ts +232 -82
- package/templates/apps/api/src/routes/consent/__tests__/account.test.ts +386 -0
- package/templates/apps/api/src/routes/consent/__tests__/sign-up-rate-limit.test.ts +160 -0
- package/templates/apps/api/src/routes/consent/account.ts +268 -0
- package/templates/apps/api/src/routes/consent/index.ts +15 -7
- package/templates/apps/api/src/routes/content/__tests__/get-page.test.ts +36 -0
- package/templates/apps/api/src/routes/content/__tests__/offerings.test.ts +731 -0
- package/templates/apps/api/src/routes/content/__tests__/pricing.test.ts +753 -0
- package/templates/apps/api/src/routes/content/__tests__/shown-offerings.test.ts +762 -0
- package/templates/apps/api/src/routes/content/get-page.ts +4 -0
- package/templates/apps/api/src/routes/content/index.ts +16 -2
- package/templates/apps/api/src/routes/content/offerings.ts +184 -0
- package/templates/apps/api/src/routes/content/pricing.ts +176 -0
- package/templates/apps/api/src/routes/content/shown-offerings.ts +229 -0
- package/templates/apps/api/src/routes/leads/__tests__/magnet-completion.test.ts +515 -0
- package/templates/apps/api/src/routes/leads/index.ts +164 -7
- package/templates/apps/api/src/routes/webhooks/README.md +66 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-checkout-consent.test.ts +649 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-offerings.test.ts +814 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-org-billing.test.ts +80 -68
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-site-filter.test.ts +5 -5
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe.test.ts +8 -2
- package/templates/apps/api/src/routes/webhooks/index.ts +23 -0
- package/templates/apps/api/src/routes/webhooks/stripe-offerings.ts +384 -0
- package/templates/apps/api/src/routes/webhooks/stripe.ts +245 -36
- package/templates/apps/api/src/server.ts +163 -46
- package/templates/apps/api/src/services/__tests__/checkout-plan.test.ts +313 -0
- package/templates/apps/api/src/services/__tests__/deliverable-fulfillment.test.ts +51 -2
- package/templates/apps/api/src/services/__tests__/keyless-workspace-predicate.test.ts +234 -0
- package/templates/apps/api/src/services/__tests__/lead-routing.test.ts +1383 -133
- package/templates/apps/api/src/services/__tests__/magnet-completion.test.ts +389 -0
- package/templates/apps/api/src/services/__tests__/person.test.ts +232 -1
- package/templates/apps/api/src/services/__tests__/plan-offerings.test.ts +444 -0
- package/templates/apps/api/src/services/checkout-buyer.ts +100 -4
- package/templates/apps/api/src/services/consent.ts +95 -0
- package/templates/apps/api/src/services/deliverable-fulfillment.ts +13 -5
- package/templates/apps/api/src/services/entitlements.ts +157 -1
- package/templates/apps/api/src/services/lead-routing.ts +431 -47
- package/templates/apps/api/src/services/magnet-completion.ts +242 -0
- package/templates/apps/api/src/services/offerings/__tests__/catalog.test.ts +295 -0
- package/templates/apps/api/src/services/offerings/__tests__/checkout-session-record.test.ts +268 -0
- package/templates/apps/api/src/services/offerings/__tests__/connection.test.ts +868 -0
- package/templates/apps/api/src/services/offerings/__tests__/fixtures.ts +416 -0
- package/templates/apps/api/src/services/offerings/__tests__/org-products.test.ts +396 -0
- package/templates/apps/api/src/services/offerings/__tests__/readers.test.ts +681 -0
- package/templates/apps/api/src/services/offerings/__tests__/source.test.ts +231 -0
- package/templates/apps/api/src/services/offerings/catalog.ts +308 -0
- package/templates/apps/api/src/services/offerings/checkout-authorization.ts +385 -0
- package/templates/apps/api/src/services/offerings/checkout-session-record.ts +192 -0
- package/templates/apps/api/src/services/offerings/connection.ts +1003 -0
- package/templates/apps/api/src/services/offerings/index.ts +614 -0
- package/templates/apps/api/src/services/offerings/source.ts +140 -0
- package/templates/apps/api/src/services/offerings/store.ts +150 -0
- package/templates/apps/api/src/services/person.ts +164 -17
- package/templates/apps/api/src/services/plan-offerings.ts +125 -0
- package/templates/apps/api/src/services/public-site-resolver.ts +27 -15
- package/templates/apps/mcp/CLAUDE.md +22 -14
- package/templates/apps/mcp/__tests__/catalog-drift.test.ts +9 -4
- package/templates/apps/mcp/__tests__/get_offerings.test.ts +358 -0
- package/templates/apps/mcp/__tests__/get_pricing.test.ts +364 -0
- package/templates/apps/mcp/__tests__/http-transport.test.ts +4 -4
- package/templates/apps/mcp/__tests__/module-exclusion.test.ts +2 -2
- package/templates/apps/mcp/__tests__/server.test.ts +13 -11
- package/templates/apps/mcp/__tests__/start_purchase.test.ts +208 -12
- package/templates/apps/mcp/__tests__/tools/purchase.test.ts +11 -11
- package/templates/apps/mcp/src/lib/shown-offerings.ts +105 -0
- package/templates/apps/mcp/src/server.ts +5 -0
- package/templates/apps/mcp/src/tools/get_offerings.ts +47 -30
- package/templates/apps/mcp/src/tools/get_pricing.ts +40 -40
- package/templates/apps/mcp/src/tools/purchase.ts +30 -2
- package/templates/apps/mcp/src/workspace-server.ts +15 -0
- package/templates/apps/web/.env.example +24 -31
- package/templates/apps/web/CLAUDE.md +393 -9
- package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +6 -2
- package/templates/apps/web/app/[locale]/(auth)/__tests__/auth-pages.test.tsx +5 -4
- package/templates/apps/web/app/[locale]/(auth)/forgot-password/forgot-password-card.tsx +5 -1
- package/templates/apps/web/app/[locale]/(auth)/forgot-password/page.tsx +2 -0
- package/templates/apps/web/app/[locale]/(auth)/layout.tsx +3 -14
- package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +2 -0
- package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +5 -1
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +160 -8
- package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +12 -9
- package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +105 -2
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +36 -3
- package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +47 -1
- package/templates/apps/web/app/[locale]/(auth)/sign-up/__tests__/sign-up-card.test.tsx +60 -22
- package/templates/apps/web/app/[locale]/(auth)/sign-up/page.tsx +16 -8
- package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up-card.tsx +85 -31
- package/templates/apps/web/app/[locale]/(auth)/use-auth-card-flow.ts +18 -4
- package/templates/apps/web/app/[locale]/(auth)/verify-email/page.tsx +3 -1
- package/templates/apps/web/app/[locale]/(authed)/__tests__/gate.test.tsx +7 -4
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +227 -207
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +17 -1
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +143 -1
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +4 -0
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +385 -89
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +5 -0
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +44 -5
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +68 -34
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -8
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +39 -151
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +61 -0
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +143 -140
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +40 -6
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +68 -54
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +5 -1
- package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +189 -0
- package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +295 -0
- package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +120 -0
- package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +23 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +319 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +172 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +149 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +141 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +424 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +72 -11
- package/templates/apps/web/app/[locale]/careers/page.tsx +129 -5
- package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +2 -2
- package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +139 -0
- package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +136 -0
- package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +114 -0
- package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +51 -0
- package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +17 -1
- package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +79 -4
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +160 -13
- package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +466 -36
- package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +7 -0
- package/templates/apps/web/app/[locale]/contact/contact.actions.ts +172 -57
- package/templates/apps/web/app/[locale]/contact/intake-script.ts +26 -0
- package/templates/apps/web/app/[locale]/contact/page.tsx +99 -60
- package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +2 -2
- package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +2 -2
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +341 -4
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +43 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +200 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +197 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +257 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +69 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +430 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +21 -9
- package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +35 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +352 -0
- package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +12 -73
- package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +10 -31
- package/templates/apps/web/app/[locale]/for/__tests__/page-renderer-migration.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +2 -2
- package/templates/apps/web/app/[locale]/layout.tsx +55 -4
- package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +174 -104
- package/templates/apps/web/app/[locale]/newsletter/page.tsx +95 -58
- package/templates/apps/web/app/[locale]/page.tsx +13 -1
- package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +2 -2
- package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +7 -0
- package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +599 -0
- package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +216 -0
- package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +236 -0
- package/templates/apps/web/app/[locale]/pricing/page.tsx +367 -6
- package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +2 -2
- package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +2 -2
- package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +2 -2
- package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +4 -1
- package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +1 -1
- package/templates/apps/web/app/[locale]/thanks/[slug]/AccountInviteLink.tsx +89 -0
- package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/AccountInviteLink.test.tsx +104 -0
- package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +38 -0
- package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +9 -0
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +17 -0
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +62 -3
- package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +70 -18
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +30 -9
- package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +1 -1
- package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +114 -0
- package/templates/apps/web/app/api/auth/hub/authorize/route.ts +20 -3
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +44 -1
- package/templates/apps/web/app/api/hub-session/sign-in/route.ts +22 -3
- package/templates/apps/web/app/api/offerings/checkout/[lookupKey]/route.ts +316 -0
- package/templates/apps/web/app/api/offerings/checkout/__tests__/route.test.ts +810 -0
- package/templates/apps/web/auth.ts +28 -2
- package/templates/apps/web/lib/__tests__/account-invite.test.ts +63 -0
- package/templates/apps/web/lib/__tests__/auth-routes.test.ts +27 -1
- package/templates/apps/web/lib/__tests__/consent-policies.test.ts +23 -0
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +7 -1
- package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +265 -0
- package/templates/apps/web/lib/__tests__/magnet-routes.test.ts +57 -0
- package/templates/apps/web/lib/__tests__/newsletter.actions.test.ts +293 -0
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +601 -0
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +101 -25
- package/templates/apps/web/lib/account-invite.ts +37 -0
- package/templates/apps/web/lib/auth-routes.ts +36 -2
- package/templates/apps/web/lib/checkout-config.ts +16 -0
- package/templates/apps/web/lib/consent-policies.ts +22 -0
- package/templates/apps/web/lib/deck-page.ts +7 -0
- package/templates/apps/web/lib/deliverable-grant.ts +18 -0
- package/templates/apps/web/lib/hub-session/__tests__/sign-in-gate.test.tsx +111 -0
- package/templates/apps/web/lib/hub-session/sign-in-gate.tsx +88 -32
- package/templates/apps/web/lib/in-page-magnet.ts +416 -0
- package/templates/apps/web/lib/magnet-routes.ts +42 -0
- package/templates/apps/web/lib/modules.generated.ts +9 -0
- package/templates/apps/web/lib/newsletter.actions.ts +202 -0
- package/templates/apps/web/lib/offerings-pricing.ts +326 -0
- package/templates/apps/web/lib/posting-title.ts +17 -0
- package/templates/apps/web/lib/prisma-for-auth.ts +8 -0
- package/templates/apps/web/lib/sign-up-agreements.ts +449 -0
- package/templates/apps/web/lib/site-chrome.ts +2 -0
- package/templates/apps/web/lib/telemetry-scrub.ts +5 -1
- package/templates/apps/web/messages/en.json +71 -20
- package/templates/apps/web/middleware.ts +12 -2
- package/templates/apps/web/package.json +1 -0
- package/templates/apps/web/security-headers.config.ts +17 -0
- package/templates/apps/web/src/lib/__tests__/lead-write.test.ts +187 -0
- package/templates/apps/web/src/lib/__tests__/rate-limit.test.ts +67 -0
- package/templates/apps/web/src/lib/lead-write.ts +90 -0
- package/templates/apps/web/src/lib/rate-limit.ts +79 -0
- package/templates/content/en/BlogList/blog.mdx +4 -71
- package/templates/content/en/BookCall/book-a-call.mdx +1 -41
- package/templates/content/en/BookCall/onsite-estimate.mdx +1 -17
- package/templates/content/en/BookCall/onsite-service.mdx +1 -17
- package/templates/content/en/BookCall/start-project.mdx +1 -17
- package/templates/content/en/ContactPage/contact.mdx +6 -63
- package/templates/content/en/HomePage/home.mdx +3 -21
- package/templates/database/CHANGELOG.md +69 -0
- package/templates/database/__tests__/consent-source-checkout-migration.test.ts +79 -0
- package/templates/database/__tests__/flow-completion-migration.test.ts +115 -0
- package/templates/database/__tests__/flow-completion.db.test.ts +136 -0
- package/templates/database/__tests__/in-page-magnets-migration.test.ts +161 -0
- package/templates/database/__tests__/offerings-checkout-session.db.test.ts +270 -0
- package/templates/database/__tests__/offerings-migration.test.ts +197 -0
- package/templates/database/__tests__/offerings-shown-price-ids-migration.test.ts +86 -0
- package/templates/database/__tests__/offerings.db.test.ts +303 -0
- package/templates/database/__tests__/seed.test.ts +64 -1
- package/templates/database/auth/schema.prisma +4 -0
- package/templates/database/config/schema.prisma +91 -0
- package/templates/database/inbox/schema.prisma +17 -2
- package/templates/database/migrations/20261018120000_flow_completion/migration.sql +52 -0
- package/templates/database/migrations/20261019120000_consent_source_checkout/migration.sql +27 -0
- package/templates/database/migrations/20261020120000_offerings_data_model/migration.sql +146 -0
- package/templates/database/migrations/20261021120000_offerings_checkout_session/migration.sql +77 -0
- package/templates/database/migrations/20261022120000_in_page_magnets/migration.sql +45 -0
- package/templates/database/migrations/20261023120000_offerings_shown_price_ids/migration.sql +47 -0
- package/templates/database/migrations/20261024120000_organization_plan_checkout_session/migration.sql +16 -0
- package/templates/database/package.json +1 -1
- package/templates/database/seed.ts +62 -3
- package/versions.json +35 -35
- package/site-templates/marketing-site-free/content/en/Pricing/pricing.mdx +0 -199
- package/templates/apps/web/app/[locale]/(auth)/sign-up/sign-up.actions.ts +0 -125
- package/templates/apps/web/app/[locale]/downloads/__tests__/page-renderer-migration.test.tsx +0 -93
- package/templates/apps/web/app/[locale]/downloads/page.tsx +0 -37
- package/templates/apps/web/app/[locale]/newsletter/__tests__/newsletter.actions.test.ts +0 -139
- package/templates/apps/web/app/[locale]/newsletter/newsletter.actions.ts +0 -93
- package/templates/apps/web/lib/__tests__/meeting-slugs.test.ts +0 -120
- package/templates/apps/web/lib/meeting-slugs.ts +0 -63
|
@@ -61,7 +61,7 @@ describe("software/[slug] — snapshot regression", () => {
|
|
|
61
61
|
});
|
|
62
62
|
const { container } = render(element);
|
|
63
63
|
expect(container.innerHTML).toMatchInlineSnapshot(`
|
|
64
|
-
"<script type="application/ld+json" data-testid="json-ld">{"@context":"https://schema.org","@type":"WebPage","inLanguage":"en","name":"@working-theory/page-renderer","description":"Single rendering primitive for MDX-wired routes.","mainEntity":{"@context":"https://schema.org","@type":"SoftwareApplication","name":"@working-theory/page-renderer","description":"Single rendering primitive for MDX-wired routes."}}</script><main id="main"><div class="mx-auto w-full max-w-container-xl px-4 md:px-6 lg:px-8 py-section"><h1 class="text-heading-1 lg:text-display-sm font-display text-fg hero-type-display">@working-theory/page-renderer</h1><p data-testid="software-description" class="mt-block-tight text-lead">Single rendering primitive for MDX-wired routes.</p><div data-testid="markdown-view-toggle" class="ailk-markdown-view-toggle mt-block-loose"><div class="flex justify-end mb-3"><div role="radiogroup" aria-label="Page view" data-testid="markdown-view-toggle" class="inline-flex items-center gap-0.5 rounded-lg p-1 bg-(--color-surface-secondary)"><button class="inline-flex items-center justify-center gap-2 font-medium transition-
|
|
64
|
+
"<script type="application/ld+json" data-testid="json-ld">{"@context":"https://schema.org","@type":"WebPage","inLanguage":"en","name":"@working-theory/page-renderer","description":"Single rendering primitive for MDX-wired routes.","mainEntity":{"@context":"https://schema.org","@type":"SoftwareApplication","name":"@working-theory/page-renderer","description":"Single rendering primitive for MDX-wired routes."}}</script><main id="main"><div class="mx-auto w-full max-w-container-xl px-4 md:px-6 lg:px-8 py-section"><h1 class="text-heading-1 lg:text-display-sm font-display text-fg hero-type-display">@working-theory/page-renderer</h1><p data-testid="software-description" class="mt-block-tight text-lead">Single rendering primitive for MDX-wired routes.</p><div data-testid="markdown-view-toggle" class="ailk-markdown-view-toggle mt-block-loose"><div class="flex justify-end mb-3"><div role="radiogroup" aria-label="Page view" data-testid="markdown-view-toggle" class="inline-flex items-center gap-0.5 rounded-lg p-1 bg-(--color-surface-secondary)"><button class="inline-flex items-center justify-center gap-2 font-medium motion-safe:transition motion-safe:duration-(--button-hover-duration) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&>svg]:shrink-0 text-(--color-fg) not-disabled:hover:bg-(--button-hover-quiet-bg) not-disabled:hover:text-(--button-hover-quiet-fg) not-disabled:hover:opacity-(--button-hover-opacity) not-disabled:hover:transform-(--button-hover-transform) not-disabled:hover:shadow-(--button-hover-shadow) not-disabled:active:bg-gray-200 not-disabled:active:text-(--color-fg) rounded-control px-control-x h-(--control-height-thin) text-caption leading-none rounded-md px-3 text-body-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 min-w-(--control-height-thin) min-h-(--control-height-big) bg-(--color-bg) text-(--color-fg) shadow-sm" type="button" role="radio" aria-checked="true" aria-label="Rendered" tabindex="0" data-testid="markdown-view-toggle-rendered">Rendered</button><button class="inline-flex items-center justify-center gap-2 font-medium motion-safe:transition motion-safe:duration-(--button-hover-duration) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&>svg]:shrink-0 text-(--color-fg) not-disabled:hover:bg-(--button-hover-quiet-bg) not-disabled:hover:text-(--button-hover-quiet-fg) not-disabled:hover:opacity-(--button-hover-opacity) not-disabled:hover:transform-(--button-hover-transform) not-disabled:hover:shadow-(--button-hover-shadow) not-disabled:active:bg-gray-200 not-disabled:active:text-(--color-fg) rounded-control px-control-x h-(--control-height-thin) text-caption leading-none rounded-md px-3 text-body-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 min-w-(--control-height-thin) min-h-(--control-height-big) text-(--color-text-muted) hover:text-(--color-fg)" type="button" role="radio" aria-checked="false" aria-label="Markdown" tabindex="-1" data-testid="markdown-view-toggle-markdown">Markdown</button></div></div><div role="status" aria-live="polite" aria-atomic="true" class="sr-only" data-testid="markdown-view-toggle-status">Showing Rendered view</div><div data-testid="markdown-view-rendered"><article data-testid="mdx-body"><div class="ailk-prose max-w-none text-(--color-text-muted) text-body-sm leading-relaxed [&>*:first-child]:mt-0 [&_h2]:mt-block-loose [&_h2]:scroll-mt-24 [&_h2]:text-heading-3 [&_h2]:font-display [&_h2]:text-(--color-fg) [&_h3]:mt-block-loose [&_h3]:scroll-mt-24 [&_h3]:text-heading-4 [&_h3]:font-display [&_h3]:text-(--color-fg) [&_h4]:mt-block-tight [&_h4]:scroll-mt-24 [&_h4]:text-heading-4 [&_h4]:font-display [&_h4]:text-(--color-fg) [&_h5]:mt-block-tight [&_h5]:scroll-mt-24 [&_h5]:text-heading-4 [&_h5]:font-display [&_h5]:text-(--color-fg) [&_h6]:mt-block-tight [&_h6]:scroll-mt-24 [&_h6]:text-heading-4 [&_h6]:font-display [&_h6]:text-(--color-fg) [&_p]:mt-paragraph [&_strong]:font-semibold [&_strong]:text-(--color-fg) [&_em]:italic [&_ul]:mt-paragraph [&_ul]:list-disc [&_ul]:ps-6 [&_ol]:mt-paragraph [&_ol]:list-decimal [&_ol]:ps-6 [&_li]:mt-1 [&_li]:ps-1 [&_li]:marker:text-(--color-text-muted) [&_li>ul]:mt-1 [&_li>ol]:mt-1 [&_blockquote]:mt-paragraph [&_blockquote]:border-s-4 [&_blockquote]:border-(--color-border-strong) [&_blockquote]:ps-4 [&_blockquote]:italic [&_blockquote]:text-(--color-text-muted) [&_hr]:my-block-loose [&_hr]:border-(--color-border) [&_a]:text-(--color-accent) [&_a]:underline [&_a]:underline-offset-4 [&_:not(pre)>code]:rounded [&_:not(pre)>code]:bg-(--color-surface-secondary) [&_:not(pre)>code]:px-1.5 [&_:not(pre)>code]:py-0.5 [&_:not(pre)>code]:text-code [&_:not(pre)>code]:font-mono [&_:not(pre)>code]:text-(--color-fg) [&_pre]:mt-paragraph [&_pre]:overflow-auto [&_pre]:rounded-md [&_pre]:border-hairline [&_pre]:border-(--color-border) [&_pre]:bg-(--color-bg) [&_pre]:p-4 [&_pre]:font-mono [&_pre]:text-body-sm [&_img]:mt-paragraph [&_img]:h-auto [&_img]:max-w-full [&_img]:rounded-lg [&_table]:mt-paragraph [&_table]:w-full [&_table]:border-collapse [&_table]:text-body-sm [&_th]:border-b [&_th]:border-(--color-border) [&_th]:bg-(--color-surface-secondary) [&_th]:px-3 [&_th]:py-2 [&_th]:text-start [&_th]:font-semibold [&_th]:text-(--color-fg) [&_td]:border-b [&_td]:border-(--color-border) [&_td]:px-3 [&_td]:py-2 [&_kbd]:rounded [&_kbd]:border-hairline [&_kbd]:border-(--color-border) [&_kbd]:bg-(--color-surface-secondary) [&_kbd]:px-1.5 [&_kbd]:py-0.5 [&_kbd]:text-caption [&_kbd]:font-mono" data-testid="mdx-content"><div data-testid="mdx-rendered">## Overview
|
|
65
65
|
|
|
66
66
|
Body content.</div></div></article></div></div></div></main>"
|
|
67
67
|
`);
|
|
@@ -68,7 +68,10 @@ describe("team/[slug] — the profile page", () => {
|
|
|
68
68
|
const person = profile["mainEntity"] as JsonLd;
|
|
69
69
|
expect(person["@type"]).toBe("Person");
|
|
70
70
|
expect(person["@id"]).toBe("#person");
|
|
71
|
-
|
|
71
|
+
// The seed's `jobTitle` is a `{placeholder}` slot, which never reaches the
|
|
72
|
+
// graph (#8797 D8.5).
|
|
73
|
+
expect(FIRST_MEMBER.frontmatter.schema.jobTitle).toBe("{Their title}");
|
|
74
|
+
expect(person).not.toHaveProperty("jobTitle");
|
|
72
75
|
|
|
73
76
|
const breadcrumb = graph.find((b) => b["@type"] === "BreadcrumbList")!;
|
|
74
77
|
const items = breadcrumb["itemListElement"] as Array<{ item: string }>;
|
package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx
CHANGED
|
@@ -62,7 +62,7 @@ describe("tech-articles/[slug] — snapshot regression", () => {
|
|
|
62
62
|
});
|
|
63
63
|
const { container } = render(element);
|
|
64
64
|
expect(container.innerHTML).toMatchInlineSnapshot(`
|
|
65
|
-
"<script type="application/ld+json" data-testid="json-ld">{"@context":"https://schema.org","@graph":[{"@context":"https://schema.org","@type":"WebPage","inLanguage":"en","name":"AEO Layer 1 Scoring","description":"Deep dive into AEO Layer 1 scoring and AILK audit internals.","mainEntity":{"@context":"https://schema.org","@type":"TechArticle","headline":"AEO Layer 1 Scoring","description":"Deep dive into AEO Layer 1 scoring and AILK audit internals."}},{"@context":"https://schema.org","@type":"BreadcrumbList","inLanguage":"en","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http://localhost:3000/en/"},{"@type":"ListItem","position":2,"name":"Tech Articles","item":"http://localhost:3000/en/tech-articles"},{"@type":"ListItem","position":3,"name":"AEO Layer 1 Scoring","item":"http://localhost:3000/en/tech-articles/aeo-layer1-scoring"}]}]}</script><main id="main"><div class="mx-auto w-full max-w-container-xl px-4 md:px-6 lg:px-8 py-section"><h1 class="text-heading-1 lg:text-display-sm font-display text-fg hero-type-display">AEO Layer 1 Scoring</h1><p data-testid="tech-article-description" class="mt-block-tight text-lead">Deep dive into AEO Layer 1 scoring and AILK audit internals.</p><div data-testid="markdown-view-toggle" class="ailk-markdown-view-toggle mt-block-loose"><div class="flex justify-end mb-3"><div role="radiogroup" aria-label="Page view" data-testid="markdown-view-toggle" class="inline-flex items-center gap-0.5 rounded-lg p-1 bg-(--color-surface-secondary)"><button class="inline-flex items-center justify-center gap-2 font-medium transition-
|
|
65
|
+
"<script type="application/ld+json" data-testid="json-ld">{"@context":"https://schema.org","@graph":[{"@context":"https://schema.org","@type":"WebPage","inLanguage":"en","name":"AEO Layer 1 Scoring","description":"Deep dive into AEO Layer 1 scoring and AILK audit internals.","mainEntity":{"@context":"https://schema.org","@type":"TechArticle","headline":"AEO Layer 1 Scoring","description":"Deep dive into AEO Layer 1 scoring and AILK audit internals."}},{"@context":"https://schema.org","@type":"BreadcrumbList","inLanguage":"en","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http://localhost:3000/en/"},{"@type":"ListItem","position":2,"name":"Tech Articles","item":"http://localhost:3000/en/tech-articles"},{"@type":"ListItem","position":3,"name":"AEO Layer 1 Scoring","item":"http://localhost:3000/en/tech-articles/aeo-layer1-scoring"}]}]}</script><main id="main"><div class="mx-auto w-full max-w-container-xl px-4 md:px-6 lg:px-8 py-section"><h1 class="text-heading-1 lg:text-display-sm font-display text-fg hero-type-display">AEO Layer 1 Scoring</h1><p data-testid="tech-article-description" class="mt-block-tight text-lead">Deep dive into AEO Layer 1 scoring and AILK audit internals.</p><div data-testid="markdown-view-toggle" class="ailk-markdown-view-toggle mt-block-loose"><div class="flex justify-end mb-3"><div role="radiogroup" aria-label="Page view" data-testid="markdown-view-toggle" class="inline-flex items-center gap-0.5 rounded-lg p-1 bg-(--color-surface-secondary)"><button class="inline-flex items-center justify-center gap-2 font-medium motion-safe:transition motion-safe:duration-(--button-hover-duration) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&>svg]:shrink-0 text-(--color-fg) not-disabled:hover:bg-(--button-hover-quiet-bg) not-disabled:hover:text-(--button-hover-quiet-fg) not-disabled:hover:opacity-(--button-hover-opacity) not-disabled:hover:transform-(--button-hover-transform) not-disabled:hover:shadow-(--button-hover-shadow) not-disabled:active:bg-gray-200 not-disabled:active:text-(--color-fg) rounded-control px-control-x h-(--control-height-thin) text-caption leading-none rounded-md px-3 text-body-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 min-w-(--control-height-thin) min-h-(--control-height-big) bg-(--color-bg) text-(--color-fg) shadow-sm" type="button" role="radio" aria-checked="true" aria-label="Rendered" tabindex="0" data-testid="markdown-view-toggle-rendered">Rendered</button><button class="inline-flex items-center justify-center gap-2 font-medium motion-safe:transition motion-safe:duration-(--button-hover-duration) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&>svg]:shrink-0 text-(--color-fg) not-disabled:hover:bg-(--button-hover-quiet-bg) not-disabled:hover:text-(--button-hover-quiet-fg) not-disabled:hover:opacity-(--button-hover-opacity) not-disabled:hover:transform-(--button-hover-transform) not-disabled:hover:shadow-(--button-hover-shadow) not-disabled:active:bg-gray-200 not-disabled:active:text-(--color-fg) rounded-control px-control-x h-(--control-height-thin) text-caption leading-none rounded-md px-3 text-body-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 min-w-(--control-height-thin) min-h-(--control-height-big) text-(--color-text-muted) hover:text-(--color-fg)" type="button" role="radio" aria-checked="false" aria-label="Markdown" tabindex="-1" data-testid="markdown-view-toggle-markdown">Markdown</button></div></div><div role="status" aria-live="polite" aria-atomic="true" class="sr-only" data-testid="markdown-view-toggle-status">Showing Rendered view</div><div data-testid="markdown-view-rendered"><article data-testid="mdx-body"><div class="ailk-prose max-w-none text-(--color-text-muted) text-body-sm leading-relaxed [&>*:first-child]:mt-0 [&_h2]:mt-block-loose [&_h2]:scroll-mt-24 [&_h2]:text-heading-3 [&_h2]:font-display [&_h2]:text-(--color-fg) [&_h3]:mt-block-loose [&_h3]:scroll-mt-24 [&_h3]:text-heading-4 [&_h3]:font-display [&_h3]:text-(--color-fg) [&_h4]:mt-block-tight [&_h4]:scroll-mt-24 [&_h4]:text-heading-4 [&_h4]:font-display [&_h4]:text-(--color-fg) [&_h5]:mt-block-tight [&_h5]:scroll-mt-24 [&_h5]:text-heading-4 [&_h5]:font-display [&_h5]:text-(--color-fg) [&_h6]:mt-block-tight [&_h6]:scroll-mt-24 [&_h6]:text-heading-4 [&_h6]:font-display [&_h6]:text-(--color-fg) [&_p]:mt-paragraph [&_strong]:font-semibold [&_strong]:text-(--color-fg) [&_em]:italic [&_ul]:mt-paragraph [&_ul]:list-disc [&_ul]:ps-6 [&_ol]:mt-paragraph [&_ol]:list-decimal [&_ol]:ps-6 [&_li]:mt-1 [&_li]:ps-1 [&_li]:marker:text-(--color-text-muted) [&_li>ul]:mt-1 [&_li>ol]:mt-1 [&_blockquote]:mt-paragraph [&_blockquote]:border-s-4 [&_blockquote]:border-(--color-border-strong) [&_blockquote]:ps-4 [&_blockquote]:italic [&_blockquote]:text-(--color-text-muted) [&_hr]:my-block-loose [&_hr]:border-(--color-border) [&_a]:text-(--color-accent) [&_a]:underline [&_a]:underline-offset-4 [&_:not(pre)>code]:rounded [&_:not(pre)>code]:bg-(--color-surface-secondary) [&_:not(pre)>code]:px-1.5 [&_:not(pre)>code]:py-0.5 [&_:not(pre)>code]:text-code [&_:not(pre)>code]:font-mono [&_:not(pre)>code]:text-(--color-fg) [&_pre]:mt-paragraph [&_pre]:overflow-auto [&_pre]:rounded-md [&_pre]:border-hairline [&_pre]:border-(--color-border) [&_pre]:bg-(--color-bg) [&_pre]:p-4 [&_pre]:font-mono [&_pre]:text-body-sm [&_img]:mt-paragraph [&_img]:h-auto [&_img]:max-w-full [&_img]:rounded-lg [&_table]:mt-paragraph [&_table]:w-full [&_table]:border-collapse [&_table]:text-body-sm [&_th]:border-b [&_th]:border-(--color-border) [&_th]:bg-(--color-surface-secondary) [&_th]:px-3 [&_th]:py-2 [&_th]:text-start [&_th]:font-semibold [&_th]:text-(--color-fg) [&_td]:border-b [&_td]:border-(--color-border) [&_td]:px-3 [&_td]:py-2 [&_kbd]:rounded [&_kbd]:border-hairline [&_kbd]:border-(--color-border) [&_kbd]:bg-(--color-surface-secondary) [&_kbd]:px-1.5 [&_kbd]:py-0.5 [&_kbd]:text-caption [&_kbd]:font-mono" data-testid="mdx-content"><div data-testid="mdx-rendered">## AEO Layer 1
|
|
66
66
|
|
|
67
67
|
Body content.</div></div></article></div></div></div></main>"
|
|
68
68
|
`);
|
package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx
CHANGED
|
@@ -79,7 +79,7 @@ describe("TestimonialsPage — snapshot regression", () => {
|
|
|
79
79
|
});
|
|
80
80
|
const { container } = render(element);
|
|
81
81
|
expect(container.innerHTML).toMatchInlineSnapshot(
|
|
82
|
-
`"<script type="application/ld+json" data-testid="json-ld">{"@context":"https://schema.org","@type":"CollectionPage","inLanguage":"en","name":"Customer Testimonials","description":"What our customers say.","mainEntity":{"@type":"ItemList","itemListElement":[{"@type":"Review"}]},"aggregateRating":{"@context":"https://schema.org","@type":"AggregateRating","ratingValue":4.9,"reviewCount":0,"bestRating":5,"worstRating":1,"itemReviewed":{"@type":"SoftwareApplication"}}}</script><main id="main"><div><h1>Customer Testimonials</h1><p data-testid="testimonials-description" class="mt-block-tight text-lead">What our customers say.</p><div data-testid="markdown-view-toggle" class="ailk-markdown-view-toggle mt-block-loose"><div class="flex justify-end mb-3"><div role="radiogroup" aria-label="Page view" data-testid="markdown-view-toggle" class="inline-flex items-center gap-0.5 rounded-lg p-1 bg-(--color-surface-secondary)"><button class="inline-flex items-center justify-center gap-2 font-medium transition-
|
|
82
|
+
`"<script type="application/ld+json" data-testid="json-ld">{"@context":"https://schema.org","@type":"CollectionPage","inLanguage":"en","name":"Customer Testimonials","description":"What our customers say.","mainEntity":{"@type":"ItemList","itemListElement":[{"@type":"Review"}]},"aggregateRating":{"@context":"https://schema.org","@type":"AggregateRating","ratingValue":4.9,"reviewCount":0,"bestRating":5,"worstRating":1,"itemReviewed":{"@type":"SoftwareApplication"}}}</script><main id="main"><div><h1>Customer Testimonials</h1><p data-testid="testimonials-description" class="mt-block-tight text-lead">What our customers say.</p><div data-testid="markdown-view-toggle" class="ailk-markdown-view-toggle mt-block-loose"><div class="flex justify-end mb-3"><div role="radiogroup" aria-label="Page view" data-testid="markdown-view-toggle" class="inline-flex items-center gap-0.5 rounded-lg p-1 bg-(--color-surface-secondary)"><button class="inline-flex items-center justify-center gap-2 font-medium motion-safe:transition motion-safe:duration-(--button-hover-duration) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&>svg]:shrink-0 text-(--color-fg) not-disabled:hover:bg-(--button-hover-quiet-bg) not-disabled:hover:text-(--button-hover-quiet-fg) not-disabled:hover:opacity-(--button-hover-opacity) not-disabled:hover:transform-(--button-hover-transform) not-disabled:hover:shadow-(--button-hover-shadow) not-disabled:active:bg-gray-200 not-disabled:active:text-(--color-fg) rounded-control px-control-x h-(--control-height-thin) text-caption leading-none rounded-md px-3 text-body-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 min-w-(--control-height-thin) min-h-(--control-height-big) bg-(--color-bg) text-(--color-fg) shadow-sm" type="button" role="radio" aria-checked="true" aria-label="Rendered" tabindex="0" data-testid="markdown-view-toggle-rendered">Rendered</button><button class="inline-flex items-center justify-center gap-2 font-medium motion-safe:transition motion-safe:duration-(--button-hover-duration) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&>svg]:shrink-0 text-(--color-fg) not-disabled:hover:bg-(--button-hover-quiet-bg) not-disabled:hover:text-(--button-hover-quiet-fg) not-disabled:hover:opacity-(--button-hover-opacity) not-disabled:hover:transform-(--button-hover-transform) not-disabled:hover:shadow-(--button-hover-shadow) not-disabled:active:bg-gray-200 not-disabled:active:text-(--color-fg) rounded-control px-control-x h-(--control-height-thin) text-caption leading-none rounded-md px-3 text-body-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-accent) focus-visible:ring-offset-1 min-w-(--control-height-thin) min-h-(--control-height-big) text-(--color-text-muted) hover:text-(--color-fg)" type="button" role="radio" aria-checked="false" aria-label="Markdown" tabindex="-1" data-testid="markdown-view-toggle-markdown">Markdown</button></div></div><div role="status" aria-live="polite" aria-atomic="true" class="sr-only" data-testid="markdown-view-toggle-status">Showing Rendered view</div><div data-testid="markdown-view-rendered"><article data-testid="mdx-body"><div data-testid="mdx-remote" data-source=""></div></article></div></div></div></main>"`,
|
|
83
83
|
);
|
|
84
84
|
});
|
|
85
85
|
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client"; // Reads sessionStorage (a browser API) once on mount — a server page cannot.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AccountInviteLink — the /thanks page's "Track this in your account" link
|
|
5
|
+
* (#8771 D6). The magnet walk writes one `sessionStorage` item,
|
|
6
|
+
* `ailk:account-invite`, before it navigates here; this shows the link only
|
|
7
|
+
* for the thank-you page that walk was headed to, and only if the stored href
|
|
8
|
+
* is a same-site sign-in path. It reads the item once and removes it, so the
|
|
9
|
+
* email in the href does not stay in the tab. A refresh shows no link (the
|
|
10
|
+
* invite email still carries it).
|
|
11
|
+
*
|
|
12
|
+
* Base tree: it imports nothing from `flows/**`, so a build without the walk
|
|
13
|
+
* still compiles this page.
|
|
14
|
+
*/
|
|
15
|
+
import { Button, Container, Link } from "@working-theory/ui";
|
|
16
|
+
import type { ReactElement } from "react";
|
|
17
|
+
import { useEffect, useState } from "react";
|
|
18
|
+
|
|
19
|
+
/** Must equal `ACCOUNT_INVITE_STORAGE_KEY` in the walk's `FlowStepperClient`. */
|
|
20
|
+
const STORAGE_KEY = "ailk:account-invite";
|
|
21
|
+
/** A reserved name that never resolves: only used to test an href stays on-site. */
|
|
22
|
+
const PLACEHOLDER_ORIGIN = "https://placeholder.invalid";
|
|
23
|
+
const HUB_SIGN_IN_PATH = "/api/hub-session/sign-in";
|
|
24
|
+
|
|
25
|
+
interface Props {
|
|
26
|
+
/** The route's `[slug]` — the hand-off must have been written for this page. */
|
|
27
|
+
thanksSlug: string;
|
|
28
|
+
/** `contact.trackInAccount`, read on the server. */
|
|
29
|
+
label: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The stored href when it is a same-site sign-in path, else `null`. */
|
|
33
|
+
function safeSignInHref(raw: unknown, thanks: unknown, thanksSlug: string): string | null {
|
|
34
|
+
if (typeof raw !== "string" || thanks !== thanksSlug) return null;
|
|
35
|
+
let url: URL;
|
|
36
|
+
try {
|
|
37
|
+
url = new URL(raw, PLACEHOLDER_ORIGIN);
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (url.origin !== PLACEHOLDER_ORIGIN) return null;
|
|
42
|
+
if (url.pathname !== HUB_SIGN_IN_PATH && !url.pathname.endsWith("/sign-in")) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return raw;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Read the hand-off once, remove it, and answer the link to show (or `null`). */
|
|
49
|
+
function takeHandOff(thanksSlug: string): string | null {
|
|
50
|
+
try {
|
|
51
|
+
const stored = window.sessionStorage.getItem(STORAGE_KEY);
|
|
52
|
+
if (stored === null) return null;
|
|
53
|
+
window.sessionStorage.removeItem(STORAGE_KEY);
|
|
54
|
+
const parsed: unknown = JSON.parse(stored);
|
|
55
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
56
|
+
const { thanks, href } = parsed as { thanks?: unknown; href?: unknown };
|
|
57
|
+
return safeSignInHref(href, thanks, thanksSlug);
|
|
58
|
+
} catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function AccountInviteLink({ thanksSlug, label }: Props): ReactElement | null {
|
|
64
|
+
const [href, setHref] = useState<string | null>(null);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
// Only ever sets the link: React's development double-mount runs this
|
|
68
|
+
// twice, and the second run finds the item already removed.
|
|
69
|
+
const found = takeHandOff(thanksSlug);
|
|
70
|
+
if (found !== null) setHref(found);
|
|
71
|
+
}, [thanksSlug]);
|
|
72
|
+
|
|
73
|
+
if (href === null) return null;
|
|
74
|
+
return (
|
|
75
|
+
// Session Replay records the DOM, so the link (it carries the email) is
|
|
76
|
+
// blocked from it; `Link` does not forward an undeclared data-* attribute.
|
|
77
|
+
// The page shell sets no gutters, so the link sits in its own Container,
|
|
78
|
+
// lined up with the thank-you content above it.
|
|
79
|
+
<Container className="pb-section">
|
|
80
|
+
<div data-sentry-block>
|
|
81
|
+
<Button asChild variant="outline" className="min-h-11">
|
|
82
|
+
<Link href={href} variant="bare" data-testid="thanks-account-invite">
|
|
83
|
+
{label}
|
|
84
|
+
</Link>
|
|
85
|
+
</Button>
|
|
86
|
+
</div>
|
|
87
|
+
</Container>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #8771 AC-5 — /thanks shows only its own hand-off: the walk's sessionStorage
|
|
3
|
+
* item, for this page's slug, when its href is a same-site sign-in path.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
|
|
8
|
+
import { render, screen } from "@testing-library/react";
|
|
9
|
+
import React, { StrictMode } from "react";
|
|
10
|
+
|
|
11
|
+
import { AccountInviteLink } from "../AccountInviteLink";
|
|
12
|
+
|
|
13
|
+
const KEY = "ailk:account-invite";
|
|
14
|
+
const LABEL = "Track this in your account";
|
|
15
|
+
const SITE_HREF = "/sign-in?next=%2Faccount&email=jane%40example.com";
|
|
16
|
+
const HUB_HREF = "/api/hub-session/sign-in?next=%2Faccount&email=x%40y.example";
|
|
17
|
+
const WALK = join(__dirname, "..", "..", "..", "flows", "[slug]", "FlowStepperClient.tsx");
|
|
18
|
+
// A Free scaffold ships no magnet walk, and the scaffold matrix runs this suite
|
|
19
|
+
// inside one (#8799), so the key check skips where the walk does not exist.
|
|
20
|
+
const itWithWalk = existsSync(WALK) ? it : it.skip;
|
|
21
|
+
|
|
22
|
+
function store(value: unknown): void {
|
|
23
|
+
window.sessionStorage.setItem(KEY, typeof value === "string" ? value : JSON.stringify(value));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function show(slug = "flow-thanks") {
|
|
27
|
+
return render(<AccountInviteLink thanksSlug={slug} label={LABEL} />);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
beforeEach(() => window.sessionStorage.clear());
|
|
31
|
+
|
|
32
|
+
describe("AccountInviteLink", () => {
|
|
33
|
+
it("renders the stored link for its own slug, blocked from Replay, and removes the item", () => {
|
|
34
|
+
store({ thanks: "flow-thanks", href: SITE_HREF });
|
|
35
|
+
|
|
36
|
+
show();
|
|
37
|
+
|
|
38
|
+
const link = screen.getByTestId("thanks-account-invite");
|
|
39
|
+
expect(link).toHaveAttribute("href", SITE_HREF);
|
|
40
|
+
expect(link).toHaveTextContent(LABEL);
|
|
41
|
+
expect(link.closest("[data-sentry-block]")).not.toBeNull();
|
|
42
|
+
expect(window.sessionStorage.getItem(KEY)).toBeNull();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("renders a hub spoke's sign-in path under the matching slug", () => {
|
|
46
|
+
store({ thanks: "flow-thanks", href: HUB_HREF });
|
|
47
|
+
show();
|
|
48
|
+
expect(screen.getByTestId("thanks-account-invite")).toHaveAttribute("href", HUB_HREF);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("renders a locale-prefixed site sign-in path", () => {
|
|
52
|
+
store({ thanks: "flow-thanks", href: "/fr/sign-in?email=a%40b.example" });
|
|
53
|
+
show();
|
|
54
|
+
expect(screen.getByTestId("thanks-account-invite")).toBeInTheDocument();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it.each([
|
|
58
|
+
["another slug", { thanks: "other", href: SITE_HREF }, "flow-thanks"],
|
|
59
|
+
["an off-site href", { thanks: "flow-thanks", href: "https://evil.example/sign-in" }, "flow-thanks"],
|
|
60
|
+
["a protocol-relative href", { thanks: "flow-thanks", href: "//evil.example/sign-in" }, "flow-thanks"],
|
|
61
|
+
["a non-sign-in path", { thanks: "flow-thanks", href: "/account" }, "flow-thanks"],
|
|
62
|
+
["a hub href under another thanks", { thanks: "flow-thanks-qualified", href: HUB_HREF }, "flow-thanks"],
|
|
63
|
+
["a value that is not JSON", "not json", "flow-thanks"],
|
|
64
|
+
["a JSON null", "null", "flow-thanks"],
|
|
65
|
+
])("renders nothing for %s", (_name, value, slug) => {
|
|
66
|
+
store(value);
|
|
67
|
+
show(slug);
|
|
68
|
+
expect(screen.queryByTestId("thanks-account-invite")).toBeNull();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("renders nothing when sessionStorage throws", () => {
|
|
72
|
+
const spy = jest.spyOn(Storage.prototype, "getItem").mockImplementation(() => {
|
|
73
|
+
throw new Error("denied");
|
|
74
|
+
});
|
|
75
|
+
show();
|
|
76
|
+
expect(screen.queryByTestId("thanks-account-invite")).toBeNull();
|
|
77
|
+
spy.mockRestore();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("shows the link once: a fresh mount after it (a refresh) renders nothing", () => {
|
|
81
|
+
store({ thanks: "flow-thanks", href: SITE_HREF });
|
|
82
|
+
const first = show();
|
|
83
|
+
expect(screen.getByTestId("thanks-account-invite")).toBeInTheDocument();
|
|
84
|
+
first.unmount();
|
|
85
|
+
|
|
86
|
+
show();
|
|
87
|
+
expect(screen.queryByTestId("thanks-account-invite")).toBeNull();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("keeps the link under React.StrictMode's double effect", () => {
|
|
91
|
+
store({ thanks: "flow-thanks", href: SITE_HREF });
|
|
92
|
+
render(
|
|
93
|
+
<StrictMode>
|
|
94
|
+
<AccountInviteLink thanksSlug="flow-thanks" label={LABEL} />
|
|
95
|
+
</StrictMode>,
|
|
96
|
+
);
|
|
97
|
+
expect(screen.getByTestId("thanks-account-invite")).toBeInTheDocument();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
itWithWalk("reads the same storage key the walk writes (the two constants are tied only by this test)", () => {
|
|
101
|
+
const walk = readFileSync(WALK, "utf8");
|
|
102
|
+
expect(walk).toContain(`ACCOUNT_INVITE_STORAGE_KEY = "${KEY}"`);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -37,6 +37,23 @@ jest.mock("@working-theory/ui", () => ({
|
|
|
37
37
|
}),
|
|
38
38
|
}));
|
|
39
39
|
|
|
40
|
+
// #8771 D6 — the page reads the link label on the server and renders the client
|
|
41
|
+
// component that owns the hand-off; this file asserts only that wiring.
|
|
42
|
+
jest.mock("next-intl/server", () => ({
|
|
43
|
+
getTranslations: jest.fn().mockResolvedValue((key: string) => `label:${key}`),
|
|
44
|
+
}));
|
|
45
|
+
// eslint-disable-next-line no-restricted-syntax -- the page's wiring is the unit under test; the component has its own suite
|
|
46
|
+
jest.mock("../AccountInviteLink", () => ({
|
|
47
|
+
AccountInviteLink: ({ thanksSlug, label }: { thanksSlug: string; label: string }) =>
|
|
48
|
+
React.createElement("div", {
|
|
49
|
+
"data-testid": "account-invite-link",
|
|
50
|
+
"data-slug": thanksSlug,
|
|
51
|
+
"data-label": label,
|
|
52
|
+
}),
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
import { readFileSync } from "node:fs";
|
|
56
|
+
import { join } from "node:path";
|
|
40
57
|
import { notFound } from "next/navigation";
|
|
41
58
|
import ThankYouSlugPage from "../page";
|
|
42
59
|
|
|
@@ -93,4 +110,25 @@ describe("ThankYouSlugPage — detail route", () => {
|
|
|
93
110
|
).rejects.toThrow("NEXT_NOT_FOUND");
|
|
94
111
|
expect(mockNotFound).toHaveBeenCalled();
|
|
95
112
|
});
|
|
113
|
+
|
|
114
|
+
it("renders AccountInviteLink with the route's slug and the contact label (#8771)", async () => {
|
|
115
|
+
const getMdxSource = jest.fn().mockResolvedValue(makeThankYouSource("flow-thanks"));
|
|
116
|
+
|
|
117
|
+
const element = await ThankYouSlugPage({
|
|
118
|
+
params: Promise.resolve({ locale: "en", slug: "flow-thanks" }),
|
|
119
|
+
getMdxSource,
|
|
120
|
+
});
|
|
121
|
+
const { container } = render(element);
|
|
122
|
+
|
|
123
|
+
const link = container.querySelector('[data-testid="account-invite-link"]');
|
|
124
|
+
// Inside the page's own <main>, not after it (#8771 design review).
|
|
125
|
+
expect(link?.closest("main")).not.toBeNull();
|
|
126
|
+
expect(link).toHaveAttribute("data-slug", "flow-thanks");
|
|
127
|
+
expect(link).toHaveAttribute("data-label", "label:trackInAccount");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("stays a server page: the module has no client directive (#8771)", () => {
|
|
131
|
+
const source = readFileSync(join(__dirname, "..", "page.tsx"), "utf8");
|
|
132
|
+
expect(source).not.toMatch(/["']use client["']/);
|
|
133
|
+
});
|
|
96
134
|
});
|
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
import type { getMdxSource as defaultGetMdxSource } from "@working-theory/page-renderer";
|
|
8
8
|
import { renderPage, renderPageMetadata } from "@working-theory/page-renderer";
|
|
9
9
|
import type { Metadata } from "next";
|
|
10
|
+
import { getTranslations } from "next-intl/server";
|
|
10
11
|
import type { ReactElement } from "react";
|
|
11
12
|
|
|
13
|
+
import { AccountInviteLink } from "./AccountInviteLink";
|
|
14
|
+
|
|
12
15
|
interface Props {
|
|
13
16
|
params: Promise<{ locale: string; slug: string }>;
|
|
14
17
|
getMdxSource?: typeof defaultGetMdxSource;
|
|
@@ -26,11 +29,17 @@ export default async function Page({
|
|
|
26
29
|
getMdxSource,
|
|
27
30
|
}: Props): Promise<ReactElement> {
|
|
28
31
|
const { locale, slug } = await params;
|
|
32
|
+
// #8771 D6 — the magnet walk's "Track this in your account" hand-off. The
|
|
33
|
+
// page stays a server page; the client component decides if it has a link.
|
|
34
|
+
// It renders through `trailing`, inside the page's own <main>, so it keeps
|
|
35
|
+
// the page's landmark and layout rather than sitting after `</main>`.
|
|
36
|
+
const t = await getTranslations({ locale, namespace: "contact" });
|
|
29
37
|
return renderPage({
|
|
30
38
|
type: "ThankYouPage",
|
|
31
39
|
slug,
|
|
32
40
|
locale,
|
|
33
41
|
populatedDescriptionTestId: "thank-you-description",
|
|
42
|
+
trailing: <AccountInviteLink thanksSlug={slug} label={t("trackInAccount")} />,
|
|
34
43
|
...(getMdxSource !== undefined && { getMdxSource }),
|
|
35
44
|
});
|
|
36
45
|
}
|
package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx
CHANGED
|
@@ -139,6 +139,19 @@ for (const specifier of ["next/link", "next/image", "next/script"]) {
|
|
|
139
139
|
}
|
|
140
140
|
// `next-intl` is path-independent: jest.config.cjs maps every copy onto one stub.
|
|
141
141
|
jest.doMock("next-intl", () => flight.createClientModuleProxy("next-intl"));
|
|
142
|
+
// #8847 D12 — the page reads the newsletter magnet through
|
|
143
|
+
// `lib/in-page-magnet`, whose module graph reaches `contact.actions`' import
|
|
144
|
+
// of `next/navigation`. Next serves server code that entry's react-server
|
|
145
|
+
// build; under jest it is the client build, which needs a React context, so
|
|
146
|
+
// it is stubbed as `signed-in-nav-rsc-boundary.test.tsx` stubs it.
|
|
147
|
+
jest.doMock("next/navigation", () => ({
|
|
148
|
+
redirect: () => {
|
|
149
|
+
throw new Error("redirect");
|
|
150
|
+
},
|
|
151
|
+
notFound: () => {
|
|
152
|
+
throw new Error("NEXT_NOT_FOUND");
|
|
153
|
+
},
|
|
154
|
+
}));
|
|
142
155
|
|
|
143
156
|
// ── Render ───────────────────────────────────────────────────────────────────
|
|
144
157
|
|
|
@@ -200,6 +213,10 @@ describe("/[locale]/unsubscribe crosses the RSC → client boundary cleanly", ()
|
|
|
200
213
|
const { errors, payload } = await renderPageToFlight("tok_1");
|
|
201
214
|
expect(errors).toEqual([]);
|
|
202
215
|
expect(payload).toContain("unsubscribe-page");
|
|
216
|
+
// #8847 D12 — the island gets the token and the magnet's copy as strings.
|
|
217
|
+
const props = /"token":"tok_1"[^}]*}/.exec(payload)?.[0] ?? "";
|
|
218
|
+
expect(props).toContain('"cta":"Unsubscribe"');
|
|
219
|
+
expect(props).toContain('"doneHeadline":"You\'re unsubscribed."');
|
|
203
220
|
});
|
|
204
221
|
|
|
205
222
|
it("serializes with no token", async () => {
|
|
@@ -40,9 +40,11 @@ jest.mock("next-intl", () => ({
|
|
|
40
40
|
}));
|
|
41
41
|
|
|
42
42
|
const mockUnsubscribe = jest.fn();
|
|
43
|
+
const mockFlowsGet = jest.fn();
|
|
43
44
|
jest.mock("@working-theory/api-client", () => ({
|
|
44
45
|
__esModule: true,
|
|
45
46
|
consent: { unsubscribe: (...args: unknown[]) => mockUnsubscribe(...args) },
|
|
47
|
+
flows: { get: (...args: unknown[]) => mockFlowsGet(...args) },
|
|
46
48
|
visitorForwardHeaders: () => undefined,
|
|
47
49
|
}));
|
|
48
50
|
|
|
@@ -56,8 +58,16 @@ import Page, { generateMetadata } from "../page";
|
|
|
56
58
|
const ok = <T,>(body: T) => ({ ok: true, body });
|
|
57
59
|
const refusal = (status: number) => ({ ok: false, status, body: null });
|
|
58
60
|
|
|
61
|
+
// #8847 D12 — the page's newsletter-magnet read is shared for a few seconds
|
|
62
|
+
// per module instance; each test starts an hour later so none sees another's.
|
|
63
|
+
let clock = 1_900_000_000_000;
|
|
64
|
+
jest.spyOn(Date, "now").mockImplementation(() => clock);
|
|
65
|
+
|
|
59
66
|
beforeEach(() => {
|
|
67
|
+
clock += 60 * 60 * 1000;
|
|
60
68
|
mockUnsubscribe.mockReset();
|
|
69
|
+
// The hub unreadable: the seeded newsletterFlowConfig's unsubscribe copy.
|
|
70
|
+
mockFlowsGet.mockReset().mockRejectedValue(new Error("hub down"));
|
|
61
71
|
});
|
|
62
72
|
|
|
63
73
|
async function renderPage(token: string | undefined): Promise<void> {
|
|
@@ -86,7 +96,7 @@ describe("the page performs no write on GET", () => {
|
|
|
86
96
|
expect(mockUnsubscribe).not.toHaveBeenCalled();
|
|
87
97
|
expect(screen.getByTestId("unsubscribe-page")).toBeInTheDocument();
|
|
88
98
|
expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("Unsubscribe");
|
|
89
|
-
expect(screen.getByText("Stop
|
|
99
|
+
expect(screen.getByText("Stop getting the newsletter by email?")).toBeInTheDocument();
|
|
90
100
|
});
|
|
91
101
|
});
|
|
92
102
|
|
|
@@ -100,7 +110,7 @@ describe("with no token", () => {
|
|
|
100
110
|
});
|
|
101
111
|
|
|
102
112
|
describe("clicking Unsubscribe", () => {
|
|
103
|
-
it("a changed answer shows the done
|
|
113
|
+
it("a changed answer shows the magnet's done message (#8847 D12)", async () => {
|
|
104
114
|
mockUnsubscribe.mockResolvedValue(
|
|
105
115
|
ok({ purpose: { id: "marketing_email", description: "product news and offers" }, changed: true }),
|
|
106
116
|
);
|
|
@@ -108,7 +118,7 @@ describe("clicking Unsubscribe", () => {
|
|
|
108
118
|
await userEvent.click(screen.getByTestId("unsubscribe-button"));
|
|
109
119
|
expect(mockUnsubscribe).toHaveBeenCalledWith({ token: "tok_1" });
|
|
110
120
|
expect(await screen.findByTestId("unsubscribe-done")).toHaveTextContent(
|
|
111
|
-
"You're unsubscribed
|
|
121
|
+
"You're unsubscribed.You won't get the newsletter any more.",
|
|
112
122
|
);
|
|
113
123
|
});
|
|
114
124
|
|
|
@@ -156,3 +166,52 @@ describe("clicking Unsubscribe", () => {
|
|
|
156
166
|
expect(await screen.findByTestId("unsubscribe-unavailable")).toBeInTheDocument();
|
|
157
167
|
});
|
|
158
168
|
});
|
|
169
|
+
|
|
170
|
+
describe("the copy comes from the newsletter magnet (#8847 D12, AC-7)", () => {
|
|
171
|
+
const unsubscribe = {
|
|
172
|
+
title: { en: "Leave" },
|
|
173
|
+
body: { en: "Sure?" },
|
|
174
|
+
cta: { en: "Leave now" },
|
|
175
|
+
done: { headline: { en: "Gone." } },
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
beforeEach(() => {
|
|
179
|
+
const { newsletterFlowConfig } = jest.requireActual("@working-theory/validation") as {
|
|
180
|
+
newsletterFlowConfig: Record<string, unknown>;
|
|
181
|
+
};
|
|
182
|
+
const { completionEmail: _omitted, ...body } = newsletterFlowConfig;
|
|
183
|
+
mockFlowsGet.mockReset().mockResolvedValue({ ok: true, status: 200, body: { ...body, unsubscribe } });
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("the title, line and button are the served block's, and so is the done message", async () => {
|
|
187
|
+
mockUnsubscribe.mockResolvedValue(
|
|
188
|
+
ok({ purpose: { id: "newsletter", description: "This site's newsletter by email" }, changed: true }),
|
|
189
|
+
);
|
|
190
|
+
await renderPage("tok_1");
|
|
191
|
+
expect(mockFlowsGet).toHaveBeenCalledWith("newsletter");
|
|
192
|
+
expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("Leave");
|
|
193
|
+
expect(screen.getByText("Sure?")).toBeInTheDocument();
|
|
194
|
+
expect(screen.getByTestId("unsubscribe-button")).toHaveTextContent("Leave now");
|
|
195
|
+
await userEvent.click(screen.getByTestId("unsubscribe-button"));
|
|
196
|
+
expect(await screen.findByTestId("unsubscribe-done")).toHaveTextContent("Gone.");
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("generateMetadata's title is the served block's", async () => {
|
|
200
|
+
const meta = await generateMetadata({
|
|
201
|
+
params: Promise.resolve({ locale: "en" }),
|
|
202
|
+
searchParams: Promise.resolve({}),
|
|
203
|
+
});
|
|
204
|
+
expect(meta.title).toBe("Leave");
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("already still shows the catalog's line", async () => {
|
|
208
|
+
mockUnsubscribe.mockResolvedValue(
|
|
209
|
+
ok({ purpose: { id: "newsletter", description: "This site's newsletter by email" }, changed: false }),
|
|
210
|
+
);
|
|
211
|
+
await renderPage("tok_1");
|
|
212
|
+
await userEvent.click(screen.getByTestId("unsubscribe-button"));
|
|
213
|
+
expect(await screen.findByTestId("unsubscribe-already")).toHaveTextContent(
|
|
214
|
+
"You were already unsubscribed.",
|
|
215
|
+
);
|
|
216
|
+
});
|
|
217
|
+
});
|