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,323 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for /[locale]/account/onboarding — the client's onboarding page
|
|
3
|
-
* (#8515, spec docs/specs/8515-standard-client-onboarding-diagnostic-and-spec.md
|
|
4
|
-
* D12; AC-7).
|
|
5
|
-
*
|
|
6
|
-
* The page runs its real server actions (`onboarding/actions.ts`) against the
|
|
7
|
-
* mocked member read and write, as `popups.test.tsx` runs the New menu's.
|
|
8
|
-
*
|
|
9
|
-
* Covers:
|
|
10
|
-
* 1. With the standard onboarding form (D1's five questions) the page
|
|
11
|
-
* renders a text input `answer.q0`, a radio group `answer.q1` of four
|
|
12
|
-
* options, five checkboxes `answer.q2`, a URL input `answer.q3` and a
|
|
13
|
-
* text input `answer.q4`.
|
|
14
|
-
* 2. Submitting with `q2` checked twice posts `{ answers }` once, the multi
|
|
15
|
-
* answer an array, a blank optional answer omitted, and the sent status
|
|
16
|
-
* replaces the form. One checked box still posts an array.
|
|
17
|
-
* 3. A `409 onboarding_off` refusal shows its copy and keeps the form and
|
|
18
|
-
* every answer.
|
|
19
|
-
* 4. `form: null` shows the unavailable copy and a link back to the
|
|
20
|
-
* locale's account; a failed read shows the error row with Retry.
|
|
21
|
-
* 5. No session is a not-found, and nothing is read.
|
|
22
|
-
*/
|
|
23
|
-
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
|
24
|
-
|
|
25
|
-
jest.mock("next-intl/server", () => {
|
|
26
|
-
const msgs: unknown = require("../../../../../messages/en.json");
|
|
27
|
-
const dig = (obj: unknown, path: string): unknown =>
|
|
28
|
-
path.split(".").reduce<unknown>(
|
|
29
|
-
(acc, k) => (acc !== null && typeof acc === "object" ? (acc as Record<string, unknown>)[k] : undefined),
|
|
30
|
-
obj,
|
|
31
|
-
);
|
|
32
|
-
return {
|
|
33
|
-
__esModule: true,
|
|
34
|
-
getTranslations: async (arg: string | { namespace?: string; locale?: string }) => {
|
|
35
|
-
const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
|
|
36
|
-
const messages = dig(msgs, ns);
|
|
37
|
-
return (key: string, values?: Record<string, unknown>): string => {
|
|
38
|
-
const value = dig(messages, key);
|
|
39
|
-
if (typeof value !== "string") return `${ns}.${key}`;
|
|
40
|
-
return value.replace(/\{(\w+)\}/g, (m, name: string) =>
|
|
41
|
-
values && name in values ? String(values[name]) : m,
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
jest.mock("next/headers", () => ({
|
|
49
|
-
__esModule: true,
|
|
50
|
-
headers: jest.fn().mockResolvedValue(new Headers()),
|
|
51
|
-
cookies: jest.fn().mockResolvedValue({ toString: () => "session=abc" }),
|
|
52
|
-
}));
|
|
53
|
-
|
|
54
|
-
const mockGetSession = jest.fn();
|
|
55
|
-
// eslint-disable-next-line no-restricted-syntax -- #507: mock-internal rewrite pending; auth.ts's lazy Better-Auth singleton has no HTTP/DB boundary a unit test of the session fields can mock without standing up Prisma.
|
|
56
|
-
jest.mock("../../../../../auth", () => ({
|
|
57
|
-
__esModule: true,
|
|
58
|
-
auth: { api: { getSession: (...args: unknown[]) => mockGetSession(...args) } },
|
|
59
|
-
}));
|
|
60
|
-
|
|
61
|
-
const mockMemberOnboarding = jest.fn();
|
|
62
|
-
const mockMemberSubmitOnboarding = jest.fn();
|
|
63
|
-
const mockMemberRequestQuote = jest.fn();
|
|
64
|
-
jest.mock("@working-theory/api-client", () => ({
|
|
65
|
-
__esModule: true,
|
|
66
|
-
waitlistSignups: { me: jest.fn() },
|
|
67
|
-
subscription: { me: jest.fn() },
|
|
68
|
-
member: {
|
|
69
|
-
onboarding: (...args: unknown[]) => mockMemberOnboarding(...args),
|
|
70
|
-
submitOnboarding: (...args: unknown[]) => mockMemberSubmitOnboarding(...args),
|
|
71
|
-
requestQuote: (...args: unknown[]) => mockMemberRequestQuote(...args),
|
|
72
|
-
},
|
|
73
|
-
}));
|
|
74
|
-
|
|
75
|
-
const mockNotFound = jest.fn(() => {
|
|
76
|
-
throw new Error("NEXT_NOT_FOUND");
|
|
77
|
-
});
|
|
78
|
-
const mockRefresh = jest.fn();
|
|
79
|
-
jest.mock("next/navigation", () => ({
|
|
80
|
-
__esModule: true,
|
|
81
|
-
notFound: () => mockNotFound(),
|
|
82
|
-
useRouter: () => ({ push: jest.fn(), refresh: mockRefresh }),
|
|
83
|
-
usePathname: () => "/account/onboarding",
|
|
84
|
-
}));
|
|
85
|
-
|
|
86
|
-
import {
|
|
87
|
-
memberOnboardingFormResponseSchema,
|
|
88
|
-
onboardingFlowConfig,
|
|
89
|
-
type MemberOnboardingFormResponse,
|
|
90
|
-
} from "@working-theory/validation";
|
|
91
|
-
|
|
92
|
-
import Page from "../onboarding/page";
|
|
93
|
-
|
|
94
|
-
const SESSION = {
|
|
95
|
-
user: { id: "user_1", name: "Cleo", email: "cleo@x.io", emailVerified: true },
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/** The cookie a single site forwards (`forwardedCookieInit()`). */
|
|
99
|
-
const INIT = { headers: { cookie: "session=abc" } };
|
|
100
|
-
|
|
101
|
-
/** D1's form as `GET /v1/member/onboarding` serves it (D7). */
|
|
102
|
-
const FORM: MemberOnboardingFormResponse = memberOnboardingFormResponseSchema.parse({
|
|
103
|
-
form: {
|
|
104
|
-
title: "Client onboarding",
|
|
105
|
-
defaultLocale: "en",
|
|
106
|
-
steps: onboardingFlowConfig.steps,
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
const ok = <T,>(body: T) => ({ ok: true, body });
|
|
111
|
-
const refusal = (status: number, code: string) => ({
|
|
112
|
-
ok: false,
|
|
113
|
-
status,
|
|
114
|
-
body: { ok: false, error: { code, message: "x" } },
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
beforeEach(() => {
|
|
118
|
-
mockGetSession.mockReset().mockResolvedValue(SESSION);
|
|
119
|
-
mockMemberOnboarding.mockReset().mockResolvedValue(ok(FORM));
|
|
120
|
-
mockMemberSubmitOnboarding
|
|
121
|
-
.mockReset()
|
|
122
|
-
.mockResolvedValue(ok({ id: "lead_1", createdAt: "2026-10-14T10:00:00.000Z" }));
|
|
123
|
-
mockMemberRequestQuote.mockReset();
|
|
124
|
-
mockNotFound.mockClear();
|
|
125
|
-
mockRefresh.mockReset();
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
async function renderPage(locale = "fr"): Promise<HTMLElement> {
|
|
129
|
-
const element = await Page({ params: Promise.resolve({ locale }) });
|
|
130
|
-
return render(element).container;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function named(container: HTMLElement, name: string): HTMLInputElement[] {
|
|
134
|
-
return Array.from(container.querySelectorAll<HTMLInputElement>(`[name="${name}"]`));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function type(container: HTMLElement, name: string, value: string): void {
|
|
138
|
-
const [control] = named(container, name);
|
|
139
|
-
fireEvent.change(control!, { target: { value } });
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** Answer the four questions the fill cases share; `q4` is left to the case. */
|
|
143
|
-
function answerCommon(container: HTMLElement): void {
|
|
144
|
-
type(container, "answer.q0", "Grow");
|
|
145
|
-
fireEvent.click(screen.getByRole("radio", { name: "This month" }));
|
|
146
|
-
fireEvent.click(screen.getByRole("checkbox", { name: "Content" }));
|
|
147
|
-
fireEvent.click(screen.getByRole("checkbox", { name: "Website" }));
|
|
148
|
-
type(container, "answer.q3", "https://cleo.example");
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
describe("account onboarding page — the controls (AC-7)", () => {
|
|
152
|
-
it("renders one control per question, each named answer.<name>", async () => {
|
|
153
|
-
const container = await renderPage();
|
|
154
|
-
const form = screen.getByTestId("account-onboarding-form");
|
|
155
|
-
|
|
156
|
-
const [q0] = named(container, "answer.q0");
|
|
157
|
-
expect(q0!.tagName).toBe("INPUT");
|
|
158
|
-
expect(q0!.type).toBe("text");
|
|
159
|
-
expect(q0!.required).toBe(true);
|
|
160
|
-
|
|
161
|
-
const group = within(form).getByRole("radiogroup", { name: "When do you want to start?" });
|
|
162
|
-
expect(within(group).getAllByRole("radio").map((r) => r.getAttribute("value"))).toEqual([
|
|
163
|
-
"This week",
|
|
164
|
-
"This month",
|
|
165
|
-
"Later this quarter",
|
|
166
|
-
"Just exploring",
|
|
167
|
-
]);
|
|
168
|
-
expect(named(container, "answer.q1")).toHaveLength(4);
|
|
169
|
-
|
|
170
|
-
const boxes = within(form).getByRole("group", { name: "Where do you want help?" });
|
|
171
|
-
expect(within(boxes).getAllByRole("checkbox")).toHaveLength(5);
|
|
172
|
-
expect(named(container, "answer.q2")).toHaveLength(5);
|
|
173
|
-
expect(named(container, "answer.q2").every((input) => input.type === "checkbox")).toBe(true);
|
|
174
|
-
|
|
175
|
-
const [q3] = named(container, "answer.q3");
|
|
176
|
-
expect(q3!.tagName).toBe("INPUT");
|
|
177
|
-
expect(q3!.inputMode).toBe("url");
|
|
178
|
-
expect(screen.getByText("Must start with https://.")).toBeInTheDocument();
|
|
179
|
-
|
|
180
|
-
const [q4] = named(container, "answer.q4");
|
|
181
|
-
expect(q4!.tagName).toBe("INPUT");
|
|
182
|
-
expect(q4!.type).toBe("text");
|
|
183
|
-
|
|
184
|
-
expect(screen.getByLabelText("What do you most want from working with us?")).toBe(q0);
|
|
185
|
-
expect(screen.getByLabelText(/Your website/)).toBe(q3);
|
|
186
|
-
expect(mockMemberOnboarding).toHaveBeenCalledWith(INIT);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
describe("account onboarding page — submitting (AC-7)", () => {
|
|
191
|
-
it("posts the answers once, q2 as an array, and shows the sent status", async () => {
|
|
192
|
-
const container = await renderPage();
|
|
193
|
-
answerCommon(container);
|
|
194
|
-
type(container, "answer.q4", "Thanks");
|
|
195
|
-
fireEvent.click(screen.getByTestId("account-onboarding-submit"));
|
|
196
|
-
|
|
197
|
-
const sent = await screen.findByTestId("account-onboarding-sent");
|
|
198
|
-
expect(sent).toHaveAttribute("role", "status");
|
|
199
|
-
expect(sent).toHaveTextContent("Thank you — your answers were sent.");
|
|
200
|
-
expect(screen.queryByTestId("account-onboarding-form")).not.toBeInTheDocument();
|
|
201
|
-
|
|
202
|
-
expect(mockMemberSubmitOnboarding).toHaveBeenCalledTimes(1);
|
|
203
|
-
expect(mockMemberSubmitOnboarding).toHaveBeenCalledWith(
|
|
204
|
-
{
|
|
205
|
-
answers: {
|
|
206
|
-
q0: "Grow",
|
|
207
|
-
q1: "This month",
|
|
208
|
-
q2: ["Content", "Website"],
|
|
209
|
-
q3: "https://cleo.example",
|
|
210
|
-
q4: "Thanks",
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
INIT,
|
|
214
|
-
);
|
|
215
|
-
expect(mockMemberRequestQuote).not.toHaveBeenCalled();
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it("omits a blank optional answer", async () => {
|
|
219
|
-
const container = await renderPage();
|
|
220
|
-
answerCommon(container);
|
|
221
|
-
type(container, "answer.q4", " ");
|
|
222
|
-
fireEvent.click(screen.getByTestId("account-onboarding-submit"));
|
|
223
|
-
|
|
224
|
-
await screen.findByTestId("account-onboarding-sent");
|
|
225
|
-
expect(mockMemberSubmitOnboarding).toHaveBeenCalledTimes(1);
|
|
226
|
-
expect(mockMemberSubmitOnboarding.mock.calls[0]![0]).toEqual({
|
|
227
|
-
answers: {
|
|
228
|
-
q0: "Grow",
|
|
229
|
-
q1: "This month",
|
|
230
|
-
q2: ["Content", "Website"],
|
|
231
|
-
q3: "https://cleo.example",
|
|
232
|
-
},
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it("posts one checked box of a multi question as an array", async () => {
|
|
237
|
-
const container = await renderPage();
|
|
238
|
-
type(container, "answer.q0", "Grow");
|
|
239
|
-
fireEvent.click(screen.getByRole("radio", { name: "This week" }));
|
|
240
|
-
fireEvent.click(screen.getByRole("checkbox", { name: "Sales" }));
|
|
241
|
-
fireEvent.click(screen.getByTestId("account-onboarding-submit"));
|
|
242
|
-
|
|
243
|
-
await screen.findByTestId("account-onboarding-sent");
|
|
244
|
-
expect(mockMemberSubmitOnboarding.mock.calls[0]![0]).toEqual({
|
|
245
|
-
answers: { q0: "Grow", q1: "This week", q2: ["Sales"] },
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it("a 409 onboarding_off shows its copy and keeps the form and every answer", async () => {
|
|
250
|
-
mockMemberSubmitOnboarding.mockResolvedValue(refusal(409, "onboarding_off"));
|
|
251
|
-
const container = await renderPage();
|
|
252
|
-
answerCommon(container);
|
|
253
|
-
fireEvent.click(screen.getByTestId("account-onboarding-submit"));
|
|
254
|
-
|
|
255
|
-
const error = await screen.findByTestId("account-onboarding-error");
|
|
256
|
-
expect(error).toHaveTextContent("Onboarding isn't open to you here right now.");
|
|
257
|
-
expect(screen.getByTestId("account-onboarding-form")).toBeInTheDocument();
|
|
258
|
-
expect(screen.queryByTestId("account-onboarding-sent")).not.toBeInTheDocument();
|
|
259
|
-
expect(named(container, "answer.q0")[0]!.value).toBe("Grow");
|
|
260
|
-
expect(screen.getByRole("radio", { name: "This month" })).toHaveAttribute("aria-checked", "true");
|
|
261
|
-
expect(screen.getByRole("checkbox", { name: "Content" })).toHaveAttribute("aria-checked", "true");
|
|
262
|
-
expect(named(container, "answer.q3")[0]!.value).toBe("https://cleo.example");
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
it.each([
|
|
266
|
-
["answers_invalid", 400, "Some answers do not fit these questions. Check them and try again."],
|
|
267
|
-
["link_not_https", 400, "A link must start with https://."],
|
|
268
|
-
["too_many_requests", 429, "Too many submissions. Try again later."],
|
|
269
|
-
["something_else", 500, "Your answers could not be sent. Try again."],
|
|
270
|
-
])("a %s refusal shows its own copy", async (code, status, copy) => {
|
|
271
|
-
mockMemberSubmitOnboarding.mockResolvedValue(refusal(status, code));
|
|
272
|
-
const container = await renderPage();
|
|
273
|
-
answerCommon(container);
|
|
274
|
-
fireEvent.click(screen.getByTestId("account-onboarding-submit"));
|
|
275
|
-
|
|
276
|
-
await waitFor(() =>
|
|
277
|
-
expect(screen.getByTestId("account-onboarding-error")).toHaveTextContent(copy),
|
|
278
|
-
);
|
|
279
|
-
expect(screen.getByTestId("account-onboarding-form")).toBeInTheDocument();
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
describe("account onboarding page — the other states", () => {
|
|
284
|
-
it("form: null shows the unavailable copy and a link back to the locale's account", async () => {
|
|
285
|
-
mockMemberOnboarding.mockResolvedValue(ok({ form: null }));
|
|
286
|
-
await renderPage("fr");
|
|
287
|
-
expect(screen.getByTestId("account-onboarding-unavailable")).toHaveTextContent(
|
|
288
|
-
"Onboarding isn't open to you here right now.",
|
|
289
|
-
);
|
|
290
|
-
expect(screen.getByRole("link", { name: "Back to your account" })).toHaveAttribute(
|
|
291
|
-
"href",
|
|
292
|
-
"/fr/account",
|
|
293
|
-
);
|
|
294
|
-
expect(screen.queryByTestId("account-onboarding-form")).not.toBeInTheDocument();
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
it("a 404 read (no member area) is the unavailable state, not an error", async () => {
|
|
298
|
-
mockMemberOnboarding.mockResolvedValue(refusal(404, "not_found"));
|
|
299
|
-
await renderPage();
|
|
300
|
-
expect(screen.getByTestId("account-onboarding-unavailable")).toBeInTheDocument();
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
it("a failed read renders the error row with Retry", async () => {
|
|
304
|
-
mockMemberOnboarding.mockResolvedValue(refusal(503, "tenant_unresolved"));
|
|
305
|
-
await renderPage();
|
|
306
|
-
expect(screen.getByTestId("inbox-error")).toHaveTextContent(
|
|
307
|
-
"We couldn't load your onboarding questions.",
|
|
308
|
-
);
|
|
309
|
-
expect(screen.queryByTestId("account-onboarding-form")).not.toBeInTheDocument();
|
|
310
|
-
fireEvent.click(screen.getByTestId("inbox-retry"));
|
|
311
|
-
expect(mockRefresh).toHaveBeenCalledTimes(1);
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
it("no session renders the heading alone — never a not-found over the sign-in gate — and reads nothing", async () => {
|
|
315
|
-
mockGetSession.mockResolvedValue(null);
|
|
316
|
-
await renderPage();
|
|
317
|
-
expect(mockNotFound).not.toHaveBeenCalled();
|
|
318
|
-
expect(screen.getByTestId("account-onboarding")).toHaveTextContent("Onboarding");
|
|
319
|
-
expect(screen.queryByTestId("account-onboarding-form")).not.toBeInTheDocument();
|
|
320
|
-
expect(screen.queryByTestId("account-onboarding-unavailable")).not.toBeInTheDocument();
|
|
321
|
-
expect(mockMemberOnboarding).not.toHaveBeenCalled();
|
|
322
|
-
});
|
|
323
|
-
});
|