create-ailk 0.37.1 → 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 +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 +18 -11
- 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 +14 -1
- package/dist/sync-routes.js +86 -5
- package/dist/topology.d.ts +15 -1
- package/dist/topology.js +20 -4
- 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 +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
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
// oss: false
|
|
2
|
-
/**
|
|
3
|
-
* #8848 D8, AC-5 — the ending delivers the deliverable by kind. FlowStepper
|
|
4
|
-
* is the ending suite's stub: it submits the configured steps through the
|
|
5
|
-
* real `onSubmitStep` and renders the `completedContent` it is given.
|
|
6
|
-
*/
|
|
7
|
-
import { render, screen } from "@testing-library/react";
|
|
8
|
-
import userEvent from "@testing-library/user-event";
|
|
9
|
-
import type { FlowConfig } from "@working-theory/validation";
|
|
10
|
-
import type { ReactElement, ReactNode } from "react";
|
|
11
|
-
|
|
12
|
-
const mockPush = jest.fn();
|
|
13
|
-
jest.mock("next/navigation", () => ({
|
|
14
|
-
useRouter: () => ({ push: mockPush }),
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
jest.mock("next-intl", () => ({
|
|
18
|
-
useTranslations: (namespace?: string) => (key: string) => (namespace ? `${namespace}.${key}` : key),
|
|
19
|
-
useMessages: () => ({}),
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
// eslint-disable-next-line no-restricted-syntax -- the boundary under test is the client wiring, not the actions
|
|
23
|
-
jest.mock("../flow.actions", () => ({ submitFlowStepAction: jest.fn() }));
|
|
24
|
-
// eslint-disable-next-line no-restricted-syntax -- see above
|
|
25
|
-
jest.mock("../account-invite.actions", () => ({ accountInviteLinkAction: jest.fn() }));
|
|
26
|
-
|
|
27
|
-
interface StubProps {
|
|
28
|
-
onSubmitStep: (payload: { stepKey: string; values: Record<string, unknown> }) => Promise<{
|
|
29
|
-
ok: boolean;
|
|
30
|
-
response?: { completed: boolean };
|
|
31
|
-
}>;
|
|
32
|
-
onCompleted?: (result: Record<string, never>) => void;
|
|
33
|
-
completedContent?: ReactNode;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
jest.mock("@working-theory/ui-signal-collectors", () => ({
|
|
37
|
-
FlowStepper: (props: StubProps) => {
|
|
38
|
-
const react = require("react");
|
|
39
|
-
// The real FlowStepper fires `onCompleted` after a completing submit.
|
|
40
|
-
async function handleSubmit(): Promise<void> {
|
|
41
|
-
const result = await props.onSubmitStep({ stepKey: "contact", values: { email: "ana@example.com" } });
|
|
42
|
-
if (result.ok && result.response?.completed) props.onCompleted?.({});
|
|
43
|
-
}
|
|
44
|
-
return react.createElement(
|
|
45
|
-
"div",
|
|
46
|
-
{ "data-testid": "mock-card" },
|
|
47
|
-
react.createElement("button", { "data-testid": "mock-submit", onClick: handleSubmit }, "Submit"),
|
|
48
|
-
props.completedContent,
|
|
49
|
-
) as ReactElement;
|
|
50
|
-
},
|
|
51
|
-
}));
|
|
52
|
-
|
|
53
|
-
import { submitFlowStepAction } from "../flow.actions";
|
|
54
|
-
import { FlowStepperClient } from "../FlowStepperClient";
|
|
55
|
-
|
|
56
|
-
const mockSubmit = submitFlowStepAction as jest.MockedFunction<typeof submitFlowStepAction>;
|
|
57
|
-
const en = (s: string) => ({ en: s });
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* A served config (#8848 D2): a gated block's target is projected out, which
|
|
61
|
-
* `FlowConfig` (the type `flows.get` answers with) cannot express — the one
|
|
62
|
-
* cast lives here.
|
|
63
|
-
*/
|
|
64
|
-
function config(extra: Record<string, unknown> = {}): FlowConfig {
|
|
65
|
-
const served = {
|
|
66
|
-
slug: "q3",
|
|
67
|
-
defaultLocale: "en",
|
|
68
|
-
steps: [
|
|
69
|
-
{
|
|
70
|
-
key: "contact",
|
|
71
|
-
type: "field",
|
|
72
|
-
copy: { title: en("Get the report") },
|
|
73
|
-
fields: [{ name: "email", inputType: "email", required: true, mapsTo: "email", copy: { label: en("Email") } }],
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
deliverable: {
|
|
77
|
-
kind: "file",
|
|
78
|
-
gated: true,
|
|
79
|
-
title: en("Q3 report"),
|
|
80
|
-
cta: en("Read the report"),
|
|
81
|
-
geometry: "letter",
|
|
82
|
-
pages: 3,
|
|
83
|
-
},
|
|
84
|
-
deliverables: { assets: [{ assetKey: "q3.pdf" }], copy: { subject: en("s"), body: en("b") } },
|
|
85
|
-
...extra,
|
|
86
|
-
};
|
|
87
|
-
// eslint-disable-next-line no-restricted-syntax -- a served gated block omits its target, which FlowConfig cannot express (see above)
|
|
88
|
-
return served as unknown as FlowConfig;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function respondWith(deliverable?: unknown): void {
|
|
92
|
-
mockSubmit.mockResolvedValue({
|
|
93
|
-
ok: true,
|
|
94
|
-
response: {
|
|
95
|
-
sessionId: "s1",
|
|
96
|
-
landed: "contact",
|
|
97
|
-
nextStepKey: null,
|
|
98
|
-
completed: true,
|
|
99
|
-
...(deliverable !== undefined ? { deliverable } : {}),
|
|
100
|
-
},
|
|
101
|
-
} as Awaited<ReturnType<typeof submitFlowStepAction>>);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async function walk(cfg: FlowConfig, locale = "en"): Promise<void> {
|
|
105
|
-
render(<FlowStepperClient config={cfg} locale={locale} slug="q3" />);
|
|
106
|
-
await userEvent.setup().click(screen.getByTestId("mock-submit"));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
beforeEach(() => {
|
|
110
|
-
jest.clearAllMocks();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
describe("the ending delivers the deliverable (#8848 D8, AC-5)", () => {
|
|
114
|
-
it("a file response links the reader with its grant, labelled the block's cta", async () => {
|
|
115
|
-
respondWith({ kind: "file", grantId: "dgrant_x" });
|
|
116
|
-
await walk(config());
|
|
117
|
-
|
|
118
|
-
const action = await screen.findByTestId("flow-deliverable-action");
|
|
119
|
-
// `localeHref`: the default locale is unprefixed (`localePrefix: "as-needed"`).
|
|
120
|
-
expect(action.getAttribute("href")).toBe("/reports/q3?g=dgrant_x");
|
|
121
|
-
expect(action.textContent).toBe("Read the report");
|
|
122
|
-
expect(action.closest("[data-sentry-block]")).not.toBeNull();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("prefixes another locale's reader link", async () => {
|
|
126
|
-
respondWith({ kind: "file", grantId: "dgrant_x" });
|
|
127
|
-
await walk(config(), "fr");
|
|
128
|
-
|
|
129
|
-
expect((await screen.findByTestId("flow-deliverable-action")).getAttribute("href")).toBe(
|
|
130
|
-
"/fr/reports/q3?g=dgrant_x",
|
|
131
|
-
);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("a redirect ending never navigates away from the deliverable", async () => {
|
|
135
|
-
respondWith({ kind: "file", grantId: "dgrant_x" });
|
|
136
|
-
await walk(config({ ending: { default: { kind: "redirect", href: "/pricing" } } }));
|
|
137
|
-
|
|
138
|
-
expect(await screen.findByTestId("flow-deliverable-action")).toBeTruthy();
|
|
139
|
-
expect(mockPush).not.toHaveBeenCalled();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it("a screen ending renders first, then the action", async () => {
|
|
143
|
-
respondWith({ kind: "file", grantId: "dgrant_x" });
|
|
144
|
-
await walk(config({ ending: { default: { kind: "screen", headline: en("Done") } } }));
|
|
145
|
-
|
|
146
|
-
const ending = await screen.findByTestId("flow-ending");
|
|
147
|
-
const action = screen.getByTestId("flow-deliverable-action");
|
|
148
|
-
expect(ending.compareDocumentPosition(action) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("a file walk with no deliverable in the response shows the by-email line and no link", async () => {
|
|
152
|
-
respondWith();
|
|
153
|
-
await walk(config());
|
|
154
|
-
|
|
155
|
-
expect(await screen.findByText("reports.fileByEmail")).toBeTruthy();
|
|
156
|
-
expect(screen.queryByTestId("flow-deliverable-action")).toBeNull();
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it("a video response embeds the player", async () => {
|
|
160
|
-
respondWith({ kind: "video", src: "https://cdn.example/v.mp4" });
|
|
161
|
-
await walk(config({ deliverable: { kind: "video", gated: true, title: en("Talk") }, deliverables: undefined }));
|
|
162
|
-
|
|
163
|
-
const box = await screen.findByTestId("flow-deliverable-video");
|
|
164
|
-
await userEvent.setup().click(screen.getByTestId("video-embed-play-button"));
|
|
165
|
-
expect(box.querySelector("video source")?.getAttribute("src")).toBe("https://cdn.example/v.mp4");
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("a page response links the site page", async () => {
|
|
169
|
-
respondWith({ kind: "page", href: "/calc" });
|
|
170
|
-
await walk(config({ deliverable: { kind: "page", gated: true, title: en("Calc") }, deliverables: undefined }));
|
|
171
|
-
|
|
172
|
-
expect((await screen.findByTestId("flow-deliverable-action")).getAttribute("href")).toBe("/calc");
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it.each([
|
|
176
|
-
{ kind: "page", href: "//evil.example" },
|
|
177
|
-
{ kind: "external", href: "javascript:alert(1)" },
|
|
178
|
-
{ kind: "video", src: "http://cdn.example/v.mp4" },
|
|
179
|
-
])("renders no link and no video for an unsafe target: %j", async (deliverable) => {
|
|
180
|
-
respondWith(deliverable);
|
|
181
|
-
await walk(
|
|
182
|
-
config({
|
|
183
|
-
deliverable: { kind: deliverable.kind, gated: true, title: en("X") },
|
|
184
|
-
deliverables: undefined,
|
|
185
|
-
}),
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
await screen.findByTestId("mock-card");
|
|
189
|
-
expect(screen.queryByTestId("flow-deliverable-action")).toBeNull();
|
|
190
|
-
expect(screen.queryByTestId("flow-deliverable-video")).toBeNull();
|
|
191
|
-
expect(document.querySelector("video")).toBeNull();
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// #11013 D-J (AC-3) — a recommending walk with no offers that shows a
|
|
195
|
-
// deliverable keeps it: the deliverable's action renders and no results
|
|
196
|
-
// permalink is pushed.
|
|
197
|
-
it("a recommending walk with no offers keeps its deliverable and pushes no permalink", async () => {
|
|
198
|
-
respondWith({ kind: "file", grantId: "dgrant_x" });
|
|
199
|
-
await walk(config({ mode: "recommending" }));
|
|
200
|
-
|
|
201
|
-
const action = await screen.findByTestId("flow-deliverable-action");
|
|
202
|
-
expect(action.getAttribute("href")).toBe("/reports/q3?g=dgrant_x");
|
|
203
|
-
expect(mockPush).not.toHaveBeenCalled();
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it("a config with no deliverable and no response key renders today's card", async () => {
|
|
207
|
-
respondWith();
|
|
208
|
-
await walk(config({ deliverable: undefined, deliverables: undefined }));
|
|
209
|
-
|
|
210
|
-
await screen.findByTestId("mock-card");
|
|
211
|
-
expect(screen.queryByTestId("flow-deliverable-action")).toBeNull();
|
|
212
|
-
expect(screen.queryByText("reports.fileByEmail")).toBeNull();
|
|
213
|
-
});
|
|
214
|
-
});
|
package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.ending.test.tsx
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
// oss: false
|
|
2
|
-
/**
|
|
3
|
-
* #8840 D9, AC-3 — FlowStepperClient's standard-magnet wiring: the locale's
|
|
4
|
-
* policy links, the input-step count, and the flow's own ending (a screen in
|
|
5
|
-
* the finished card or a redirect to a site path, never `thankYou` once an
|
|
6
|
-
* ending exists). FlowStepper is a stub that records its props, submits the
|
|
7
|
-
* configured steps through the real `onSubmitStep`, and renders the
|
|
8
|
-
* `completedContent` it is given — as the invite test's stub does.
|
|
9
|
-
*/
|
|
10
|
-
import { render, screen, waitFor } from "@testing-library/react";
|
|
11
|
-
import userEvent from "@testing-library/user-event";
|
|
12
|
-
import type { FlowConfig } from "@working-theory/validation";
|
|
13
|
-
import type { ReactElement, ReactNode } from "react";
|
|
14
|
-
|
|
15
|
-
const mockPush = jest.fn();
|
|
16
|
-
jest.mock("next/navigation", () => ({
|
|
17
|
-
useRouter: () => ({ push: mockPush }),
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
|
-
jest.mock("next-intl", () => ({
|
|
21
|
-
useTranslations: () => (key: string) => key,
|
|
22
|
-
useMessages: () => ({}),
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
// eslint-disable-next-line no-restricted-syntax -- the boundary under test is the client wiring, not the actions
|
|
26
|
-
jest.mock("../flow.actions", () => ({ submitFlowStepAction: jest.fn() }));
|
|
27
|
-
// eslint-disable-next-line no-restricted-syntax -- see above
|
|
28
|
-
jest.mock("../account-invite.actions", () => ({ accountInviteLinkAction: jest.fn() }));
|
|
29
|
-
|
|
30
|
-
type Step = { stepKey: string; values: Record<string, unknown> };
|
|
31
|
-
let steps: Step[] = [];
|
|
32
|
-
|
|
33
|
-
interface StubProps {
|
|
34
|
-
onSubmitStep: (payload: Step) => Promise<{ ok: boolean; response?: { completed: boolean } }>;
|
|
35
|
-
onCompleted?: unknown;
|
|
36
|
-
uncountedStepKeys?: readonly string[];
|
|
37
|
-
consentConfig?: { policies: Record<string, string> };
|
|
38
|
-
completedContent?: ReactNode;
|
|
39
|
-
hiddenValues?: Record<string, string>;
|
|
40
|
-
header?: ReactNode;
|
|
41
|
-
}
|
|
42
|
-
let lastProps: StubProps | undefined;
|
|
43
|
-
|
|
44
|
-
jest.mock("@working-theory/ui-signal-collectors", () => ({
|
|
45
|
-
FlowStepper: (props: StubProps) => {
|
|
46
|
-
lastProps = props;
|
|
47
|
-
async function handleSubmit(): Promise<void> {
|
|
48
|
-
for (const step of steps) await props.onSubmitStep(step);
|
|
49
|
-
}
|
|
50
|
-
const react = require("react");
|
|
51
|
-
return react.createElement(
|
|
52
|
-
"div",
|
|
53
|
-
{ "data-testid": "mock-card" },
|
|
54
|
-
react.createElement("button", { "data-testid": "mock-submit", onClick: handleSubmit }, "Submit"),
|
|
55
|
-
props.completedContent,
|
|
56
|
-
) as ReactElement;
|
|
57
|
-
},
|
|
58
|
-
}));
|
|
59
|
-
|
|
60
|
-
import { submitFlowStepAction } from "../flow.actions";
|
|
61
|
-
import { FlowStepperClient } from "../FlowStepperClient";
|
|
62
|
-
|
|
63
|
-
const mockSubmit = submitFlowStepAction as jest.MockedFunction<typeof submitFlowStepAction>;
|
|
64
|
-
const en = (s: string) => ({ en: s });
|
|
65
|
-
|
|
66
|
-
function baseConfig(extra: Partial<FlowConfig> = {}): FlowConfig {
|
|
67
|
-
return {
|
|
68
|
-
slug: "growth",
|
|
69
|
-
defaultLocale: "en",
|
|
70
|
-
steps: [
|
|
71
|
-
{
|
|
72
|
-
key: "about",
|
|
73
|
-
type: "field",
|
|
74
|
-
copy: { title: en("About you") },
|
|
75
|
-
fields: [
|
|
76
|
-
{ name: "first_name", inputType: "text", mapsTo: "givenName", copy: { label: en("First name") } },
|
|
77
|
-
{ name: "email", inputType: "email", required: true, mapsTo: "email", copy: { label: en("Email") } },
|
|
78
|
-
],
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
key: "pace",
|
|
82
|
-
type: "segmentation",
|
|
83
|
-
copy: { title: en("Pace?") },
|
|
84
|
-
questions: [{ name: "pace", options: [{ value: "fast", label: en("Fast") }, { value: "slow", label: en("Slow") }] }],
|
|
85
|
-
},
|
|
86
|
-
{ key: "thanks", type: "message", copy: { title: en("Thanks") } },
|
|
87
|
-
],
|
|
88
|
-
...extra,
|
|
89
|
-
} as FlowConfig;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function completeOn(lastKey: string): void {
|
|
93
|
-
mockSubmit.mockImplementation(async (_slug, payload) => ({
|
|
94
|
-
ok: true,
|
|
95
|
-
response: {
|
|
96
|
-
sessionId: "s1",
|
|
97
|
-
landed: payload.stepKey,
|
|
98
|
-
nextStepKey: null,
|
|
99
|
-
completed: payload.stepKey === lastKey,
|
|
100
|
-
},
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
beforeEach(() => {
|
|
105
|
-
jest.clearAllMocks();
|
|
106
|
-
lastProps = undefined;
|
|
107
|
-
steps = [
|
|
108
|
-
{ stepKey: "about", values: { first_name: "Ana", email: "ana@example.com" } },
|
|
109
|
-
{ stepKey: "pace", values: { pace: "fast" } },
|
|
110
|
-
];
|
|
111
|
-
completeOn("pace");
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
async function walk(config: FlowConfig, locale = "en"): Promise<void> {
|
|
115
|
-
render(<FlowStepperClient config={config} locale={locale} slug={config.slug} />);
|
|
116
|
-
await userEvent.setup().click(screen.getByTestId("mock-submit"));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
describe("the count and the registry (#8840 D9)", () => {
|
|
120
|
-
it("passes every message step's key as uncounted", () => {
|
|
121
|
-
render(<FlowStepperClient config={baseConfig()} locale="en" slug="growth" />);
|
|
122
|
-
expect(lastProps?.uncountedStepKeys).toEqual(["thanks"]);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("localizes the policy links", () => {
|
|
126
|
-
render(<FlowStepperClient config={baseConfig()} locale="fr" slug="growth" />);
|
|
127
|
-
expect(lastProps?.consentConfig?.policies["terms"]).toBe("/fr/terms");
|
|
128
|
-
expect(lastProps?.consentConfig?.policies["privacy"]).toBe("/fr/privacy");
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it("passes hiddenValues and header through", () => {
|
|
132
|
-
render(
|
|
133
|
-
<FlowStepperClient
|
|
134
|
-
config={baseConfig()}
|
|
135
|
-
locale="en"
|
|
136
|
-
slug="growth"
|
|
137
|
-
hiddenValues={{ job: "writer" }}
|
|
138
|
-
header={<span>Back</span>}
|
|
139
|
-
/>,
|
|
140
|
-
);
|
|
141
|
-
expect(lastProps?.hiddenValues).toEqual({ job: "writer" });
|
|
142
|
-
expect(lastProps?.header).toBeDefined();
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
describe("the ending wins (#8840 D9)", () => {
|
|
147
|
-
const screenEnding = {
|
|
148
|
-
default: {
|
|
149
|
-
kind: "screen" as const,
|
|
150
|
-
headline: en("Thanks, {name}."),
|
|
151
|
-
body: en("We'll be in touch."),
|
|
152
|
-
ctas: [
|
|
153
|
-
{ label: en("Book a call"), href: "/meet/intro" },
|
|
154
|
-
// Injected past the schema: the client re-checks every destination.
|
|
155
|
-
{ label: en("Elsewhere"), href: "//evil.example" },
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
it("with an ending and a thankYou, passes no onCompleted", () => {
|
|
161
|
-
render(
|
|
162
|
-
<FlowStepperClient
|
|
163
|
-
config={baseConfig({ ending: screenEnding, thankYou: { default: "thanks" } })}
|
|
164
|
-
locale="en"
|
|
165
|
-
slug="growth"
|
|
166
|
-
/>,
|
|
167
|
-
);
|
|
168
|
-
expect(lastProps?.onCompleted).toBeUndefined();
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("a completing response renders the filled headline and the localized on-site CTA only", async () => {
|
|
172
|
-
await walk(baseConfig({ ending: screenEnding, thankYou: { default: "thanks" } }), "fr");
|
|
173
|
-
await screen.findByTestId("flow-ending");
|
|
174
|
-
expect(screen.getByRole("heading", { level: 2 }).textContent).toBe("Thanks, Ana.");
|
|
175
|
-
const links = screen.getAllByTestId("flow-ending-cta");
|
|
176
|
-
expect(links.map((a) => a.getAttribute("href"))).toEqual(["/fr/meet/intro"]);
|
|
177
|
-
expect(mockPush).not.toHaveBeenCalled();
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it("a redirect ending pushes the locale-prefixed site path", async () => {
|
|
181
|
-
await walk(baseConfig({ ending: { default: { kind: "redirect", href: "/pricing?plan=pro" } } }));
|
|
182
|
-
await waitFor(() => expect(mockPush).toHaveBeenCalledWith("/en/pricing?plan=pro"));
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it("a redirect href injected past the schema is never pushed", async () => {
|
|
186
|
-
await walk(baseConfig({ ending: { default: { kind: "redirect", href: "//evil.example" } } }));
|
|
187
|
-
await waitFor(() => expect(mockSubmit).toHaveBeenCalledTimes(2));
|
|
188
|
-
expect(mockPush).not.toHaveBeenCalled();
|
|
189
|
-
expect(screen.queryByTestId("flow-ending")).toBeNull();
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it("with no ending, nothing new renders and thankYou still navigates", async () => {
|
|
193
|
-
await walk(baseConfig({ thankYou: { default: "thanks" } }));
|
|
194
|
-
expect(lastProps?.completedContent).toBeUndefined();
|
|
195
|
-
expect(typeof lastProps?.onCompleted).toBe("function");
|
|
196
|
-
});
|
|
197
|
-
});
|