create-ailk 0.37.1 → 0.39.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/README.md +129 -0
- package/component-catalog.json +44 -6
- package/component-catalog.md +6 -5
- package/dist/add-module.js +16 -1
- package/dist/add-route.d.ts +2 -2
- package/dist/add-route.js +19 -12
- package/dist/cli.js +52 -0
- package/dist/declined-routes.d.ts +13 -0
- package/dist/declined-routes.js +74 -0
- package/dist/derive-architecture.d.ts +0 -6
- package/dist/derive-architecture.js +12 -16
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/language-import.d.ts +93 -0
- package/dist/language-import.js +270 -43
- package/dist/lib/import-mdx.js +1 -1
- package/dist/lib/scaffold-render-sweep.d.ts +6 -3
- package/dist/lib/scaffold-render-sweep.js +8 -4
- package/dist/migrate-content.d.ts +6 -2
- package/dist/migrate-content.js +62 -5
- package/dist/module-architecture.js +139 -103
- package/dist/paid-sections.d.ts +13 -0
- package/dist/paid-sections.js +35 -5
- package/dist/programmatic.js +6 -16
- package/dist/remove-module.js +73 -2
- package/dist/routes.d.ts +130 -0
- package/dist/routes.js +954 -0
- package/dist/site-manifest.js +6 -4
- package/dist/site-roster.d.ts +11 -2
- package/dist/site-roster.js +63 -21
- package/dist/spoke-checkout.d.ts +28 -27
- package/dist/spoke-checkout.js +71 -102
- package/dist/surfaces.d.ts +26 -0
- package/dist/surfaces.js +105 -293
- package/dist/sync-routes.d.ts +14 -1
- package/dist/sync-routes.js +108 -10
- package/dist/template-record.js +3 -1
- package/dist/topology.d.ts +26 -1
- package/dist/topology.js +273 -7
- package/dist/update.d.ts +17 -2
- package/dist/update.js +480 -77
- package/package.json +3 -3
- package/templates/README.md +1 -1
- package/templates/apps/mcp/CLAUDE.md +5 -3
- package/templates/apps/web/CLAUDE.md +87 -23
- package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +5 -1
- package/templates/apps/web/__tests__/__mocks__/next-intl.ts +5 -1
- package/templates/apps/web/__tests__/auth/seam.test.ts +34 -0
- package/templates/apps/web/account.config.tsx +100 -0
- 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 +2 -2
- package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +1 -1
- package/templates/apps/web/app/[locale]/layout.tsx +46 -29
- package/templates/apps/web/app/apple-icon.tsx +72 -0
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +22 -12
- package/templates/apps/web/app/og/__tests__/__snapshots__/card.test.tsx.snap +3 -0
- package/templates/apps/web/app/og/__tests__/card.test.tsx +129 -0
- package/templates/apps/web/app/og/__tests__/route.test.ts +3 -4
- package/templates/apps/web/app/og/route.tsx +155 -72
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +12 -0
- package/templates/apps/web/auth.config.tsx +107 -0
- package/templates/apps/web/auth.ts +2 -1
- package/templates/apps/web/i18n/request.ts +51 -1
- package/templates/apps/web/jest.config.cjs +17 -1
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +73 -0
- package/templates/apps/web/lib/__tests__/nav-label-keys.test.ts +14 -0
- package/templates/apps/web/lib/__tests__/profile-back-link.test.ts +148 -61
- package/templates/apps/web/lib/__tests__/served-pages.test.ts +77 -0
- package/templates/apps/web/lib/__tests__/server-api.test.ts +37 -5
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +26 -13
- package/templates/apps/web/lib/listings.tsx +2 -2
- package/templates/apps/web/lib/nav-label-keys.ts +16 -2
- package/templates/apps/web/lib/paid-section-contracts.ts +35 -6
- package/templates/apps/web/lib/paid-sections.generated.ts +8 -0
- package/templates/apps/web/lib/profile-back-link.ts +105 -32
- package/templates/apps/web/lib/served-pages.ts +95 -0
- package/templates/apps/web/lib/server-api.ts +1 -1
- package/templates/apps/web/lib/site-brand.tsx +3 -5
- package/templates/apps/web/lib/topology.generated.ts +5 -0
- package/templates/apps/web/messages/en.json +8 -836
- package/templates/apps/web/middleware.ts +15 -26
- package/templates/apps/web/next.config.mjs +35 -0
- package/templates/apps/web/package.json +2 -0
- package/templates/apps/web/types/messages.d.ts +6 -1
- package/templates/customizations.yaml +9 -0
- package/templates/package.json +3 -1
- package/templates/tools/lint-architecture.ts +164 -11
- package/versions.json +49 -47
- 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/__tests__/account-frame-sign-out.test.tsx +0 -175
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/agreements-prompt.test.tsx +0 -301
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +0 -515
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +0 -883
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +0 -758
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +0 -264
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +0 -167
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +0 -730
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +0 -355
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +0 -97
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +0 -375
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/onboarding.test.tsx +0 -323
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +0 -1208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +0 -418
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +0 -462
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +0 -63
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/settings.test.tsx +0 -93
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/support.test.tsx +0 -208
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +0 -340
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +0 -353
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +0 -57
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-actions.ts +0 -58
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-gate.ts +0 -61
- package/templates/apps/web/app/[locale]/(authed)/account/agreements-prompt.tsx +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +0 -161
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +0 -426
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +0 -76
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +0 -139
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +0 -406
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/pay-form.tsx +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/review-form.tsx +0 -172
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +0 -190
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +0 -333
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +0 -936
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/pay.test.tsx +0 -193
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/review.test.tsx +0 -476
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-actions.ts +0 -184
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +0 -197
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +0 -182
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +0 -99
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +0 -123
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +0 -424
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +0 -303
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +0 -274
- package/templates/apps/web/app/[locale]/(authed)/account/error-row.tsx +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/for-you-labels.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +0 -65
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +0 -36
- package/templates/apps/web/app/[locale]/(authed)/account/general/billing-anchor.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +0 -149
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/general/deletion-request.tsx +0 -132
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +0 -218
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +0 -122
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +0 -73
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +0 -107
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +0 -87
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +0 -119
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/__tests__/route.test.ts +0 -215
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +0 -80
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +0 -43
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +0 -125
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +0 -88
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +0 -31
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +0 -35
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +0 -266
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +0 -12
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +0 -154
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +0 -152
- package/templates/apps/web/app/[locale]/(authed)/account/new-actions.ts +0 -219
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +0 -365
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +0 -86
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +0 -143
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/actions.ts +0 -120
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/onboarding-form.tsx +0 -322
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +0 -126
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +0 -306
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +0 -173
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +0 -103
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +0 -102
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +0 -240
- package/templates/apps/web/app/[locale]/(authed)/account/profile-actions.ts +0 -116
- package/templates/apps/web/app/[locale]/(authed)/account/retry-button.tsx +0 -27
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +0 -258
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +0 -131
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +0 -130
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +0 -92
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -24
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +0 -121
- package/templates/apps/web/app/[locale]/(authed)/account/sign-in-method.ts +0 -37
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/(authed)/account/support/support-form.tsx +0 -98
- package/templates/apps/web/app/[locale]/(authed)/account/support-actions.ts +0 -100
- package/templates/apps/web/app/[locale]/checkout/__tests__/pages.test.tsx +0 -139
- package/templates/apps/web/app/[locale]/checkout/__tests__/thank-you-account.test.tsx +0 -146
- package/templates/apps/web/app/[locale]/checkout/thank-you/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/checkout/unavailable/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +0 -614
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.count.test.tsx +0 -43
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +0 -214
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx +0 -197
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +0 -286
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +0 -520
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +0 -376
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.thanks-by-tier.test.tsx +0 -306
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts +0 -69
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/flow.actions.test.ts +0 -398
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +0 -704
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +0 -173
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/two-route-tool.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/verify.test.tsx +0 -249
- package/templates/apps/web/app/[locale]/flows/[slug]/account-invite.actions.ts +0 -35
- package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +0 -92
- package/templates/apps/web/app/[locale]/flows/[slug]/flow.actions.ts +0 -177
- package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +0 -472
- package/templates/apps/web/app/[locale]/flows/[slug]/page.tsx +0 -48
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +0 -100
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +0 -99
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +0 -820
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +0 -203
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +0 -194
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +0 -284
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +0 -302
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/landing.test.tsx +0 -293
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +0 -485
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +0 -231
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/checkout-seam.ts +0 -74
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +0 -36
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +0 -420
- package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +0 -85
- package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +0 -91
- package/templates/apps/web/app/[locale]/flows/[slug]/start/page.tsx +0 -32
- package/templates/apps/web/app/[locale]/flows/[slug]/verify/page.tsx +0 -153
- package/templates/apps/web/app/[locale]/flows/[slug]/verify.actions.ts +0 -151
- package/templates/apps/web/app/[locale]/meet/confirmed/BookingHandOff.tsx +0 -128
- package/templates/apps/web/app/[locale]/meet/confirmed/__tests__/BookingHandOff.test.tsx +0 -126
- package/templates/apps/web/app/[locale]/purchase/__tests__/cancel.test.tsx +0 -162
- package/templates/apps/web/app/[locale]/purchase/__tests__/module-scope.test.ts +0 -68
- package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +0 -411
- package/templates/apps/web/app/[locale]/purchase/cancel/page.tsx +0 -115
- package/templates/apps/web/app/[locale]/purchase/success/page.tsx +0 -348
- 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__/account-config.test.ts +0 -704
- package/templates/apps/web/lib/__tests__/auth-routes.test.ts +0 -140
- package/templates/apps/web/lib/account-config.ts +0 -678
- package/templates/apps/web/lib/auth-routes.ts +0 -125
- package/templates/apps/web/lib/checkout-config.ts +0 -16
- 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/next-path.ts +0 -35
- package/templates/apps/web/src/lib/__tests__/commerce-sections.test.ts +0 -57
- package/templates/apps/web/src/lib/commerce-sections.ts +0 -55
package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/account-invite.actions.test.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// oss: false
|
|
2
|
-
/**
|
|
3
|
-
* #8771 AC-4 (the action) — accountInviteLinkAction builds #8757's link on the
|
|
4
|
-
* server and answers null when it cannot.
|
|
5
|
-
*/
|
|
6
|
-
import { readFileSync } from "node:fs";
|
|
7
|
-
import { join } from "node:path";
|
|
8
|
-
|
|
9
|
-
const mockGetLocale = jest.fn();
|
|
10
|
-
jest.mock("next-intl/server", () => ({
|
|
11
|
-
getLocale: (...args: unknown[]) => mockGetLocale(...args),
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
const mockInviteHref = jest.fn();
|
|
15
|
-
// eslint-disable-next-line no-restricted-syntax -- accountInviteHref reads the generated topology (build output); this file asserts the action's own decision
|
|
16
|
-
jest.mock("../../../../../lib/account-invite", () => ({
|
|
17
|
-
accountInviteHref: (...args: unknown[]) => mockInviteHref(...args),
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
|
-
import { accountInviteLinkAction } from "../account-invite.actions";
|
|
21
|
-
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
jest.clearAllMocks();
|
|
24
|
-
mockGetLocale.mockResolvedValue("fr");
|
|
25
|
-
mockInviteHref.mockImplementation(
|
|
26
|
-
(locale: string, email: string) => `/${locale}/sign-in?email=${email}`,
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe("accountInviteLinkAction", () => {
|
|
31
|
-
it("returns what accountInviteHref returns for the request's locale", async () => {
|
|
32
|
-
await expect(accountInviteLinkAction("jane@example.com")).resolves.toBe(
|
|
33
|
-
"/fr/sign-in?email=jane@example.com",
|
|
34
|
-
);
|
|
35
|
-
expect(mockInviteHref).toHaveBeenCalledWith("fr", "jane@example.com");
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it.each(["nope", "a\r\n@b.example", "a b@example.com"])(
|
|
39
|
-
"refuses %j",
|
|
40
|
-
async (email) => {
|
|
41
|
-
await expect(accountInviteLinkAction(email)).resolves.toBeNull();
|
|
42
|
-
expect(mockInviteHref).not.toHaveBeenCalled();
|
|
43
|
-
},
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
it("answers null when the locale cannot be read", async () => {
|
|
47
|
-
mockGetLocale.mockRejectedValue(new Error("no request scope"));
|
|
48
|
-
await expect(
|
|
49
|
-
accountInviteLinkAction("jane@example.com"),
|
|
50
|
-
).resolves.toBeNull();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("answers null for a site with no sign-in", async () => {
|
|
54
|
-
mockInviteHref.mockReturnValue(null);
|
|
55
|
-
await expect(
|
|
56
|
-
accountInviteLinkAction("jane@example.com"),
|
|
57
|
-
).resolves.toBeNull();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("makes no API call, and carries the oss marker on its first line", () => {
|
|
61
|
-
const source = readFileSync(
|
|
62
|
-
join(__dirname, "..", "account-invite.actions.ts"),
|
|
63
|
-
"utf8",
|
|
64
|
-
);
|
|
65
|
-
expect(source.split("\n")[0]).toBe("// oss: false");
|
|
66
|
-
expect(source).not.toMatch(/\bfetch\(/);
|
|
67
|
-
expect(source).not.toContain("@working-theory/api-client");
|
|
68
|
-
});
|
|
69
|
-
});
|
|
@@ -1,398 +0,0 @@
|
|
|
1
|
-
// oss: false
|
|
2
|
-
/**
|
|
3
|
-
* Tests for submitFlowStepAction Server Action (#3957 D8).
|
|
4
|
-
*
|
|
5
|
-
* Acceptance criteria verified here:
|
|
6
|
-
* - submitFlowStepAction(slug, validPayload) calls api-client flows.submitStep
|
|
7
|
-
* and returns { ok: true, response } passthrough.
|
|
8
|
-
* - invalid slug / invalid payload → { ok: false, kind: "invalid_input" }
|
|
9
|
-
* without calling api-client.
|
|
10
|
-
* - api-client 400 → kind "invalid_input"; 409 → kind "step_conflict";
|
|
11
|
-
* 429 → kind "rate_limited" carrying retryAfterSeconds; other statuses /
|
|
12
|
-
* a thrown error → kind "network".
|
|
13
|
-
* - #4730 — the visitor's `x-forwarded-for` (read from THIS action's own
|
|
14
|
-
* incoming request via next/headers) is forwarded on the outbound
|
|
15
|
-
* flows.submitStep call; absent entirely when no header is present.
|
|
16
|
-
* - Parity: submitFlowStepAction is paired with ailkSubmitFlowStep per ADR 0013.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { submitFlowStepAction } from "../flow.actions.js";
|
|
20
|
-
|
|
21
|
-
// #9255 — the write bot check's verdict. `checkBotId` reads Vercel's
|
|
22
|
-
// request context, which jest has none of, so every case decides it here.
|
|
23
|
-
const checkBotIdMock = jest.fn();
|
|
24
|
-
jest.mock("botid/server", () => ({
|
|
25
|
-
checkBotId: (...args: unknown[]) => checkBotIdMock(...args),
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
jest.mock("@working-theory/api-client", () => ({
|
|
29
|
-
flows: {
|
|
30
|
-
submitStep: jest.fn(),
|
|
31
|
-
},
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
// #4730 — default: no incoming headers to forward, matching every
|
|
35
|
-
// pre-existing test's 2-arg `flows.submitStep(slug, payload)` expectation
|
|
36
|
-
// byte-for-byte. Individual #4730 tests override with a real x-forwarded-for.
|
|
37
|
-
jest.mock("next/headers", () => ({
|
|
38
|
-
__esModule: true,
|
|
39
|
-
headers: jest.fn().mockResolvedValue({ get: () => null }),
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
import { flows } from "@working-theory/api-client";
|
|
43
|
-
import { headers } from "next/headers";
|
|
44
|
-
const mockSubmitStep = flows.submitStep as jest.Mock;
|
|
45
|
-
const mockHeaders = headers as jest.Mock;
|
|
46
|
-
|
|
47
|
-
afterEach(() => {
|
|
48
|
-
jest.clearAllMocks();
|
|
49
|
-
mockHeaders.mockResolvedValue({ get: () => null });
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const VALID_PAYLOAD = {
|
|
53
|
-
stepKey: "contact",
|
|
54
|
-
values: { email: "jane@example.com" },
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
describe("submitFlowStepAction — valid input", () => {
|
|
58
|
-
it("calls flows.submitStep and returns the response passthrough on success", async () => {
|
|
59
|
-
mockSubmitStep.mockResolvedValueOnce({
|
|
60
|
-
ok: true,
|
|
61
|
-
body: {
|
|
62
|
-
sessionId: "sess1",
|
|
63
|
-
landed: "contact",
|
|
64
|
-
nextStepKey: "budget",
|
|
65
|
-
completed: false,
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const result = await submitFlowStepAction("get-a-quote", VALID_PAYLOAD);
|
|
70
|
-
|
|
71
|
-
expect(mockSubmitStep).toHaveBeenCalledWith(
|
|
72
|
-
"get-a-quote",
|
|
73
|
-
expect.objectContaining(VALID_PAYLOAD),
|
|
74
|
-
);
|
|
75
|
-
expect(result).toEqual({
|
|
76
|
-
ok: true,
|
|
77
|
-
response: {
|
|
78
|
-
sessionId: "sess1",
|
|
79
|
-
landed: "contact",
|
|
80
|
-
nextStepKey: "budget",
|
|
81
|
-
completed: false,
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("threads sessionId and locale through to the api-client call", async () => {
|
|
87
|
-
mockSubmitStep.mockResolvedValueOnce({
|
|
88
|
-
ok: true,
|
|
89
|
-
body: {
|
|
90
|
-
sessionId: "sess1",
|
|
91
|
-
landed: "budget",
|
|
92
|
-
nextStepKey: "thanks",
|
|
93
|
-
completed: false,
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
await submitFlowStepAction("get-a-quote", {
|
|
98
|
-
sessionId: "sess1",
|
|
99
|
-
stepKey: "budget",
|
|
100
|
-
values: { budget: "small" },
|
|
101
|
-
locale: "en",
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
expect(mockSubmitStep).toHaveBeenCalledWith("get-a-quote", {
|
|
105
|
-
sessionId: "sess1",
|
|
106
|
-
stepKey: "budget",
|
|
107
|
-
values: { budget: "small" },
|
|
108
|
-
locale: "en",
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
describe("submitFlowStepAction — invalid input", () => {
|
|
114
|
-
it("returns invalid_input without calling api-client for a malformed slug", async () => {
|
|
115
|
-
const result = await submitFlowStepAction("Not A Slug!", VALID_PAYLOAD);
|
|
116
|
-
|
|
117
|
-
expect(result).toMatchObject({ ok: false, kind: "invalid_input" });
|
|
118
|
-
expect(mockSubmitStep).not.toHaveBeenCalled();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it("returns invalid_input without calling api-client for a missing stepKey", async () => {
|
|
122
|
-
const result = await submitFlowStepAction("get-a-quote", {
|
|
123
|
-
stepKey: "",
|
|
124
|
-
values: {},
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
expect(result).toMatchObject({ ok: false, kind: "invalid_input" });
|
|
128
|
-
expect(mockSubmitStep).not.toHaveBeenCalled();
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
describe("submitFlowStepAction — api-client failure mapping", () => {
|
|
133
|
-
it("maps a 400 response to kind invalid_input", async () => {
|
|
134
|
-
mockSubmitStep.mockResolvedValueOnce({ ok: false, status: 400, body: {} });
|
|
135
|
-
|
|
136
|
-
const result = await submitFlowStepAction("get-a-quote", VALID_PAYLOAD);
|
|
137
|
-
|
|
138
|
-
expect(result).toEqual({ ok: false, kind: "invalid_input" });
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("maps a 409 response to kind step_conflict", async () => {
|
|
142
|
-
mockSubmitStep.mockResolvedValueOnce({ ok: false, status: 409, body: {} });
|
|
143
|
-
|
|
144
|
-
const result = await submitFlowStepAction("get-a-quote", VALID_PAYLOAD);
|
|
145
|
-
|
|
146
|
-
expect(result).toEqual({ ok: false, kind: "step_conflict" });
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it("maps a 429 response to kind rate_limited, carrying retryAfterSeconds (#4730)", async () => {
|
|
150
|
-
mockSubmitStep.mockResolvedValueOnce({
|
|
151
|
-
ok: false,
|
|
152
|
-
status: 429,
|
|
153
|
-
body: { error: "rate_limited", retryAfterSeconds: 37 },
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
const result = await submitFlowStepAction("get-a-quote", VALID_PAYLOAD);
|
|
157
|
-
|
|
158
|
-
expect(result).toEqual({
|
|
159
|
-
ok: false,
|
|
160
|
-
kind: "rate_limited",
|
|
161
|
-
retryAfterSeconds: 37,
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it("maps a 429 response with no retryAfterSeconds to kind rate_limited alone (#4730)", async () => {
|
|
166
|
-
mockSubmitStep.mockResolvedValueOnce({ ok: false, status: 429, body: {} });
|
|
167
|
-
|
|
168
|
-
const result = await submitFlowStepAction("get-a-quote", VALID_PAYLOAD);
|
|
169
|
-
|
|
170
|
-
expect(result).toEqual({ ok: false, kind: "rate_limited" });
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it("maps any other failing status to kind network", async () => {
|
|
174
|
-
mockSubmitStep.mockResolvedValueOnce({ ok: false, status: 500, body: {} });
|
|
175
|
-
|
|
176
|
-
const result = await submitFlowStepAction("get-a-quote", VALID_PAYLOAD);
|
|
177
|
-
|
|
178
|
-
expect(result).toEqual({ ok: false, kind: "network" });
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
it("maps a thrown error to kind network", async () => {
|
|
182
|
-
mockSubmitStep.mockRejectedValueOnce(new Error("network down"));
|
|
183
|
-
|
|
184
|
-
const result = await submitFlowStepAction("get-a-quote", VALID_PAYLOAD);
|
|
185
|
-
|
|
186
|
-
expect(result).toEqual({ ok: false, kind: "network" });
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it("logs a thrown error server-side without leaking submitted values", async () => {
|
|
190
|
-
const thrown = new Error("network down");
|
|
191
|
-
mockSubmitStep.mockRejectedValueOnce(thrown);
|
|
192
|
-
const consoleErrorSpy = jest
|
|
193
|
-
.spyOn(console, "error")
|
|
194
|
-
.mockImplementation(() => {});
|
|
195
|
-
|
|
196
|
-
const result = await submitFlowStepAction("get-a-quote", VALID_PAYLOAD);
|
|
197
|
-
|
|
198
|
-
expect(result).toEqual({ ok: false, kind: "network" });
|
|
199
|
-
expect(consoleErrorSpy).toHaveBeenCalledTimes(1);
|
|
200
|
-
const [logLine, loggedErr] = consoleErrorSpy.mock.calls[0] as [
|
|
201
|
-
string,
|
|
202
|
-
unknown,
|
|
203
|
-
];
|
|
204
|
-
expect(logLine).toContain("[submitFlowStepAction]");
|
|
205
|
-
expect(logLine).toContain("get-a-quote");
|
|
206
|
-
expect(logLine).toContain(VALID_PAYLOAD.stepKey);
|
|
207
|
-
expect(logLine).not.toContain("jane@example.com");
|
|
208
|
-
expect(loggedErr).toBe(thrown);
|
|
209
|
-
|
|
210
|
-
consoleErrorSpy.mockRestore();
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
describe("submitFlowStepAction — visitor IP forwarding (#4730)", () => {
|
|
215
|
-
it("forwards x-forwarded-for from the action's own incoming request as init.headers", async () => {
|
|
216
|
-
mockHeaders.mockResolvedValueOnce({
|
|
217
|
-
get: (name: string) =>
|
|
218
|
-
name === "x-forwarded-for" ? "203.0.113.7, 9.9.9.9" : null,
|
|
219
|
-
});
|
|
220
|
-
mockSubmitStep.mockResolvedValueOnce({
|
|
221
|
-
ok: true,
|
|
222
|
-
body: {
|
|
223
|
-
sessionId: "sess1",
|
|
224
|
-
landed: "contact",
|
|
225
|
-
nextStepKey: "budget",
|
|
226
|
-
completed: false,
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
await submitFlowStepAction("get-a-quote", VALID_PAYLOAD);
|
|
231
|
-
|
|
232
|
-
expect(mockSubmitStep).toHaveBeenCalledWith(
|
|
233
|
-
"get-a-quote",
|
|
234
|
-
expect.objectContaining(VALID_PAYLOAD),
|
|
235
|
-
{ headers: { "x-forwarded-for": "203.0.113.7, 9.9.9.9" } },
|
|
236
|
-
);
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
it("falls back to x-real-ip when x-forwarded-for is absent", async () => {
|
|
240
|
-
mockHeaders.mockResolvedValueOnce({
|
|
241
|
-
get: (name: string) => (name === "x-real-ip" ? "198.51.100.4" : null),
|
|
242
|
-
});
|
|
243
|
-
mockSubmitStep.mockResolvedValueOnce({
|
|
244
|
-
ok: true,
|
|
245
|
-
body: {
|
|
246
|
-
sessionId: "sess1",
|
|
247
|
-
landed: "contact",
|
|
248
|
-
nextStepKey: "budget",
|
|
249
|
-
completed: false,
|
|
250
|
-
},
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
await submitFlowStepAction("get-a-quote", VALID_PAYLOAD);
|
|
254
|
-
|
|
255
|
-
expect(mockSubmitStep).toHaveBeenCalledWith(
|
|
256
|
-
"get-a-quote",
|
|
257
|
-
expect.objectContaining(VALID_PAYLOAD),
|
|
258
|
-
{ headers: { "x-forwarded-for": "198.51.100.4" } },
|
|
259
|
-
);
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it("calls flows.submitStep with exactly two arguments when no visitor IP header is present", async () => {
|
|
263
|
-
// Default mock (no x-forwarded-for / x-real-ip) — mirrors every other
|
|
264
|
-
// test in this file; asserted explicitly here as the #4730 regression
|
|
265
|
-
// floor: no header ⇒ no third argument, ever an explicit `undefined`.
|
|
266
|
-
mockSubmitStep.mockResolvedValueOnce({
|
|
267
|
-
ok: true,
|
|
268
|
-
body: {
|
|
269
|
-
sessionId: "sess1",
|
|
270
|
-
landed: "contact",
|
|
271
|
-
nextStepKey: "budget",
|
|
272
|
-
completed: false,
|
|
273
|
-
},
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
await submitFlowStepAction("get-a-quote", VALID_PAYLOAD);
|
|
277
|
-
|
|
278
|
-
expect(mockSubmitStep).toHaveBeenCalledWith(
|
|
279
|
-
"get-a-quote",
|
|
280
|
-
expect.objectContaining(VALID_PAYLOAD),
|
|
281
|
-
);
|
|
282
|
-
expect(mockSubmitStep.mock.calls[0]).toHaveLength(2);
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
it("degrades to no forwarded header when headers() itself throws", async () => {
|
|
286
|
-
mockHeaders.mockRejectedValueOnce(new Error("no request scope"));
|
|
287
|
-
mockSubmitStep.mockResolvedValueOnce({
|
|
288
|
-
ok: true,
|
|
289
|
-
body: {
|
|
290
|
-
sessionId: "sess1",
|
|
291
|
-
landed: "contact",
|
|
292
|
-
nextStepKey: "budget",
|
|
293
|
-
completed: false,
|
|
294
|
-
},
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
const result = await submitFlowStepAction("get-a-quote", VALID_PAYLOAD);
|
|
298
|
-
|
|
299
|
-
expect(result).toEqual({
|
|
300
|
-
ok: true,
|
|
301
|
-
response: {
|
|
302
|
-
sessionId: "sess1",
|
|
303
|
-
landed: "contact",
|
|
304
|
-
nextStepKey: "budget",
|
|
305
|
-
completed: false,
|
|
306
|
-
},
|
|
307
|
-
});
|
|
308
|
-
expect(mockSubmitStep.mock.calls[0]).toHaveLength(2);
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
// #9255 D4 — the write bot check runs after the slug and payload checks,
|
|
313
|
-
// immediately before the write (spec
|
|
314
|
-
// docs/specs/9255-an-edge-bot-challenge-in-spec.md §5.1 AC-2).
|
|
315
|
-
describe("submitFlowStepAction — the write bot check (#9255)", () => {
|
|
316
|
-
const BOT = {
|
|
317
|
-
isHuman: false,
|
|
318
|
-
isBot: true,
|
|
319
|
-
isVerifiedBot: false,
|
|
320
|
-
bypassed: false,
|
|
321
|
-
};
|
|
322
|
-
const HUMAN = { ...BOT, isHuman: true, isBot: false };
|
|
323
|
-
const BOT_ENV_KEYS = [
|
|
324
|
-
"VERCEL",
|
|
325
|
-
"AILK_BOT_CHECK",
|
|
326
|
-
"AILK_BOOKING_BOT_CHECK",
|
|
327
|
-
] as const;
|
|
328
|
-
const priorBotEnv = new Map(
|
|
329
|
-
BOT_ENV_KEYS.map((name) => [name, process.env[name]]),
|
|
330
|
-
);
|
|
331
|
-
|
|
332
|
-
let botLogSpies: jest.SpyInstance[] = [];
|
|
333
|
-
|
|
334
|
-
beforeEach(() => {
|
|
335
|
-
checkBotIdMock.mockReset();
|
|
336
|
-
for (const name of BOT_ENV_KEYS) delete process.env[name];
|
|
337
|
-
process.env.VERCEL = "1";
|
|
338
|
-
botLogSpies = [
|
|
339
|
-
jest.spyOn(console, "warn").mockImplementation(() => undefined),
|
|
340
|
-
jest.spyOn(console, "error").mockImplementation(() => undefined),
|
|
341
|
-
];
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
afterEach(() => {
|
|
345
|
-
for (const [name, value] of priorBotEnv) {
|
|
346
|
-
if (value === undefined) delete process.env[name];
|
|
347
|
-
else process.env[name] = value;
|
|
348
|
-
}
|
|
349
|
-
for (const spy of botLogSpies) spy.mockRestore();
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
it.each([
|
|
353
|
-
["a bot", () => checkBotIdMock.mockResolvedValue(BOT)],
|
|
354
|
-
[
|
|
355
|
-
"a check that fails",
|
|
356
|
-
() => checkBotIdMock.mockRejectedValue(new Error("boom")),
|
|
357
|
-
],
|
|
358
|
-
])("%s gets kind network, and nothing is sent", async (_label, decide) => {
|
|
359
|
-
decide();
|
|
360
|
-
expect(
|
|
361
|
-
await submitFlowStepAction("lead-magnet", VALID_PAYLOAD),
|
|
362
|
-
).toStrictEqual({
|
|
363
|
-
ok: false,
|
|
364
|
-
kind: "network",
|
|
365
|
-
});
|
|
366
|
-
expect(checkBotIdMock).toHaveBeenCalledTimes(1);
|
|
367
|
-
expect(mockSubmitStep).not.toHaveBeenCalled();
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
it("a human sends exactly what the check off sends", async () => {
|
|
371
|
-
checkBotIdMock.mockResolvedValue(HUMAN);
|
|
372
|
-
mockSubmitStep.mockResolvedValue({
|
|
373
|
-
ok: true,
|
|
374
|
-
status: 200,
|
|
375
|
-
body: { sessionId: "s1", nextStepKey: null, completed: true },
|
|
376
|
-
});
|
|
377
|
-
delete process.env.VERCEL;
|
|
378
|
-
await submitFlowStepAction("lead-magnet", VALID_PAYLOAD);
|
|
379
|
-
process.env.VERCEL = "1";
|
|
380
|
-
expect(
|
|
381
|
-
await submitFlowStepAction("lead-magnet", VALID_PAYLOAD),
|
|
382
|
-
).toMatchObject({ ok: true });
|
|
383
|
-
expect(checkBotIdMock).toHaveBeenCalledTimes(1);
|
|
384
|
-
expect(mockSubmitStep).toHaveBeenCalledTimes(2);
|
|
385
|
-
expect(mockSubmitStep.mock.calls[1]).toEqual(mockSubmitStep.mock.calls[0]);
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
it("an invalid payload answers invalid_input with no check", async () => {
|
|
389
|
-
checkBotIdMock.mockResolvedValue(BOT);
|
|
390
|
-
expect(
|
|
391
|
-
await submitFlowStepAction("lead-magnet", { stepKey: "", values: {} }),
|
|
392
|
-
).toMatchObject({
|
|
393
|
-
ok: false,
|
|
394
|
-
kind: "invalid_input",
|
|
395
|
-
});
|
|
396
|
-
expect(checkBotIdMock).not.toHaveBeenCalled();
|
|
397
|
-
});
|
|
398
|
-
});
|