create-ailk 0.37.0 → 0.38.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 +149 -2
- 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 +7 -2
- package/dist/add-route.js +28 -13
- 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 +9 -15
- 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 +67 -0
- package/dist/routes.d.ts +103 -0
- package/dist/routes.js +708 -0
- package/dist/site-manifest.js +1 -1
- package/dist/site-roster.d.ts +2 -1
- package/dist/site-roster.js +30 -8
- package/dist/spoke-checkout.d.ts +28 -27
- package/dist/spoke-checkout.js +71 -102
- package/dist/surfaces.d.ts +18 -0
- package/dist/surfaces.js +47 -282
- package/dist/sync-routes.d.ts +28 -1
- package/dist/sync-routes.js +144 -11
- package/dist/template-record.d.ts +11 -0
- package/dist/template-record.js +18 -0
- package/dist/topology.d.ts +15 -1
- package/dist/topology.js +20 -4
- package/dist/update.d.ts +31 -2
- package/dist/update.js +627 -99
- 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 +62 -20
- package/templates/apps/web/account.config.tsx +101 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +3 -161
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +3 -139
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +3 -406
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +2 -190
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +3 -182
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +8 -420
- package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +1 -1
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +8 -214
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +8 -115
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/message/[id]/file/route.ts +2 -80
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +8 -121
- package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +3 -154
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +7 -149
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +3 -143
- package/templates/apps/web/app/[locale]/(authed)/account/onboarding/page.tsx +3 -126
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +8 -302
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +2 -102
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +3 -240
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -131
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +2 -24
- package/templates/apps/web/app/[locale]/(authed)/account/support/page.tsx +3 -60
- package/templates/apps/web/app/[locale]/layout.tsx +45 -28
- 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/i18n/request.ts +44 -1
- package/templates/apps/web/jest.config.cjs +13 -1
- package/templates/apps/web/lib/__tests__/auth-phone.test.ts +11 -0
- package/templates/apps/web/lib/__tests__/fixtures/site-topology.ts +70 -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/site-brand.tsx +3 -5
- package/templates/apps/web/messages/en.json +8 -684
- package/templates/apps/web/middleware.ts +3 -1
- package/templates/apps/web/next.config.mjs +27 -0
- package/templates/apps/web/package.json +1 -0
- package/templates/customizations.yaml +9 -0
- package/templates/package.json +3 -1
- package/templates/tools/lint-architecture.ts +164 -11
- package/versions.json +48 -47
- 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/__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/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/__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/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-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/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/message/[id]/file/__tests__/route.test.ts +0 -215
- 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/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/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/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/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/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/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-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/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/lib/__tests__/account-config.test.ts +0 -704
- package/templates/apps/web/lib/account-config.ts +0 -678
- package/templates/apps/web/lib/checkout-config.ts +0 -16
- 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]/results/[payload]/__tests__/page.test.tsx
DELETED
|
@@ -1,485 +0,0 @@
|
|
|
1
|
-
// oss: false
|
|
2
|
-
/**
|
|
3
|
-
* Tests for the `/[locale]/flows/[slug]/results/[payload]` cold-load route
|
|
4
|
-
* (#4770).
|
|
5
|
-
*
|
|
6
|
-
* AC3 — a payload encoding a known answer set renders exactly the offer
|
|
7
|
-
* names and matched reasons `recommend()` returns for those same
|
|
8
|
-
* answers — asserted against the SAME fixture (`FIXTURE_CONFIG` +
|
|
9
|
-
* `KNOWN_ANSWERS`) `recommend()` itself would score.
|
|
10
|
-
* AC4 — four cases `redirect()` to `/[locale]/flows/[slug]` and render no
|
|
11
|
-
* results markup: invalid payload, stale-version payload, a
|
|
12
|
-
* flowSlug-mismatched payload, and a non-recommending flow.
|
|
13
|
-
* #11013 spec E, D-C (AC-3) — the guard widens additively: a recommending
|
|
14
|
-
* flow with no offers and no rows renders whenever `hasResultsPage`
|
|
15
|
-
* holds (no ending); a cold permalink of a recommending flow with an
|
|
16
|
-
* ending and offers still renders, as at the pin.
|
|
17
|
-
*
|
|
18
|
-
* `next/navigation`'s `redirect` is mocked to throw (mirrors the sibling
|
|
19
|
-
* `thanks/[slug]` route's `notFound` test pattern) so a redirect is
|
|
20
|
-
* observable via `.rejects.toThrow` without a real Next.js router. `next-intl`
|
|
21
|
-
* is mocked to an identity translator — `ResultsClient`'s only string comes
|
|
22
|
-
* from the `flow` namespace's `whyThis` key, which this test does not assert
|
|
23
|
-
* on by literal text.
|
|
24
|
-
*/
|
|
25
|
-
import { render, screen } from "@testing-library/react";
|
|
26
|
-
import userEvent from "@testing-library/user-event";
|
|
27
|
-
import type { FlowConfig } from "@working-theory/validation";
|
|
28
|
-
import {
|
|
29
|
-
encodePermalink,
|
|
30
|
-
PERMALINK_VERSION,
|
|
31
|
-
recommend,
|
|
32
|
-
resolveLocalizedString,
|
|
33
|
-
} from "@working-theory/validation";
|
|
34
|
-
|
|
35
|
-
const mockGet = jest.fn();
|
|
36
|
-
jest.mock("@working-theory/api-client", () => ({
|
|
37
|
-
__esModule: true,
|
|
38
|
-
flows: { get: (...args: unknown[]) => mockGet(...args) },
|
|
39
|
-
}));
|
|
40
|
-
|
|
41
|
-
const mockRedirect = jest.fn((url: string) => {
|
|
42
|
-
throw new Error(`NEXT_REDIRECT:${url}`);
|
|
43
|
-
});
|
|
44
|
-
jest.mock("next/navigation", () => ({
|
|
45
|
-
__esModule: true,
|
|
46
|
-
redirect: (url: string) => mockRedirect(url),
|
|
47
|
-
}));
|
|
48
|
-
|
|
49
|
-
jest.mock("next-intl", () => ({
|
|
50
|
-
__esModule: true,
|
|
51
|
-
useTranslations: () => (key: string) => key,
|
|
52
|
-
useMessages: () => ({}),
|
|
53
|
-
}));
|
|
54
|
-
|
|
55
|
-
import Page, { generateMetadata } from "../page";
|
|
56
|
-
|
|
57
|
-
const SLUG = "ailk-recommender";
|
|
58
|
-
|
|
59
|
-
const KNOWN_ANSWERS = { team_size: "solo", wants_seo: "yes" };
|
|
60
|
-
|
|
61
|
-
function fixtureConfig(overrides: Partial<FlowConfig> = {}): FlowConfig {
|
|
62
|
-
return {
|
|
63
|
-
slug: SLUG,
|
|
64
|
-
defaultLocale: "en",
|
|
65
|
-
mode: "recommending",
|
|
66
|
-
steps: [
|
|
67
|
-
{
|
|
68
|
-
key: "team",
|
|
69
|
-
type: "segmentation",
|
|
70
|
-
copy: { title: { en: "Tell us about your team" } },
|
|
71
|
-
questions: [
|
|
72
|
-
{
|
|
73
|
-
name: "team_size",
|
|
74
|
-
options: [
|
|
75
|
-
{ value: "solo", label: { en: "Solo" } },
|
|
76
|
-
{ value: "agency", label: { en: "Agency" } },
|
|
77
|
-
],
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: "wants_seo",
|
|
81
|
-
options: [
|
|
82
|
-
{ value: "yes", label: { en: "Yes" } },
|
|
83
|
-
{ value: "no", label: { en: "No" } },
|
|
84
|
-
],
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
offers: [
|
|
90
|
-
{
|
|
91
|
-
key: "free_oss",
|
|
92
|
-
copy: {
|
|
93
|
-
name: { en: "Free" },
|
|
94
|
-
description: { en: "Self-serve, open source." },
|
|
95
|
-
},
|
|
96
|
-
price: { kind: "label", label: { en: "Free" } },
|
|
97
|
-
rules: [
|
|
98
|
-
{
|
|
99
|
-
when: { answer: "team_size", eq: "solo" },
|
|
100
|
-
reason: { en: "You're a solo builder." },
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
key: "seo_addon",
|
|
106
|
-
copy: {
|
|
107
|
-
name: { en: "SEO Add-on" },
|
|
108
|
-
description: { en: "AEO + SEO tuning." },
|
|
109
|
-
},
|
|
110
|
-
price: { kind: "label", label: { en: "Add-on" } },
|
|
111
|
-
rules: [
|
|
112
|
-
{
|
|
113
|
-
when: { answer: "wants_seo", eq: "yes" },
|
|
114
|
-
reason: { en: "You want more organic reach." },
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
recommendation: {
|
|
120
|
-
key: "recommendation",
|
|
121
|
-
copy: { title: { en: "Your recommendation" } },
|
|
122
|
-
},
|
|
123
|
-
...overrides,
|
|
124
|
-
} as FlowConfig;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
beforeEach(() => {
|
|
128
|
-
mockGet.mockReset();
|
|
129
|
-
mockRedirect.mockClear();
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
async function expectRedirectTo(
|
|
133
|
-
payload: string,
|
|
134
|
-
expectedUrl: string,
|
|
135
|
-
): Promise<void> {
|
|
136
|
-
await expect(
|
|
137
|
-
Page({
|
|
138
|
-
params: Promise.resolve({ locale: "en", slug: SLUG, payload }),
|
|
139
|
-
}),
|
|
140
|
-
).rejects.toThrow(`NEXT_REDIRECT:${expectedUrl}`);
|
|
141
|
-
expect(mockRedirect).toHaveBeenCalledWith(expectedUrl);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
describe("AC4 — invalid / stale-version / mismatched / non-recommending all redirect to step 1", () => {
|
|
145
|
-
it("redirects on an invalid payload", async () => {
|
|
146
|
-
await expectRedirectTo("not-a-valid-payload!!!", `/en/flows/${SLUG}`);
|
|
147
|
-
// Never fetched the flow config for an undecodable payload.
|
|
148
|
-
expect(mockGet).not.toHaveBeenCalled();
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("redirects on a stale-version payload", async () => {
|
|
152
|
-
const stalePayload = encodePermalink({
|
|
153
|
-
version: PERMALINK_VERSION - 1,
|
|
154
|
-
flowSlug: SLUG,
|
|
155
|
-
answers: KNOWN_ANSWERS,
|
|
156
|
-
});
|
|
157
|
-
await expectRedirectTo(stalePayload, `/en/flows/${SLUG}`);
|
|
158
|
-
expect(mockGet).not.toHaveBeenCalled();
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it("redirects when the payload's own flowSlug differs from the route's [slug]", async () => {
|
|
162
|
-
const mismatchedPayload = encodePermalink({
|
|
163
|
-
version: PERMALINK_VERSION,
|
|
164
|
-
flowSlug: "a-different-flow",
|
|
165
|
-
answers: KNOWN_ANSWERS,
|
|
166
|
-
});
|
|
167
|
-
await expectRedirectTo(mismatchedPayload, `/en/flows/${SLUG}`);
|
|
168
|
-
expect(mockGet).not.toHaveBeenCalled();
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("redirects when the served flow is not a recommending flow (no offers)", async () => {
|
|
172
|
-
const payload = encodePermalink({
|
|
173
|
-
version: PERMALINK_VERSION,
|
|
174
|
-
flowSlug: SLUG,
|
|
175
|
-
answers: KNOWN_ANSWERS,
|
|
176
|
-
});
|
|
177
|
-
const {
|
|
178
|
-
offers: _offers,
|
|
179
|
-
mode: _mode,
|
|
180
|
-
...nonRecommending
|
|
181
|
-
} = fixtureConfig();
|
|
182
|
-
mockGet.mockResolvedValueOnce({ ok: true, body: nonRecommending });
|
|
183
|
-
|
|
184
|
-
await expectRedirectTo(payload, `/en/flows/${SLUG}`);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it("redirects when the served flow declares mode !== 'recommending'", async () => {
|
|
188
|
-
const payload = encodePermalink({
|
|
189
|
-
version: PERMALINK_VERSION,
|
|
190
|
-
flowSlug: SLUG,
|
|
191
|
-
answers: KNOWN_ANSWERS,
|
|
192
|
-
});
|
|
193
|
-
mockGet.mockResolvedValueOnce({
|
|
194
|
-
ok: true,
|
|
195
|
-
body: fixtureConfig({ mode: "qualifying" }),
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
await expectRedirectTo(payload, `/en/flows/${SLUG}`);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it("no results markup renders on any redirect path (renders nothing before throwing)", async () => {
|
|
202
|
-
await expect(
|
|
203
|
-
Page({
|
|
204
|
-
params: Promise.resolve({
|
|
205
|
-
locale: "en",
|
|
206
|
-
slug: SLUG,
|
|
207
|
-
payload: "garbage",
|
|
208
|
-
}),
|
|
209
|
-
}),
|
|
210
|
-
).rejects.toThrow();
|
|
211
|
-
expect(screen.queryByTestId("flow-results")).not.toBeInTheDocument();
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
describe("AC3 — a valid payload against a recommending flow renders exactly recommend()'s fits", () => {
|
|
216
|
-
it("renders exactly the offer names and matched reasons recommend() itself returns for the same answers", async () => {
|
|
217
|
-
const user = userEvent.setup();
|
|
218
|
-
const config = fixtureConfig();
|
|
219
|
-
const payload = encodePermalink({
|
|
220
|
-
version: PERMALINK_VERSION,
|
|
221
|
-
flowSlug: SLUG,
|
|
222
|
-
answers: KNOWN_ANSWERS,
|
|
223
|
-
});
|
|
224
|
-
mockGet.mockResolvedValueOnce({ ok: true, body: config });
|
|
225
|
-
|
|
226
|
-
// The SAME fixture (`config` + `KNOWN_ANSWERS`) drives BOTH the mocked
|
|
227
|
-
// server response AND this expectation — `recommend()` is the one
|
|
228
|
-
// source of truth for "which fits, in what order, with which reason,"
|
|
229
|
-
// never a second hand-typed list that could silently drift from it.
|
|
230
|
-
const expected = recommend(
|
|
231
|
-
{
|
|
232
|
-
key: SLUG,
|
|
233
|
-
offers: config.offers,
|
|
234
|
-
pairings: config.pairings,
|
|
235
|
-
rateTable: config.rateTable,
|
|
236
|
-
scoring: config.scoring,
|
|
237
|
-
},
|
|
238
|
-
KNOWN_ANSWERS,
|
|
239
|
-
);
|
|
240
|
-
expect(expected.fits.length).toBeGreaterThan(0);
|
|
241
|
-
|
|
242
|
-
const element = await Page({
|
|
243
|
-
params: Promise.resolve({ locale: "en", slug: SLUG, payload }),
|
|
244
|
-
});
|
|
245
|
-
render(element);
|
|
246
|
-
|
|
247
|
-
expect(mockRedirect).not.toHaveBeenCalled();
|
|
248
|
-
expect(screen.getByTestId("flow-results")).toBeInTheDocument();
|
|
249
|
-
expect(
|
|
250
|
-
screen.getByRole("heading", {
|
|
251
|
-
name: resolveLocalizedString(
|
|
252
|
-
config.recommendation!.copy.title,
|
|
253
|
-
"en",
|
|
254
|
-
config.defaultLocale,
|
|
255
|
-
),
|
|
256
|
-
}),
|
|
257
|
-
).toBeInTheDocument();
|
|
258
|
-
|
|
259
|
-
for (const fit of expected.fits) {
|
|
260
|
-
const offer = config.offers!.find((o) => o.key === fit.offerKey)!;
|
|
261
|
-
const name = resolveLocalizedString(
|
|
262
|
-
offer.copy.name,
|
|
263
|
-
"en",
|
|
264
|
-
config.defaultLocale,
|
|
265
|
-
);
|
|
266
|
-
// #11013 D-G — the top fit alone renders, as one card; the side panel
|
|
267
|
-
// and every other fit are gone from the results view.
|
|
268
|
-
if (fit.offerKey !== expected.fits[0]!.offerKey) {
|
|
269
|
-
expect(screen.queryByText(name)).not.toBeInTheDocument();
|
|
270
|
-
expect(screen.queryByTestId(`recommendation-card-${fit.offerKey}`)).not.toBeInTheDocument();
|
|
271
|
-
continue;
|
|
272
|
-
}
|
|
273
|
-
expect(screen.getAllByText(name)).toHaveLength(1);
|
|
274
|
-
if (offer.copy.description) {
|
|
275
|
-
expect(
|
|
276
|
-
screen.getByText(
|
|
277
|
-
resolveLocalizedString(
|
|
278
|
-
offer.copy.description,
|
|
279
|
-
"en",
|
|
280
|
-
config.defaultLocale,
|
|
281
|
-
),
|
|
282
|
-
),
|
|
283
|
-
).toBeInTheDocument();
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// The matched reason renders inside the "Why this?" Popover
|
|
287
|
-
// disclosure — reveal it (mirrors packages/ui/src/blocks/__tests__/
|
|
288
|
-
// RecommendationCard.test.tsx's own click-to-reveal pattern).
|
|
289
|
-
await user.click(
|
|
290
|
-
screen.getByTestId(`recommendation-card-${fit.offerKey}-why-trigger`),
|
|
291
|
-
);
|
|
292
|
-
expect(
|
|
293
|
-
await screen.findByText(
|
|
294
|
-
resolveLocalizedString(fit.reason, "en", config.defaultLocale),
|
|
295
|
-
),
|
|
296
|
-
).toBeInTheDocument();
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
// ─── #11013 spec E, D-C (AC-3) — the widened guard ─────────────────────────
|
|
302
|
-
|
|
303
|
-
describe("#11013 D-C — the results page serves every flow with a results page", () => {
|
|
304
|
-
const validPayload = (): string =>
|
|
305
|
-
encodePermalink({ version: PERMALINK_VERSION, flowSlug: SLUG, answers: KNOWN_ANSWERS });
|
|
306
|
-
|
|
307
|
-
it("a recommending flow with no offers, no by-result rows and no ending renders ResultsClient", async () => {
|
|
308
|
-
const { offers: _offers, ...noOffers } = fixtureConfig();
|
|
309
|
-
mockGet.mockResolvedValueOnce({ ok: true, body: noOffers });
|
|
310
|
-
render(await Page({ params: Promise.resolve({ locale: "en", slug: SLUG, payload: validPayload() }) }));
|
|
311
|
-
expect(mockRedirect).not.toHaveBeenCalled();
|
|
312
|
-
expect(screen.getByTestId("flow-results")).toBeInTheDocument();
|
|
313
|
-
expect(screen.queryAllByTestId(/^recommendation-card-[a-z_]+$/)).toHaveLength(0);
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
it("a flow that is not recommending still redirects, offers or not", async () => {
|
|
317
|
-
mockGet.mockResolvedValueOnce({ ok: true, body: fixtureConfig({ mode: "qualifying" }) });
|
|
318
|
-
await expectRedirectTo(validPayload(), `/en/flows/${SLUG}`);
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
it("a recommending flow with an ending and offers still renders from a cold permalink (today's guard)", async () => {
|
|
322
|
-
mockGet.mockResolvedValueOnce({
|
|
323
|
-
ok: true,
|
|
324
|
-
body: fixtureConfig({ ending: { default: { kind: "screen", headline: { en: "Done" } } } } as Partial<FlowConfig>),
|
|
325
|
-
});
|
|
326
|
-
render(await Page({ params: Promise.resolve({ locale: "en", slug: SLUG, payload: validPayload() }) }));
|
|
327
|
-
expect(mockRedirect).not.toHaveBeenCalled();
|
|
328
|
-
expect(screen.getByTestId("flow-results")).toBeInTheDocument();
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it("a recommending flow with an ending and no offers or rows redirects (no results page)", async () => {
|
|
332
|
-
const { offers: _offers, ...noOffers } = fixtureConfig();
|
|
333
|
-
mockGet.mockResolvedValueOnce({
|
|
334
|
-
ok: true,
|
|
335
|
-
body: { ...noOffers, ending: { default: { kind: "screen", headline: { en: "Done" } } } },
|
|
336
|
-
});
|
|
337
|
-
await expectRedirectTo(validPayload(), `/en/flows/${SLUG}`);
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
it("hands ResultsClient the frame's brand and the exit to the flow's landing", async () => {
|
|
341
|
-
mockGet.mockResolvedValueOnce({ ok: true, body: fixtureConfig() });
|
|
342
|
-
render(await Page({ params: Promise.resolve({ locale: "en", slug: SLUG, payload: validPayload() }) }));
|
|
343
|
-
expect(screen.getByTestId("flow-frame-exit-link").getAttribute("href")).toBe(`/en/flows/${SLUG}`);
|
|
344
|
-
expect(screen.getByTestId("flow-frame-title")).toHaveTextContent("Tell us about your team");
|
|
345
|
-
expect(screen.getByTestId("flow-frame-logomark")).toBeInTheDocument();
|
|
346
|
-
expect(screen.getByTestId("flow-frame-wordmark")).toBeInTheDocument();
|
|
347
|
-
expect(screen.queryByTestId("flow-frame-bar")).not.toBeInTheDocument();
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
describe("generateMetadata", () => {
|
|
352
|
-
it("resolves the page title from the compiled recommendation marker", async () => {
|
|
353
|
-
const payload = encodePermalink({
|
|
354
|
-
version: PERMALINK_VERSION,
|
|
355
|
-
flowSlug: SLUG,
|
|
356
|
-
answers: KNOWN_ANSWERS,
|
|
357
|
-
});
|
|
358
|
-
mockGet.mockResolvedValueOnce({ ok: true, body: fixtureConfig() });
|
|
359
|
-
|
|
360
|
-
const metadata = await generateMetadata({
|
|
361
|
-
params: Promise.resolve({ locale: "en", slug: SLUG, payload }),
|
|
362
|
-
});
|
|
363
|
-
expect(metadata.title).toBe("Your recommendation");
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
it("returns an empty metadata object for an invalid payload", async () => {
|
|
367
|
-
const metadata = await generateMetadata({
|
|
368
|
-
params: Promise.resolve({
|
|
369
|
-
locale: "en",
|
|
370
|
-
slug: SLUG,
|
|
371
|
-
payload: "garbage",
|
|
372
|
-
}),
|
|
373
|
-
});
|
|
374
|
-
expect(metadata).toEqual({});
|
|
375
|
-
expect(mockGet).not.toHaveBeenCalled();
|
|
376
|
-
});
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
describe("#10990 AC-4 — a failed flow read redirects to the landing, never throws", () => {
|
|
380
|
-
const validPayload = (): string =>
|
|
381
|
-
encodePermalink({ version: PERMALINK_VERSION, flowSlug: SLUG, answers: KNOWN_ANSWERS });
|
|
382
|
-
|
|
383
|
-
it.each([
|
|
384
|
-
["a rejected read", () => mockGet.mockRejectedValue(new TypeError("fetch failed"))],
|
|
385
|
-
["a 2xx with no body", () => mockGet.mockResolvedValue({ ok: true, body: undefined })],
|
|
386
|
-
["a 2xx with {}", () => mockGet.mockResolvedValue({ ok: true, body: {} })],
|
|
387
|
-
["a 503", () => mockGet.mockResolvedValue({ ok: false, status: 503, body: null })],
|
|
388
|
-
["a 403", () => mockGet.mockResolvedValue({ ok: false, status: 403, body: null })],
|
|
389
|
-
])("%s: Page redirects to /en/flows/<slug> and generateMetadata is {}", async (_label, arrange) => {
|
|
390
|
-
arrange();
|
|
391
|
-
const payload = validPayload();
|
|
392
|
-
await expectRedirectTo(payload, `/en/flows/${SLUG}`);
|
|
393
|
-
await expect(
|
|
394
|
-
generateMetadata({ params: Promise.resolve({ locale: "en", slug: SLUG, payload }) }),
|
|
395
|
-
).resolves.toEqual({});
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
it("a read that never answers redirects after 5 seconds", async () => {
|
|
399
|
-
jest.useFakeTimers();
|
|
400
|
-
try {
|
|
401
|
-
mockGet.mockReturnValue(new Promise(() => undefined));
|
|
402
|
-
const rendering = Page({
|
|
403
|
-
params: Promise.resolve({ locale: "en", slug: SLUG, payload: validPayload() }),
|
|
404
|
-
});
|
|
405
|
-
const settled = expect(rendering).rejects.toThrow(`NEXT_REDIRECT:/en/flows/${SLUG}`);
|
|
406
|
-
await jest.advanceTimersByTimeAsync(5_000);
|
|
407
|
-
await settled;
|
|
408
|
-
} finally {
|
|
409
|
-
jest.useRealTimers();
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
// ─── #4842 AC-5 — the `?checkout=` return states (additive; the cases above
|
|
415
|
-
// are the regression floor and stay as they were) ───────────────────────────
|
|
416
|
-
|
|
417
|
-
describe("AC-5 (#4842) — ?checkout= return states render over the same recommendation", () => {
|
|
418
|
-
function validPayload(): string {
|
|
419
|
-
return encodePermalink({
|
|
420
|
-
version: PERMALINK_VERSION,
|
|
421
|
-
flowSlug: SLUG,
|
|
422
|
-
answers: KNOWN_ANSWERS,
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
async function renderWithSearch(
|
|
427
|
-
checkout: string | undefined,
|
|
428
|
-
): Promise<ReturnType<typeof recommend>> {
|
|
429
|
-
const config = fixtureConfig();
|
|
430
|
-
mockGet.mockResolvedValueOnce({ ok: true, body: config });
|
|
431
|
-
const expected = recommend(
|
|
432
|
-
{
|
|
433
|
-
key: SLUG,
|
|
434
|
-
offers: config.offers,
|
|
435
|
-
pairings: config.pairings,
|
|
436
|
-
rateTable: config.rateTable,
|
|
437
|
-
scoring: config.scoring,
|
|
438
|
-
},
|
|
439
|
-
KNOWN_ANSWERS,
|
|
440
|
-
);
|
|
441
|
-
const element = await Page({
|
|
442
|
-
params: Promise.resolve({ locale: "en", slug: SLUG, payload: validPayload() }),
|
|
443
|
-
searchParams: Promise.resolve(checkout === undefined ? {} : { checkout }),
|
|
444
|
-
});
|
|
445
|
-
render(element);
|
|
446
|
-
expect(mockRedirect).not.toHaveBeenCalled();
|
|
447
|
-
return expected;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
function expectIdenticalFits(expected: ReturnType<typeof recommend>): void {
|
|
451
|
-
expect(expected.fits.length).toBeGreaterThan(0);
|
|
452
|
-
// #11013 D-G — the top fit is the one card.
|
|
453
|
-
expect(screen.getByTestId(`recommendation-card-${expected.fits[0]!.offerKey}`)).toBeInTheDocument();
|
|
454
|
-
expect(screen.getAllByTestId(/^recommendation-card-[a-z_]+$/)).toHaveLength(1);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
it("?checkout=success renders the success status line AND the identical fit cards", async () => {
|
|
458
|
-
const expected = await renderWithSearch("success");
|
|
459
|
-
expect(screen.getByTestId("flow-results-return-state")).toHaveTextContent("checkoutSuccess");
|
|
460
|
-
expect(screen.getByRole("status")).toBeInTheDocument();
|
|
461
|
-
expectIdenticalFits(expected);
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
it("?checkout=cancelled renders the cancelled status line AND the identical fit cards", async () => {
|
|
465
|
-
const expected = await renderWithSearch("cancelled");
|
|
466
|
-
expect(screen.getByTestId("flow-results-return-state")).toHaveTextContent("checkoutCancelled");
|
|
467
|
-
expectIdenticalFits(expected);
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
it("an unrecognised value renders no status line; the fits are unchanged", async () => {
|
|
471
|
-
const expected = await renderWithSearch("bogus");
|
|
472
|
-
expect(screen.queryByTestId("flow-results-return-state")).not.toBeInTheDocument();
|
|
473
|
-
expectIdenticalFits(expected);
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
it("a return param never changes which redirect guard fires (invalid payload still redirects to step 1)", async () => {
|
|
477
|
-
await expect(
|
|
478
|
-
Page({
|
|
479
|
-
params: Promise.resolve({ locale: "en", slug: SLUG, payload: "not-a-valid-payload!!!" }),
|
|
480
|
-
searchParams: Promise.resolve({ checkout: "success" }),
|
|
481
|
-
}),
|
|
482
|
-
).rejects.toThrow(`NEXT_REDIRECT:/en/flows/${SLUG}`);
|
|
483
|
-
expect(mockGet).not.toHaveBeenCalled();
|
|
484
|
-
});
|
|
485
|
-
});
|