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,758 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The account area on a spoke that signs in through its hub (#7894 D10, D12;
|
|
3
|
-
* spec docs/specs/7894-the-hub-signs-in-its-spec.md AC-5, AC-7).
|
|
4
|
-
*
|
|
5
|
-
* The generated web seam is mocked to its `signIn: "hub"` render: the
|
|
6
|
-
* session comes from `readSession`, `forwardedCookieInit()` re-targets to the
|
|
7
|
-
* hub credential, and `SIGN_IN_PROVIDER` is `"hub"`. It sits under
|
|
8
|
-
* `account/__tests__`, which a hub-mode spoke drops with the other account
|
|
9
|
-
* suites (spec 7894 D9), so it runs in this monorepo only.
|
|
10
|
-
*
|
|
11
|
-
* Covers:
|
|
12
|
-
* - AC-7: with the hub answering 404 to every read (the hub credential
|
|
13
|
-
* is admitted on none of them, D6), `loadInboxItems` loads `[]` with
|
|
14
|
-
* `failed` false — an empty Inbox, never an error row — and every read
|
|
15
|
-
* carries the Bearer credential, not a cookie. The purchase and
|
|
16
|
-
* appointment kinds read `member.purchases` and `member.appointments`,
|
|
17
|
-
* never `flowCheckouts.me` (#8231 D5–D7).
|
|
18
|
-
* - AC-5, as #8232 rewrites it (spec
|
|
19
|
-
* docs/specs/8232-member-settings-account-general-and-spec.md D2–D7, D9;
|
|
20
|
-
* its AC-2 and AC-7): General no longer links to the hub's settings.
|
|
21
|
-
* Where the hub answers the member routes, the name and photo go through
|
|
22
|
-
* the member API with the Bearer credential, and a save re-seals the
|
|
23
|
-
* session cookie; where it answers none (the fixture's 404), the name is
|
|
24
|
-
* read-only. (The deletion request left Privacy in #11164.) Billing says
|
|
25
|
-
* there is no subscription without reading `subscription.me`.
|
|
26
|
-
* - #8217 AC-1 (spec docs/specs/8217-spoke-billing-spoke-checkout-reads-spec.md
|
|
27
|
-
* D10–D12): Billing reads the seam's `loadSpokeBilling` — the plan, the
|
|
28
|
-
* card and Manage billing for a subscription; the plain none line with
|
|
29
|
-
* no button for none or a spoke without the action (`null`); the
|
|
30
|
-
* unreadable line; the error row for a failed read — and never calls
|
|
31
|
-
* `subscription.me` or `member.billing` itself. `openBillingPortal`
|
|
32
|
-
* redirects to the loader's portal URL, and to nothing without one.
|
|
33
|
-
* - #8431 AC-4 (spec docs/specs/8431-account-security-tab-human-sign-spec.md
|
|
34
|
-
* D1–D3), as #11162 rewrites it: Security's Log out POSTs the spoke's
|
|
35
|
-
* sign-out endpoint, never Better Auth, and lands on `/account` only
|
|
36
|
-
* when it succeeded. The panel itself — the Password row read from the
|
|
37
|
-
* hub, in place of the retired "managed at <hub>" pointer — is pinned
|
|
38
|
-
* beside the route, in `security/__tests__/hub-variant.test.tsx`.
|
|
39
|
-
*/
|
|
40
|
-
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
41
|
-
import { tmpdir } from "node:os";
|
|
42
|
-
import { join } from "node:path";
|
|
43
|
-
|
|
44
|
-
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
|
45
|
-
|
|
46
|
-
jest.mock("next-intl/server", () => {
|
|
47
|
-
const msgs: unknown = require("../../../../../messages/en.json");
|
|
48
|
-
const dig = (obj: unknown, path: string): unknown =>
|
|
49
|
-
path.split(".").reduce<unknown>(
|
|
50
|
-
(acc, k) => (acc !== null && typeof acc === "object" ? (acc as Record<string, unknown>)[k] : undefined),
|
|
51
|
-
obj,
|
|
52
|
-
);
|
|
53
|
-
return {
|
|
54
|
-
__esModule: true,
|
|
55
|
-
getTranslations: async (arg: string | { namespace?: string; locale?: string }) => {
|
|
56
|
-
const ns = typeof arg === "string" ? arg : (arg.namespace ?? "");
|
|
57
|
-
const messages = dig(msgs, ns);
|
|
58
|
-
const t = (key: string, values?: Record<string, unknown>): string => {
|
|
59
|
-
const value = dig(messages, key);
|
|
60
|
-
if (typeof value !== "string") return `${ns}.${key}`;
|
|
61
|
-
return value.replace(/\{(\w+)\}/g, (m, name: string) =>
|
|
62
|
-
values && name in values ? String(values[name]) : m,
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
// #11164: Privacy's lead is a `t.rich` message with a `<policy>` tag.
|
|
66
|
-
const { withRich } = require("./rich-translator") as typeof import("./rich-translator");
|
|
67
|
-
return withRich(t, (key: string) => dig(messages, key), ns);
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const mockHeaders = jest.fn();
|
|
73
|
-
const mockCookieSet = jest.fn();
|
|
74
|
-
jest.mock("next/headers", () => ({
|
|
75
|
-
__esModule: true,
|
|
76
|
-
headers: (...args: unknown[]) => mockHeaders(...args),
|
|
77
|
-
cookies: jest.fn().mockImplementation(async () => ({
|
|
78
|
-
toString: () => "",
|
|
79
|
-
set: (...args: unknown[]) => mockCookieSet(...args),
|
|
80
|
-
})),
|
|
81
|
-
}));
|
|
82
|
-
|
|
83
|
-
const mockReadSession = jest.fn();
|
|
84
|
-
const mockLoadSpokeBilling = jest.fn();
|
|
85
|
-
const mockReadOwnAccounts = jest.fn();
|
|
86
|
-
// eslint-disable-next-line no-restricted-syntax -- #507: the seam is generated per build (#7894 D8); its `signIn: "hub"` render is the boundary under test, and no env or HTTP surface selects it.
|
|
87
|
-
jest.mock("../../../../../lib/topology.generated", () => ({
|
|
88
|
-
__esModule: true,
|
|
89
|
-
TOPOLOGY: "spoke",
|
|
90
|
-
SIGN_IN_ENABLED: true,
|
|
91
|
-
SIGN_IN_PROVIDER: "hub",
|
|
92
|
-
SIGN_IN_PATH: "/account",
|
|
93
|
-
SIGN_UP_PATH: null,
|
|
94
|
-
SIGN_OUT_ENDPOINT: "/api/hub-session/sign-out",
|
|
95
|
-
readSession: (...args: unknown[]) => mockReadSession(...args),
|
|
96
|
-
registerSiteStores: () => Promise.resolve(),
|
|
97
|
-
// #8217 D7 — the billing render's loader; `null` is a spoke without the action.
|
|
98
|
-
loadSpokeBilling: (...args: unknown[]) => mockLoadSpokeBilling(...args),
|
|
99
|
-
// #8431 D2a — a spoke has no local accounts; Security must never ask.
|
|
100
|
-
readOwnAccounts: (...args: unknown[]) => mockReadOwnAccounts(...args),
|
|
101
|
-
}));
|
|
102
|
-
|
|
103
|
-
const mockLeadsSubmit = jest.fn();
|
|
104
|
-
const notFound = { ok: false, status: 404, body: { ok: false, error: { code: "not_found", message: "Not found" } } };
|
|
105
|
-
const mockWaitlistMe = jest.fn();
|
|
106
|
-
const mockFlowCheckoutsMe = jest.fn();
|
|
107
|
-
const mockSubscriptionMe = jest.fn();
|
|
108
|
-
const mockMemberRead = jest.fn();
|
|
109
|
-
const mockMemberPurchases = jest.fn();
|
|
110
|
-
const mockMemberAppointments = jest.fn();
|
|
111
|
-
const mockUpdateProfile = jest.fn();
|
|
112
|
-
const mockMemberProfile = jest.fn();
|
|
113
|
-
const mockMemberContact = jest.fn();
|
|
114
|
-
const mockUpdateContact = jest.fn();
|
|
115
|
-
const mockHubMe = jest.fn();
|
|
116
|
-
const mockMemberBilling = jest.fn();
|
|
117
|
-
const mockMemberBillingPortal = jest.fn();
|
|
118
|
-
const mockOfferingsShown = jest.fn();
|
|
119
|
-
const mockPortalSession = jest.fn();
|
|
120
|
-
jest.mock("@working-theory/api-client", () => ({
|
|
121
|
-
__esModule: true,
|
|
122
|
-
waitlistSignups: { me: (...args: unknown[]) => mockWaitlistMe(...args) },
|
|
123
|
-
flowCheckouts: { me: (...args: unknown[]) => mockFlowCheckoutsMe(...args) },
|
|
124
|
-
subscription: {
|
|
125
|
-
me: (...args: unknown[]) => mockSubscriptionMe(...args),
|
|
126
|
-
portalSession: (...args: unknown[]) => mockPortalSession(...args),
|
|
127
|
-
},
|
|
128
|
-
leads: { submit: (...args: unknown[]) => mockLeadsSubmit(...args) },
|
|
129
|
-
// #7920 — the member kinds read the hub with the credential; 404 here.
|
|
130
|
-
member: {
|
|
131
|
-
pieces: (...args: unknown[]) => mockMemberRead(...args),
|
|
132
|
-
messages: (...args: unknown[]) => mockMemberRead(...args),
|
|
133
|
-
// #11157 — the member's own sent requests, read like the other member kinds.
|
|
134
|
-
requests: (...args: unknown[]) => mockMemberRead(...args),
|
|
135
|
-
// #11150 — the onboarding-steps read.
|
|
136
|
-
welcome: (...args: unknown[]) => mockMemberRead(...args),
|
|
137
|
-
purchases: (...args: unknown[]) => mockMemberPurchases(...args),
|
|
138
|
-
appointments: (...args: unknown[]) => mockMemberAppointments(...args),
|
|
139
|
-
// #10826 D7 — the user-magnet results read; 404 here (no workspace module).
|
|
140
|
-
results: () =>
|
|
141
|
-
Promise.resolve({
|
|
142
|
-
ok: false,
|
|
143
|
-
status: 404,
|
|
144
|
-
body: { ok: false, error: { code: "not_found", message: "Not found" } },
|
|
145
|
-
}),
|
|
146
|
-
updateProfile: (...args: unknown[]) => mockUpdateProfile(...args),
|
|
147
|
-
// #11167 — the member profile read General's photo comes from, and the
|
|
148
|
-
// contact read and write the account name follows.
|
|
149
|
-
profile: (...args: unknown[]) => mockMemberProfile(...args),
|
|
150
|
-
contact: (...args: unknown[]) => mockMemberContact(...args),
|
|
151
|
-
updateContact: (...args: unknown[]) => mockUpdateContact(...args),
|
|
152
|
-
// #11165 — the hub's read of the member's plan, History and portal.
|
|
153
|
-
billing: (...args: unknown[]) => mockMemberBilling(...args),
|
|
154
|
-
billingPortal: (...args: unknown[]) => mockMemberBillingPortal(...args),
|
|
155
|
-
},
|
|
156
|
-
// #11165 — the shown set's base plan, Upgrade target and offer; unconnected here.
|
|
157
|
-
offerings: { shown: (...args: unknown[]) => mockOfferingsShown(...args) },
|
|
158
|
-
visitorForwardHeaders: () => null,
|
|
159
|
-
hubSignIn: { me: (...args: unknown[]) => mockHubMe(...args) },
|
|
160
|
-
}));
|
|
161
|
-
|
|
162
|
-
const mockUpdateUser = jest.fn();
|
|
163
|
-
const mockSignOut = jest.fn();
|
|
164
|
-
jest.mock("better-auth/react", () => ({
|
|
165
|
-
__esModule: true,
|
|
166
|
-
createAuthClient: () => ({
|
|
167
|
-
signOut: (...args: unknown[]) => mockSignOut(...args),
|
|
168
|
-
updateUser: (...args: unknown[]) => mockUpdateUser(...args),
|
|
169
|
-
}),
|
|
170
|
-
}));
|
|
171
|
-
|
|
172
|
-
const mockRedirect = jest.fn();
|
|
173
|
-
const mockPush = jest.fn();
|
|
174
|
-
jest.mock("next/navigation", () => ({
|
|
175
|
-
__esModule: true,
|
|
176
|
-
useRouter: () => ({ push: mockPush, refresh: jest.fn(), replace: jest.fn() }),
|
|
177
|
-
usePathname: () => "/account/general",
|
|
178
|
-
redirect: (...args: unknown[]) => mockRedirect(...args),
|
|
179
|
-
}));
|
|
180
|
-
|
|
181
|
-
import { seal, unseal } from "../../../../../lib/hub-session/seal";
|
|
182
|
-
import { accountSession, loadInboxItems } from "../account-data";
|
|
183
|
-
import { openBillingPortal } from "../actions";
|
|
184
|
-
import GeneralPage from "../general/page";
|
|
185
|
-
import { submitSupportRequest } from "../support-actions";
|
|
186
|
-
|
|
187
|
-
const HUB = "https://hub.example.com";
|
|
188
|
-
const SESSION_SECRET = "s".repeat(43);
|
|
189
|
-
const CREDENTIAL = `ailk_hst_${"t".repeat(43)}`;
|
|
190
|
-
const USER = {
|
|
191
|
-
name: "Ada Lovelace",
|
|
192
|
-
email: "ada@example.com",
|
|
193
|
-
emailVerified: true,
|
|
194
|
-
createdAt: "2026-09-01T00:00:00.000Z",
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const ENV = process.env;
|
|
198
|
-
let contentRoot: string;
|
|
199
|
-
|
|
200
|
-
beforeEach(() => {
|
|
201
|
-
contentRoot = mkdtempSync(join(tmpdir(), "ailk-hub-mode-"));
|
|
202
|
-
writeFileSync(join(contentRoot, "_site.mdx"), '---\nsiteName: "Test"\n---\n');
|
|
203
|
-
process.env = {
|
|
204
|
-
...ENV,
|
|
205
|
-
AILK_CONTENT_ROOT: contentRoot,
|
|
206
|
-
AILK_HUB_SIGN_IN_URL: HUB,
|
|
207
|
-
AILK_HUB_CLIENT_ID: "spoke_0001",
|
|
208
|
-
AILK_HUB_CLIENT_SECRET: `ailk_hcs_${"c".repeat(43)}`,
|
|
209
|
-
AILK_HUB_SESSION_SECRET: SESSION_SECRET,
|
|
210
|
-
NEXT_PUBLIC_BASE_URL: "https://spoke.example.com",
|
|
211
|
-
};
|
|
212
|
-
const sealed = seal(
|
|
213
|
-
{ v: 1, accessToken: CREDENTIAL, expiresAt: Date.now() + 60_000, user: USER },
|
|
214
|
-
SESSION_SECRET,
|
|
215
|
-
"session",
|
|
216
|
-
"__Host-ailk-hub-session",
|
|
217
|
-
);
|
|
218
|
-
mockHeaders.mockReset().mockResolvedValue(new Headers({ cookie: `__Host-ailk-hub-session=${sealed}` }));
|
|
219
|
-
mockReadSession.mockReset().mockResolvedValue({ user: USER });
|
|
220
|
-
mockWaitlistMe.mockReset().mockResolvedValue(notFound);
|
|
221
|
-
mockFlowCheckoutsMe.mockReset().mockResolvedValue(notFound);
|
|
222
|
-
mockSubscriptionMe.mockReset().mockResolvedValue(notFound);
|
|
223
|
-
mockMemberRead.mockReset().mockResolvedValue(notFound);
|
|
224
|
-
mockMemberPurchases.mockReset().mockResolvedValue(notFound);
|
|
225
|
-
mockMemberAppointments.mockReset().mockResolvedValue(notFound);
|
|
226
|
-
mockUpdateProfile.mockReset();
|
|
227
|
-
mockMemberProfile.mockReset().mockResolvedValue(notFound);
|
|
228
|
-
mockMemberContact.mockReset().mockResolvedValue(notFound);
|
|
229
|
-
mockUpdateContact.mockReset().mockResolvedValue(notFound);
|
|
230
|
-
mockHubMe.mockReset();
|
|
231
|
-
mockLoadSpokeBilling.mockReset().mockResolvedValue(null);
|
|
232
|
-
mockMemberBilling.mockReset().mockResolvedValue(notFound);
|
|
233
|
-
mockMemberBillingPortal.mockReset().mockResolvedValue(notFound);
|
|
234
|
-
mockOfferingsShown.mockReset().mockResolvedValue({ ok: true, body: { status: "unconnected" } });
|
|
235
|
-
mockPortalSession.mockReset();
|
|
236
|
-
mockRedirect.mockReset();
|
|
237
|
-
mockCookieSet.mockReset();
|
|
238
|
-
mockUpdateUser.mockReset();
|
|
239
|
-
mockReadOwnAccounts.mockReset().mockResolvedValue(null);
|
|
240
|
-
mockSignOut.mockReset();
|
|
241
|
-
mockPush.mockReset();
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
afterEach(() => {
|
|
245
|
-
rmSync(contentRoot, { recursive: true, force: true });
|
|
246
|
-
process.env = ENV;
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
describe("AC-7 — the base Inbox kinds on a hub-mode spoke", () => {
|
|
250
|
-
it("loads [] for every kind, with failed false, when the hub answers 404", async () => {
|
|
251
|
-
const session = await accountSession("en");
|
|
252
|
-
if (session === null) throw new Error("expected a session");
|
|
253
|
-
expect(session.ctx.init).toEqual({ headers: { authorization: `Bearer ${CREDENTIAL}` } });
|
|
254
|
-
|
|
255
|
-
const inbox = await loadInboxItems(session.ctx);
|
|
256
|
-
expect(inbox).toEqual({ items: [], failed: false });
|
|
257
|
-
const bearer = { headers: { authorization: `Bearer ${CREDENTIAL}` } };
|
|
258
|
-
expect(mockMemberPurchases).toHaveBeenCalledWith(bearer);
|
|
259
|
-
expect(mockMemberAppointments).toHaveBeenCalledWith(bearer);
|
|
260
|
-
expect(mockFlowCheckoutsMe).not.toHaveBeenCalled();
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
it("has no session when the seam reads none", async () => {
|
|
264
|
-
mockReadSession.mockResolvedValue(null);
|
|
265
|
-
await expect(accountSession("en")).resolves.toBeNull();
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
describe("AC-5 — General and Billing on a hub-mode spoke (#8232)", () => {
|
|
270
|
-
const bearer = { headers: { authorization: `Bearer ${CREDENTIAL}` } };
|
|
271
|
-
|
|
272
|
-
async function renderGeneral(): Promise<void> {
|
|
273
|
-
render(await GeneralPage({ params: Promise.resolve({ locale: "en" }) }));
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
describe("a hub that answers the member routes", () => {
|
|
277
|
-
beforeEach(() => {
|
|
278
|
-
mockMemberRead.mockResolvedValue({ ok: true, body: [] });
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it("renders the photo form with the hub's photo and no Name field, with no link to the hub's settings (#11167)", async () => {
|
|
282
|
-
// The session carries no photo (C5); the member profile read, with the
|
|
283
|
-
// Bearer credential, brings the hub's (#11167 ruling 4).
|
|
284
|
-
mockMemberProfile.mockResolvedValue({
|
|
285
|
-
ok: true,
|
|
286
|
-
body: { name: "Ada Lovelace", image: "https://lh3.googleusercontent.com/a/ada" },
|
|
287
|
-
});
|
|
288
|
-
await renderGeneral();
|
|
289
|
-
expect(screen.getByTestId("account-general-form")).toBeInTheDocument();
|
|
290
|
-
expect(screen.queryByLabelText("Name")).not.toBeInTheDocument();
|
|
291
|
-
expect(screen.getByLabelText("Photo")).toHaveValue("https://lh3.googleusercontent.com/a/ada");
|
|
292
|
-
expect(mockMemberProfile).toHaveBeenCalledWith(bearer);
|
|
293
|
-
expect(screen.queryByTestId("account-settings-manage-on-hub")).not.toBeInTheDocument();
|
|
294
|
-
expect(screen.queryByTestId("account-privacy-manage-on-hub")).not.toBeInTheDocument();
|
|
295
|
-
expect(document.querySelector(`a[href^="${HUB}"]`)).toBeNull();
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
it("a hub whose member profile read fails leaves the photo field empty", async () => {
|
|
299
|
-
await renderGeneral();
|
|
300
|
-
expect(screen.getByLabelText("Photo")).toHaveValue("");
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
it("saves the photo alone through member.updateProfile with the Bearer credential; no re-seal, the session carries no photo", async () => {
|
|
304
|
-
const photo = "https://cdn.example.com/ada.png";
|
|
305
|
-
mockUpdateProfile.mockResolvedValue({ ok: true, body: { name: "Ada Lovelace", image: photo } });
|
|
306
|
-
await renderGeneral();
|
|
307
|
-
fireEvent.change(screen.getByLabelText("Photo"), { target: { value: photo } });
|
|
308
|
-
await act(async () => {
|
|
309
|
-
fireEvent.click(screen.getByTestId("account-general-save"));
|
|
310
|
-
});
|
|
311
|
-
expect(mockUpdateProfile).toHaveBeenCalledWith({ image: photo }, bearer);
|
|
312
|
-
expect(mockUpdateUser).not.toHaveBeenCalled();
|
|
313
|
-
expect(mockHubMe).not.toHaveBeenCalled();
|
|
314
|
-
expect(mockCookieSet).not.toHaveBeenCalled();
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
it("a contact save that derives the account name writes it through member.updateProfile with the Bearer credential, then re-seals the session", async () => {
|
|
318
|
-
const { saveContact } = await import("../general/contact-actions");
|
|
319
|
-
// The hub's stored "Ada Lovelace" (read with the Bearer credential, never
|
|
320
|
-
// the sealed cookie's copy) is what the previous contact derived, so it
|
|
321
|
-
// follows the new names; a hand-set name would not (general.test.tsx).
|
|
322
|
-
mockMemberProfile.mockResolvedValue({ ok: true, body: { name: "Ada Lovelace", image: null } });
|
|
323
|
-
mockMemberContact.mockResolvedValue({
|
|
324
|
-
ok: true,
|
|
325
|
-
body: {
|
|
326
|
-
contact: {
|
|
327
|
-
givenName: "Ada",
|
|
328
|
-
familyName: "Lovelace",
|
|
329
|
-
telephone: null,
|
|
330
|
-
address: null,
|
|
331
|
-
companyName: null,
|
|
332
|
-
jobTitle: null,
|
|
333
|
-
},
|
|
334
|
-
},
|
|
335
|
-
});
|
|
336
|
-
mockUpdateContact.mockResolvedValue({
|
|
337
|
-
ok: true,
|
|
338
|
-
body: {
|
|
339
|
-
contact: {
|
|
340
|
-
givenName: "Ada",
|
|
341
|
-
familyName: "King",
|
|
342
|
-
telephone: null,
|
|
343
|
-
address: null,
|
|
344
|
-
companyName: null,
|
|
345
|
-
jobTitle: null,
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
});
|
|
349
|
-
mockUpdateProfile.mockResolvedValue({ ok: true, body: { name: "Ada King", image: null } });
|
|
350
|
-
mockHubMe.mockResolvedValue({ ok: true, body: { user: { ...USER, name: "Ada King" }, billingCustomerId: null } });
|
|
351
|
-
await expect(
|
|
352
|
-
saveContact({
|
|
353
|
-
givenName: "Ada",
|
|
354
|
-
familyName: "King",
|
|
355
|
-
telephone: null,
|
|
356
|
-
address: null,
|
|
357
|
-
companyName: null,
|
|
358
|
-
jobTitle: null,
|
|
359
|
-
}),
|
|
360
|
-
).resolves.toEqual({ ok: true });
|
|
361
|
-
expect(mockMemberProfile).toHaveBeenCalledWith(bearer);
|
|
362
|
-
expect(mockUpdateProfile).toHaveBeenCalledWith({ name: "Ada King" }, bearer);
|
|
363
|
-
expect(mockHubMe).toHaveBeenCalledWith(bearer);
|
|
364
|
-
expect(mockCookieSet).toHaveBeenCalledTimes(1);
|
|
365
|
-
const [name, value] = mockCookieSet.mock.calls[0] as [string, string];
|
|
366
|
-
expect(name).toBe("__Host-ailk-hub-session");
|
|
367
|
-
expect(unseal(value, SESSION_SECRET, "session", name)).toMatchObject({
|
|
368
|
-
accessToken: CREDENTIAL,
|
|
369
|
-
user: { name: "Ada King" },
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
describe("a hub that answers no member route (the fixture's 404)", () => {
|
|
375
|
-
it("shows the name read-only and offers no save", async () => {
|
|
376
|
-
await renderGeneral();
|
|
377
|
-
expect(screen.getByTestId("account-general-name-text")).toHaveTextContent("Ada Lovelace");
|
|
378
|
-
expect(screen.queryByTestId("account-general-form")).not.toBeInTheDocument();
|
|
379
|
-
expect(screen.queryByLabelText("Photo")).not.toBeInTheDocument();
|
|
380
|
-
expect(document.querySelector(`a[href^="${HUB}"]`)).toBeNull();
|
|
381
|
-
expect(mockUpdateUser).not.toHaveBeenCalled();
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
// #11194 — the Your data table's two member routes are hub-admitted
|
|
386
|
-
// (`GET /v1/member/data-export`, `POST /v1/member/stored-sessions/delete`
|
|
387
|
-
// in HUB_SESSION_ROUTES), so a spoke that signs in through its hub renders
|
|
388
|
-
// the same table as a site with its own sign-in: Export data and Delete
|
|
389
|
-
// stored sessions, never the #11164 unavailable line. The Support pointer
|
|
390
|
-
// for an account-deletion request stays off here alone: this fixture's hub
|
|
391
|
-
// answers no member route (`via: "none"`), where Support must not take it
|
|
392
|
-
// (SEC-7894-11).
|
|
393
|
-
describe("Privacy's Your data card on a hub-mode spoke (#11194)", () => {
|
|
394
|
-
it("renders the table with Export data and Delete stored sessions and no unavailable line", async () => {
|
|
395
|
-
const { default: PrivacyPage } = await import("../privacy/page");
|
|
396
|
-
render(await PrivacyPage({ params: Promise.resolve({ locale: "en" }) }));
|
|
397
|
-
const table = screen.getByTestId("account-privacy-your-data");
|
|
398
|
-
expect(table).toHaveTextContent("Your data");
|
|
399
|
-
expect(table).toHaveTextContent("Export data");
|
|
400
|
-
expect(table).toHaveTextContent("Delete stored sessions");
|
|
401
|
-
expect(screen.getByTestId("account-privacy-your-data-export-button")).toHaveAttribute(
|
|
402
|
-
"href",
|
|
403
|
-
"/account/privacy/export",
|
|
404
|
-
);
|
|
405
|
-
expect(screen.getByTestId("account-privacy-your-data-delete-button")).toBeInTheDocument();
|
|
406
|
-
expect(screen.queryByTestId("account-privacy-your-data-account-deletion")).not.toBeInTheDocument();
|
|
407
|
-
expect(screen.queryByTestId("account-privacy-your-data-unavailable")).not.toBeInTheDocument();
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
it("files a posted deletion request as a support request — Support files support only (SEC-7894-11)", async () => {
|
|
412
|
-
mockLeadsSubmit.mockResolvedValue({ ok: true, body: {} });
|
|
413
|
-
const form = new FormData();
|
|
414
|
-
form.set("kind", "deletion");
|
|
415
|
-
form.set("subject", "Delete me");
|
|
416
|
-
form.set("message", "Please delete my account.");
|
|
417
|
-
await expect(submitSupportRequest({ kind: "idle" }, form)).resolves.toEqual({ kind: "success" });
|
|
418
|
-
expect(mockLeadsSubmit).toHaveBeenCalledWith(
|
|
419
|
-
expect.objectContaining({ email: USER.email, payload: expect.objectContaining({ kind: "support" }) }),
|
|
420
|
-
);
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
it("Billing with nothing to show renders no plan card and no button, without reading subscription.me (#11165)", async () => {
|
|
424
|
-
// The Billing route's own page, loaded with `import()`: architecture.yaml bans
|
|
425
|
-
// a static import of a relative billing/ path to keep OSS code out of the
|
|
426
|
-
// apps-paid/billing service's source, and this route directory shares the name.
|
|
427
|
-
const { default: BillingPage } = await import("../billing/page");
|
|
428
|
-
render(await BillingPage({ params: Promise.resolve({ locale: "en" }) }));
|
|
429
|
-
expect(screen.queryByTestId("account-billing")).not.toBeInTheDocument();
|
|
430
|
-
expect(screen.queryByText("You don't have a subscription.")).not.toBeInTheDocument();
|
|
431
|
-
expect(screen.queryByTestId("account-billing-manage")).not.toBeInTheDocument();
|
|
432
|
-
// Nothing to show is no card at all — never an empty shell.
|
|
433
|
-
expect(screen.queryByTestId("account-settings-billing-card")).not.toBeInTheDocument();
|
|
434
|
-
expect(mockSubscriptionMe).not.toHaveBeenCalled();
|
|
435
|
-
});
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
describe("#8431 AC-4 — Security on a hub-mode spoke", () => {
|
|
439
|
-
const realFetch = Object.getOwnPropertyDescriptor(globalThis, "fetch");
|
|
440
|
-
const mockFetch = jest.fn();
|
|
441
|
-
|
|
442
|
-
beforeEach(() => {
|
|
443
|
-
mockFetch.mockReset();
|
|
444
|
-
Object.defineProperty(globalThis, "fetch", { value: mockFetch, writable: true, configurable: true });
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
afterEach(() => {
|
|
448
|
-
if (realFetch) Object.defineProperty(globalThis, "fetch", realFetch);
|
|
449
|
-
else Reflect.deleteProperty(globalThis, "fetch");
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
async function renderSecurity(): Promise<void> {
|
|
453
|
-
const { default: SecurityPage } = await import("../security/page");
|
|
454
|
-
render(await SecurityPage({ params: Promise.resolve({ locale: "en" }) }));
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
it("renders no 'managed at <hub>' sentence and no link to the hub's Security page (#11162), and never reads the seam's accounts", async () => {
|
|
458
|
-
await renderSecurity();
|
|
459
|
-
expect(screen.queryByTestId("account-security-hub")).not.toBeInTheDocument();
|
|
460
|
-
expect(screen.queryByTestId("account-security-hub-link")).not.toBeInTheDocument();
|
|
461
|
-
expect(screen.queryByTestId("account-security-sentence")).not.toBeInTheDocument();
|
|
462
|
-
expect(screen.getByTestId("account-security-log-out")).toBeInTheDocument();
|
|
463
|
-
expect(mockReadOwnAccounts).not.toHaveBeenCalled();
|
|
464
|
-
});
|
|
465
|
-
|
|
466
|
-
it("Log out POSTs the spoke's sign-out endpoint, never Better Auth, and on a 204 lands on the home (#11095 D4)", async () => {
|
|
467
|
-
mockFetch.mockResolvedValue({ ok: true, status: 204 });
|
|
468
|
-
await renderSecurity();
|
|
469
|
-
await act(async () => {
|
|
470
|
-
fireEvent.click(screen.getByTestId("account-security-log-out"));
|
|
471
|
-
});
|
|
472
|
-
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
473
|
-
expect(mockFetch).toHaveBeenCalledWith("/api/hub-session/sign-out", {
|
|
474
|
-
method: "POST",
|
|
475
|
-
credentials: "same-origin",
|
|
476
|
-
});
|
|
477
|
-
expect(mockSignOut).not.toHaveBeenCalled();
|
|
478
|
-
expect(mockPush).toHaveBeenCalledWith("/");
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
it("a refused sign-out (403) navigates nowhere and shows the error", async () => {
|
|
482
|
-
mockFetch.mockResolvedValue({ ok: false, status: 403 });
|
|
483
|
-
await renderSecurity();
|
|
484
|
-
await act(async () => {
|
|
485
|
-
fireEvent.click(screen.getByTestId("account-security-log-out"));
|
|
486
|
-
});
|
|
487
|
-
expect(mockPush).not.toHaveBeenCalled();
|
|
488
|
-
expect(mockSignOut).not.toHaveBeenCalled();
|
|
489
|
-
expect(screen.getByTestId("account-security-log-out-error")).toBeInTheDocument();
|
|
490
|
-
});
|
|
491
|
-
});
|
|
492
|
-
|
|
493
|
-
describe("#11165 AC-1, AC-4 — Billing on a hub-mode spoke reads the hub first, the spoke's own key as the fallback", () => {
|
|
494
|
-
const VISA = { brand: "visa", last4: "4242", expMonth: 4, expYear: 2030 };
|
|
495
|
-
const PORTAL_URL = "https://billing.stripe.com/p/session/test_fake";
|
|
496
|
-
const HUB_PORTAL_URL = "https://billing.stripe.com/p/session/test_hub";
|
|
497
|
-
const PLAN = {
|
|
498
|
-
name: "Essentials",
|
|
499
|
-
status: "active",
|
|
500
|
-
price: { amountMinor: 1250000, currency: "usd", interval: "month" },
|
|
501
|
-
renewsAt: "2026-12-01T00:00:00.000Z",
|
|
502
|
-
accessEndsAt: null,
|
|
503
|
-
card: { brand: "visa", last4: "4242" },
|
|
504
|
-
};
|
|
505
|
-
const ROW = {
|
|
506
|
-
id: "in_workshop",
|
|
507
|
-
paidAt: "2026-10-25T10:00:00.000Z",
|
|
508
|
-
offering: "Positioning workshop",
|
|
509
|
-
amountMinor: 120000,
|
|
510
|
-
currency: "usd",
|
|
511
|
-
receiptUrl: "https://invoice.stripe.com/i/acct_1/test_workshop",
|
|
512
|
-
};
|
|
513
|
-
const PURCHASE = {
|
|
514
|
-
id: "purchase_01920000-1109-7000-8000-000000000001",
|
|
515
|
-
offering: "Strategy Session",
|
|
516
|
-
amountMinor: 25000,
|
|
517
|
-
currency: "usd",
|
|
518
|
-
period: null,
|
|
519
|
-
purchasedAt: "2026-11-07T12:00:00.000Z",
|
|
520
|
-
};
|
|
521
|
-
const bearer = { headers: { authorization: `Bearer ${CREDENTIAL}` } };
|
|
522
|
-
|
|
523
|
-
/** The hub's answer: its customers and what it read for them. */
|
|
524
|
-
const hub = (billing: unknown) => ({
|
|
525
|
-
ok: true,
|
|
526
|
-
body: { customers: [{ customerId: "cus_A1", planOffering: null }], ...(billing === undefined ? {} : { billing }) },
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
/** A `SpokeBilling` stub: what the rendered action returns. */
|
|
530
|
-
function stub(read: unknown, portalUrl: string | null = PORTAL_URL) {
|
|
531
|
-
return { read: jest.fn().mockResolvedValue(read), portalUrl: jest.fn().mockResolvedValue(portalUrl) };
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
async function renderBilling(): Promise<void> {
|
|
535
|
-
// The Billing route's own page, loaded with `import()` — see the AC-5 case above.
|
|
536
|
-
const { default: BillingPage } = await import("../billing/page");
|
|
537
|
-
render(await BillingPage({ params: Promise.resolve({ locale: "en" }) }));
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
afterEach(() => {
|
|
541
|
-
// Every case: a hub-mode spoke never reads the hub's cookie-session subscription.
|
|
542
|
-
expect(mockSubscriptionMe).not.toHaveBeenCalled();
|
|
543
|
-
});
|
|
544
|
-
|
|
545
|
-
describe("the hub read (source: hub)", () => {
|
|
546
|
-
it("renders the plan card from the hub's read — the name, the muted price, the renewal line with the card, Manage plan — and the History table, with the Bearer credential and no spoke-key read", async () => {
|
|
547
|
-
mockMemberBilling.mockResolvedValue(hub({ source: "hub", plan: PLAN, history: [ROW], portalAvailable: true }));
|
|
548
|
-
await renderBilling();
|
|
549
|
-
expect(mockMemberBilling).toHaveBeenCalledWith(bearer);
|
|
550
|
-
const card = screen.getByTestId("account-billing");
|
|
551
|
-
expect(within(card).getByTestId("account-billing-plan")).toHaveTextContent("Essentials");
|
|
552
|
-
expect(within(card).getByTestId("account-billing-price")).toHaveTextContent("$12,500/mo");
|
|
553
|
-
expect(within(card).getByTestId("account-billing-status")).toHaveTextContent("Renews on December 1 · Visa 4242");
|
|
554
|
-
expect(within(card).getByTestId("account-billing-manage")).toHaveTextContent("Manage plan");
|
|
555
|
-
expect(screen.queryByText("Current plan")).not.toBeInTheDocument();
|
|
556
|
-
const history = screen.getByTestId("account-billing-history");
|
|
557
|
-
expect(within(history).getByRole("heading", { level: 2 })).toHaveTextContent("History");
|
|
558
|
-
const row = within(history).getAllByTestId("account-billing-history-row")[0]!;
|
|
559
|
-
expect(row).toHaveTextContent("10/25/2026");
|
|
560
|
-
expect(row).toHaveTextContent("Positioning workshop");
|
|
561
|
-
expect(row).toHaveTextContent("$1,200");
|
|
562
|
-
expect(within(row).getByRole("link", { name: "View" })).toHaveAttribute("href", ROW.receiptUrl);
|
|
563
|
-
expect(mockLoadSpokeBilling).not.toHaveBeenCalled();
|
|
564
|
-
expect(mockMemberPurchases).not.toHaveBeenCalled();
|
|
565
|
-
expect(screen.queryByTestId("account-billing-unreadable")).not.toBeInTheDocument();
|
|
566
|
-
// Two cards: the plan and History — no shell for the absent offer.
|
|
567
|
-
expect(screen.getAllByTestId("account-settings-billing-card")).toHaveLength(2);
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
it.each([
|
|
571
|
-
["past_due", { ...PLAN, status: "past_due", renewsAt: null }, "Payment due · Visa 4242"],
|
|
572
|
-
["canceled with an access end", { ...PLAN, status: "canceled", renewsAt: null, accessEndsAt: "2026-12-01T00:00:00.000Z" }, "Access ends December 1 · Visa 4242"],
|
|
573
|
-
["no card", { ...PLAN, card: null }, "Renews on December 1"],
|
|
574
|
-
["no name and no price", { ...PLAN, name: null, price: null }, "Renews on December 1 · Visa 4242"],
|
|
575
|
-
])("the status line for %s", async (_label, plan, line) => {
|
|
576
|
-
mockMemberBilling.mockResolvedValue(hub({ source: "hub", plan, history: [], portalAvailable: true }));
|
|
577
|
-
await renderBilling();
|
|
578
|
-
expect(screen.getByTestId("account-billing-status")).toHaveTextContent(line);
|
|
579
|
-
if (plan.name === null) {
|
|
580
|
-
expect(screen.getByTestId("account-billing-plan")).toHaveTextContent("Your subscription");
|
|
581
|
-
expect(screen.queryByTestId("account-billing-price")).not.toBeInTheDocument();
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
it("no portal, no Manage plan", async () => {
|
|
586
|
-
mockMemberBilling.mockResolvedValue(hub({ source: "hub", plan: PLAN, history: [], portalAvailable: false }));
|
|
587
|
-
await renderBilling();
|
|
588
|
-
expect(screen.getByTestId("account-billing")).toBeInTheDocument();
|
|
589
|
-
expect(screen.queryByTestId("account-billing-manage")).not.toBeInTheDocument();
|
|
590
|
-
});
|
|
591
|
-
|
|
592
|
-
it("a member with no customer — no plan, no history — renders no plan card (the shown set is unconnected) and the purchase leads as History, without a receipt", async () => {
|
|
593
|
-
mockMemberBilling.mockResolvedValue(hub({ source: "hub", plan: null, history: [], portalAvailable: false }));
|
|
594
|
-
mockMemberPurchases.mockResolvedValue({ ok: true, body: { items: [PURCHASE] } });
|
|
595
|
-
await renderBilling();
|
|
596
|
-
expect(screen.queryByTestId("account-billing")).not.toBeInTheDocument();
|
|
597
|
-
expect(screen.queryByTestId("account-billing-manage")).not.toBeInTheDocument();
|
|
598
|
-
expect(mockMemberPurchases).toHaveBeenCalledWith(bearer);
|
|
599
|
-
const rows = screen.getAllByTestId("account-billing-history-row");
|
|
600
|
-
expect(rows).toHaveLength(1);
|
|
601
|
-
expect(rows[0]).toHaveTextContent("11/07/2026");
|
|
602
|
-
expect(rows[0]).toHaveTextContent("Strategy Session");
|
|
603
|
-
expect(rows[0]).toHaveTextContent("$250");
|
|
604
|
-
expect(within(rows[0]!).queryByRole("link")).not.toBeInTheDocument();
|
|
605
|
-
expect(mockLoadSpokeBilling).not.toHaveBeenCalled();
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
it("no history anywhere renders no History card; an older hub's 404 on purchases is none", async () => {
|
|
609
|
-
mockMemberBilling.mockResolvedValue(hub({ source: "hub", plan: PLAN, history: [], portalAvailable: true }));
|
|
610
|
-
await renderBilling();
|
|
611
|
-
expect(screen.queryByTestId("account-billing-history")).not.toBeInTheDocument();
|
|
612
|
-
expect(screen.queryByTestId("account-billing-history-error")).not.toBeInTheDocument();
|
|
613
|
-
expect(screen.getAllByTestId("account-settings-billing-card")).toHaveLength(1);
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
it("a failed purchases read shows the History error row, never an empty list", async () => {
|
|
617
|
-
const errorSpy = jest.spyOn(console, "error").mockImplementation(() => {});
|
|
618
|
-
mockMemberBilling.mockResolvedValue(hub({ source: "hub", plan: PLAN, history: [], portalAvailable: true }));
|
|
619
|
-
mockMemberPurchases.mockResolvedValue({ ok: false, status: 502, body: {} });
|
|
620
|
-
await renderBilling();
|
|
621
|
-
expect(screen.getByTestId("account-billing-history-error")).toHaveTextContent("We couldn't load your purchases.");
|
|
622
|
-
expect(screen.queryByTestId("account-billing-history-row")).not.toBeInTheDocument();
|
|
623
|
-
errorSpy.mockRestore();
|
|
624
|
-
});
|
|
625
|
-
|
|
626
|
-
it("source: failed renders the error row, never 'no subscription', and never the spoke's own key", async () => {
|
|
627
|
-
const errorSpy = jest.spyOn(console, "error").mockImplementation(() => {});
|
|
628
|
-
mockMemberBilling.mockResolvedValue(hub({ source: "failed" }));
|
|
629
|
-
await renderBilling();
|
|
630
|
-
expect(screen.getByTestId("inbox-error")).toHaveTextContent("We couldn't load your billing details.");
|
|
631
|
-
expect(screen.queryByTestId("account-billing")).not.toBeInTheDocument();
|
|
632
|
-
expect(mockLoadSpokeBilling).not.toHaveBeenCalled();
|
|
633
|
-
errorSpy.mockRestore();
|
|
634
|
-
});
|
|
635
|
-
|
|
636
|
-
it("a 500 from the hub, or a throw, renders the error row", async () => {
|
|
637
|
-
const errorSpy = jest.spyOn(console, "error").mockImplementation(() => {});
|
|
638
|
-
mockMemberBilling.mockResolvedValue({ ok: false, status: 500, body: {} });
|
|
639
|
-
await renderBilling();
|
|
640
|
-
expect(screen.getByTestId("inbox-error")).toBeInTheDocument();
|
|
641
|
-
expect(mockLoadSpokeBilling).not.toHaveBeenCalled();
|
|
642
|
-
errorSpy.mockRestore();
|
|
643
|
-
});
|
|
644
|
-
});
|
|
645
|
-
|
|
646
|
-
describe("the spoke-key fallback (source: none, an older hub, a 404)", () => {
|
|
647
|
-
it.each([
|
|
648
|
-
["source: none — no Organization connection", () => mockMemberBilling.mockResolvedValue(hub({ source: "none" }))],
|
|
649
|
-
["an older hub with no billing key", () => mockMemberBilling.mockResolvedValue(hub(undefined))],
|
|
650
|
-
["a 404", () => mockMemberBilling.mockResolvedValue(notFound)],
|
|
651
|
-
])("%s: a subscription read with the spoke's own key renders the plan, the card and Manage plan, with no price or renewal", async (_label, arrange) => {
|
|
652
|
-
arrange();
|
|
653
|
-
mockLoadSpokeBilling.mockResolvedValue(
|
|
654
|
-
stub({ kind: "subscription", status: "active", planName: "Pro", paymentMethod: VISA, unreadable: false }),
|
|
655
|
-
);
|
|
656
|
-
await renderBilling();
|
|
657
|
-
const card = screen.getByTestId("account-billing");
|
|
658
|
-
expect(within(card).getByTestId("account-billing-plan")).toHaveTextContent("Pro");
|
|
659
|
-
expect(within(card).getByTestId("account-billing-status")).toHaveTextContent("Active · Visa 4242");
|
|
660
|
-
expect(within(card).queryByTestId("account-billing-price")).not.toBeInTheDocument();
|
|
661
|
-
expect(screen.getByTestId("account-billing-manage")).toHaveTextContent("Manage plan");
|
|
662
|
-
expect(mockLoadSpokeBilling).toHaveBeenCalledTimes(1);
|
|
663
|
-
expect(mockMemberPurchases).toHaveBeenCalledWith(bearer);
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
it("none renders no plan card and no button", async () => {
|
|
667
|
-
mockMemberBilling.mockResolvedValue(hub({ source: "none" }));
|
|
668
|
-
mockLoadSpokeBilling.mockResolvedValue(stub({ kind: "none", unreadable: false }, null));
|
|
669
|
-
await renderBilling();
|
|
670
|
-
expect(screen.queryByTestId("account-billing")).not.toBeInTheDocument();
|
|
671
|
-
expect(screen.queryByTestId("account-billing-manage")).not.toBeInTheDocument();
|
|
672
|
-
expect(screen.queryByTestId("account-billing-unreadable")).not.toBeInTheDocument();
|
|
673
|
-
});
|
|
674
|
-
|
|
675
|
-
it.each([
|
|
676
|
-
["none", { kind: "none", unreadable: true }, "account-settings-billing"],
|
|
677
|
-
[
|
|
678
|
-
"a subscription",
|
|
679
|
-
{ kind: "subscription", status: "past_due", planName: null, paymentMethod: null, unreadable: true },
|
|
680
|
-
"account-billing",
|
|
681
|
-
],
|
|
682
|
-
])("unreadable: true on %s adds the unreadable line", async (_label, read, baseTestId) => {
|
|
683
|
-
mockMemberBilling.mockResolvedValue(hub({ source: "none" }));
|
|
684
|
-
mockLoadSpokeBilling.mockResolvedValue(stub(read));
|
|
685
|
-
await renderBilling();
|
|
686
|
-
const line = screen.getByTestId("account-billing-unreadable");
|
|
687
|
-
expect(line).toHaveTextContent("Some of your billing is with another Stripe account, so it isn't shown here.");
|
|
688
|
-
expect(screen.getByTestId(baseTestId)).toBeInTheDocument();
|
|
689
|
-
});
|
|
690
|
-
|
|
691
|
-
it("a failed own-key read renders the error row, never 'no subscription'", async () => {
|
|
692
|
-
mockMemberBilling.mockResolvedValue(hub({ source: "none" }));
|
|
693
|
-
mockLoadSpokeBilling.mockResolvedValue(stub({ kind: "failed" }));
|
|
694
|
-
await renderBilling();
|
|
695
|
-
expect(screen.getByTestId("inbox-error")).toHaveTextContent("We couldn't load your billing details.");
|
|
696
|
-
expect(screen.queryByTestId("account-billing-unreadable")).not.toBeInTheDocument();
|
|
697
|
-
});
|
|
698
|
-
|
|
699
|
-
it("a loader that fails to load renders the error row", async () => {
|
|
700
|
-
const errorSpy = jest.spyOn(console, "error").mockImplementation(() => {});
|
|
701
|
-
mockMemberBilling.mockResolvedValue(hub({ source: "none" }));
|
|
702
|
-
mockLoadSpokeBilling.mockRejectedValue(new SyntaxError("checkout-config.ts is malformed"));
|
|
703
|
-
await renderBilling();
|
|
704
|
-
expect(screen.getByTestId("inbox-error")).toBeInTheDocument();
|
|
705
|
-
expect(errorSpy.mock.calls.map((args) => args.join(" "))).toEqual([
|
|
706
|
-
"[account] read failed source=spoke-billing errName=SyntaxError",
|
|
707
|
-
]);
|
|
708
|
-
errorSpy.mockRestore();
|
|
709
|
-
});
|
|
710
|
-
|
|
711
|
-
it("a spoke without the action (the loader resolves null) and no purchases renders no plan card and no History", async () => {
|
|
712
|
-
mockMemberBilling.mockResolvedValue(hub({ source: "none" }));
|
|
713
|
-
await renderBilling();
|
|
714
|
-
expect(screen.queryByTestId("account-billing")).not.toBeInTheDocument();
|
|
715
|
-
expect(screen.queryByTestId("account-billing-history")).not.toBeInTheDocument();
|
|
716
|
-
expect(mockLoadSpokeBilling).toHaveBeenCalledTimes(1);
|
|
717
|
-
});
|
|
718
|
-
});
|
|
719
|
-
|
|
720
|
-
describe("Manage plan — openBillingPortal", () => {
|
|
721
|
-
it("redirects to the hub's portal session, minted with the Bearer credential", async () => {
|
|
722
|
-
mockMemberBillingPortal.mockResolvedValue({ ok: true, body: { url: HUB_PORTAL_URL } });
|
|
723
|
-
mockLoadSpokeBilling.mockResolvedValue(stub({ kind: "none", unreadable: false }));
|
|
724
|
-
await openBillingPortal();
|
|
725
|
-
expect(mockMemberBillingPortal).toHaveBeenCalledWith(bearer);
|
|
726
|
-
expect(mockRedirect).toHaveBeenCalledTimes(1);
|
|
727
|
-
expect(mockRedirect).toHaveBeenCalledWith(HUB_PORTAL_URL);
|
|
728
|
-
expect(mockLoadSpokeBilling).not.toHaveBeenCalled();
|
|
729
|
-
expect(mockPortalSession).not.toHaveBeenCalled();
|
|
730
|
-
});
|
|
731
|
-
|
|
732
|
-
it("a 404 from the hub (no portal there) falls back to the loader's portal URL", async () => {
|
|
733
|
-
const billing = stub({ kind: "none", unreadable: false });
|
|
734
|
-
mockLoadSpokeBilling.mockResolvedValue(billing);
|
|
735
|
-
await openBillingPortal();
|
|
736
|
-
expect(billing.portalUrl).toHaveBeenCalledWith();
|
|
737
|
-
expect(mockRedirect).toHaveBeenCalledWith(PORTAL_URL);
|
|
738
|
-
expect(mockPortalSession).not.toHaveBeenCalled();
|
|
739
|
-
});
|
|
740
|
-
|
|
741
|
-
it.each([
|
|
742
|
-
["the hub refuses with a 500", () => mockMemberBillingPortal.mockResolvedValue({ ok: false, status: 500, body: {} })],
|
|
743
|
-
["the hub answers with a URL off Stripe", () => mockMemberBillingPortal.mockResolvedValue({ ok: true, body: { url: "https://evil.example/p" } })],
|
|
744
|
-
["the hub answers with an http: URL", () => mockMemberBillingPortal.mockResolvedValue({ ok: true, body: { url: "http://billing.stripe.com/p" } })],
|
|
745
|
-
["the hub call throws", () => mockMemberBillingPortal.mockRejectedValue(new TypeError("fetch failed"))],
|
|
746
|
-
["the loader's portal is null", () => mockLoadSpokeBilling.mockResolvedValue(stub({ kind: "none", unreadable: false }, null))],
|
|
747
|
-
["there is no loader", () => mockLoadSpokeBilling.mockResolvedValue(null)],
|
|
748
|
-
["the loader fails to load", () => mockLoadSpokeBilling.mockRejectedValue(new Error("load failed"))],
|
|
749
|
-
])("openBillingPortal redirects nowhere when %s", async (_label, arrange) => {
|
|
750
|
-
const errorSpy = jest.spyOn(console, "error").mockImplementation(() => {});
|
|
751
|
-
arrange();
|
|
752
|
-
await openBillingPortal();
|
|
753
|
-
expect(mockRedirect).not.toHaveBeenCalled();
|
|
754
|
-
expect(mockPortalSession).not.toHaveBeenCalled();
|
|
755
|
-
errorSpy.mockRestore();
|
|
756
|
-
});
|
|
757
|
-
});
|
|
758
|
-
});
|