From 8da15518d6b810ca61c5bb6d2d05a3ee745f57c7 Mon Sep 17 00:00:00 2001 From: dante01yoon Date: Mon, 28 Sep 2026 15:25:29 -0400 Subject: [PATCH 1/5] feat(billing-web): full-page checkout refusal, plan-not-available and couldn't-load screens A denied capability renders Checkout not available with the denial reason as the copyable code and Contact support as the only action. A quote the server answers INVALID_PLAN renders Plan not available with PLAN_NOT_FOUND and View plans back to return_to. Any other load failure renders Couldn't load your checkout, whose Try again re-runs reconciliation and the capture read in place. --- .../billing-web/e2e/full-page-endings.spec.ts | 77 ++++++++++++++++++- .../src/checkout/checkoutPage.test.ts | 39 ++++++++-- apps/billing-web/src/checkout/checkoutPage.ts | 9 +++ .../src/checkout/endingScreen.test.ts | 33 ++++++++ apps/billing-web/src/checkout/endingScreen.ts | 12 +++ .../fullPage/CheckoutEnding.test.ts | 70 +++++++++++++---- .../components/fullPage/CheckoutEnding.vue | 27 +++++-- .../src/composables/useFullPageCheckout.ts | 16 +++- apps/billing-web/src/locales/en/main.json | 23 ++++-- .../src/views/FullPageCheckoutView.test.ts | 67 +++++++++++++--- .../src/views/FullPageCheckoutView.vue | 35 +-------- 11 files changed, 329 insertions(+), 79 deletions(-) diff --git a/apps/billing-web/e2e/full-page-endings.spec.ts b/apps/billing-web/e2e/full-page-endings.spec.ts index fe0704bbd82..b6fc0f22a63 100644 --- a/apps/billing-web/e2e/full-page-endings.spec.ts +++ b/apps/billing-web/e2e/full-page-endings.spec.ts @@ -1,12 +1,16 @@ /** * The full-page terminals, each reached the way a customer reaches it: their - * own Pay, a revisit after the money settled, and a bank capture that is - * still settling. + * own Pay, a revisit after the money settled, a bank capture that is still + * settling, a refusal, a stale plan link and a checkout that could not load. */ import type { Page } from '@playwright/test' import type { MockCloud } from './fixtures/cloud' -import { pendingOperation, succeededOperation } from './fixtures/scenario' +import { + capabilitiesWith, + pendingOperation, + succeededOperation +} from './fixtures/scenario' import { installFakeStripe } from './fixtures/stripe' import { entryPath, expect, test as base } from './fixtures/test' @@ -122,3 +126,70 @@ test('FE-2856: a capture the bank is still settling renders Payment in progress, await expect(code(page)).toHaveText('op_bank') expect(subscribeRequests(cloud)).toHaveLength(0) }) + +test('a member the owner manages billing for sees Checkout not available with the reason code, and support only', async ({ + page, + cloud, + signIn +}) => { + const refused = capabilitiesWith({ can_subscribe_self_serve: false }) + cloud.reply('GET', '/billing/capabilities', () => ({ + body: { + ...refused, + denied_reasons: { can_subscribe_self_serve: 'not_workspace_owner' } + }, + headers: { 'x-capability-revision': String(refused.revision) } + })) + await signIn(CHECKOUT) + + await expect(heading(page, 'Checkout not available')).toBeVisible() + await expect(code(page)).toHaveText('NOT_WORKSPACE_OWNER') + await expect(contactSupport(page)).toBeVisible() + await expect( + page.getByRole('button', { name: /Close|Try again/ }) + ).toBeHidden() +}) + +test('a link to a plan the catalog lacks renders Plan not available, and View plans goes back to the host catalog', async ({ + page, + cloud, + signIn +}) => { + cloud.reply('POST', '/billing/preview-subscribe', () => ({ + status: 400, + body: { code: 'INVALID_PLAN', message: 'Plan not found: pro_monthly' } + })) + await signIn(CHECKOUT) + + await expect(heading(page, 'This plan is no longer available')).toBeVisible() + await expect(code(page)).toHaveText('PLAN_NOT_FOUND') + + await page.getByRole('button', { name: 'View plans' }).click() + + await expect(heading(page, 'Host app')).toBeVisible() + expect(new URL(page.url()).searchParams.has('billing_result')).toBe(false) +}) + +test("a checkout that couldn't load retries in place on Try again, without leaving the URL", async ({ + page, + cloud, + signIn +}) => { + let quotes = 0 + cloud.reply('POST', '/billing/preview-subscribe', () => { + quotes += 1 + return quotes === 1 + ? { status: 503, body: { code: 'UNAVAILABLE', message: 'down' } } + : { body: cloud.scenario.preview } + }) + await signIn(CHECKOUT) + + await expect(heading(page, "Couldn't load your checkout")).toBeVisible() + await expect(code(page)).toHaveText('REQUEST_FAILED') + + await page.getByRole('button', { name: 'Try again' }).click() + + await expect(payButton(page)).toBeEnabled() + await expect(page).toHaveURL(CHECKOUT) + expect(quotes).toBe(2) +}) diff --git a/apps/billing-web/src/checkout/checkoutPage.test.ts b/apps/billing-web/src/checkout/checkoutPage.test.ts index 94c55bc966a..44a2fe9f7cd 100644 --- a/apps/billing-web/src/checkout/checkoutPage.test.ts +++ b/apps/billing-web/src/checkout/checkoutPage.test.ts @@ -776,6 +776,8 @@ const parkedForAHuman = (): BillingOperationState => ({ ...succeededOperation(), phase: 'reconciliation_needed' }) +const planUnavailable: CheckoutPageEvent = { type: 'planUnavailable' } +const tryAgain: CheckoutPageEvent = { type: 'retried' } const UNCONFIRMED: CheckoutPage = { kind: 'unconfirmed', operationId: 'op_1' } describe('reduceCheckoutPage endings', () => { @@ -784,6 +786,21 @@ describe('reduceCheckoutPage endings', () => { events: CheckoutPageEvent[] expected: CheckoutPage }>([ + { + name: 'a plan the catalog lacks is Plan not available', + events: [planUnavailable], + expected: { kind: 'plan_unavailable' } + }, + { + name: 'Try again after a failed load resolves again', + events: [unavailable, tryAgain], + expected: RESOLVING + }, + { + name: 'Try again then a quote is capture', + events: [unavailable, tryAgain, quoted(0)], + expected: collect('loading') + }, { name: 'an operation parked for a human on mount is unconfirmed, and the quote cannot open a form over it', events: [reconciled(parkedForAHuman()), quoted(0)], @@ -879,12 +896,24 @@ describe('reduceCheckoutPage endings', () => { }) it.for<{ name: string; from: CheckoutPage; event: CheckoutPageEvent }>([ - { name: 'a quote over unconfirmed', from: UNCONFIRMED, event: quoted(0) }, + { name: 'Try again on capture', from: collect('ready'), event: tryAgain }, + { name: 'Try again while resolving', from: RESOLVING, event: tryAgain }, { - name: 'a refusal over unconfirmed', - from: UNCONFIRMED, - event: refused - } + name: 'a late unknown plan after capture', + from: collect('ready'), + event: planUnavailable + }, + { + name: 'the lifecycle over Plan not available', + from: replay([planUnavailable]), + event: reconciled(pendingOperation()) + }, + { + name: 'Try again on Plan not available', + from: replay([planUnavailable]), + event: tryAgain + }, + { name: 'a quote over unconfirmed', from: UNCONFIRMED, event: quoted(0) } ])('ignores $name', ({ from, event }) => { expect(reduceCheckoutPage(from, event)).toBe(from) }) diff --git a/apps/billing-web/src/checkout/checkoutPage.ts b/apps/billing-web/src/checkout/checkoutPage.ts index 5b198110992..317bf8d3c72 100644 --- a/apps/billing-web/src/checkout/checkoutPage.ts +++ b/apps/billing-web/src/checkout/checkoutPage.ts @@ -91,6 +91,7 @@ export type CheckoutPage = | { readonly kind: 'resolving'; readonly outcome?: InlineOutcome } | { readonly kind: 'refused'; readonly reason: CapabilityDenialReason } | { readonly kind: 'unavailable'; readonly code: string } + | { readonly kind: 'plan_unavailable' } | Capture | { readonly kind: 'waiting'; readonly operation: PendingBillingOperation } | { readonly kind: 'unconfirmed'; readonly operationId: string } @@ -109,6 +110,10 @@ export type OperationOutcome = Exclude< export type CheckoutPageEvent = | { readonly type: 'refused'; readonly reason: CapabilityDenialReason } | { readonly type: 'unavailable'; readonly code: string } + /** The quote named a plan the catalog does not have. */ + | { readonly type: 'planUnavailable' } + /** Try again on a checkout that could not load. */ + | { readonly type: 'retried' } | ({ readonly type: 'quoted'; readonly reactivation: boolean } & ( | { readonly method: 'collect'; readonly saved: SavedArrival } | { readonly method: 'on_file' } @@ -218,6 +223,10 @@ export function reduceCheckoutPage( : page case 'requoteFailed': return leavingCapture(page, { kind: 'unavailable', code: event.code }) + case 'planUnavailable': + return page.kind === 'resolving' ? { kind: 'plan_unavailable' } : page + case 'retried': + return page.kind === 'unavailable' ? RESOLVING : page case 'quoted': return page.kind === 'resolving' ? arrived(page, event) : page case 'reconciled': diff --git a/apps/billing-web/src/checkout/endingScreen.test.ts b/apps/billing-web/src/checkout/endingScreen.test.ts index ab8b9008f43..7c3c4d6136d 100644 --- a/apps/billing-web/src/checkout/endingScreen.test.ts +++ b/apps/billing-web/src/checkout/endingScreen.test.ts @@ -1,3 +1,5 @@ +import type { CapabilityDenialReason } from '@comfyorg/account-core/billing' + import type { CheckoutPage } from '@/checkout/checkoutPage' import { RESOLVING } from '@/checkout/checkoutPage' import type { EndingScreen } from '@/checkout/endingScreen' @@ -88,8 +90,39 @@ describe('endingOf', () => { name: 'a settled payment with no operation to quote', page: { kind: 'terminal', attribution: 'settled' }, screen: { kind: 'already_completed' } + }, + { + name: 'a checkout that could not load', + page: { kind: 'unavailable', code: 'REQUEST_FAILED' }, + screen: { kind: 'load_failed', code: 'REQUEST_FAILED' } + }, + { + name: 'a plan the catalog lacks', + page: { kind: 'plan_unavailable' }, + screen: { kind: 'plan_unavailable', code: 'PLAN_NOT_FOUND' } } ])('$name', ({ page, screen }) => { expect(endingOf(page)).toEqual(screen) }) + + it.for<{ reason: CapabilityDenialReason; code: string }>([ + { reason: 'not_a_member', code: 'NOT_A_MEMBER' }, + { reason: 'not_workspace_owner', code: 'NOT_WORKSPACE_OWNER' }, + { reason: 'tier_not_self_serve', code: 'TIER_NOT_SELF_SERVE' }, + { reason: 'subscription_not_started', code: 'SUBSCRIPTION_NOT_STARTED' }, + { + reason: 'subscription_change_in_progress', + code: 'SUBSCRIPTION_CHANGE_IN_PROGRESS' + }, + { + reason: 'subscription_status_unrecognized', + code: 'SUBSCRIPTION_STATUS_UNRECOGNIZED' + }, + { reason: 'unspecified', code: 'UNSPECIFIED' } + ])('a refusal for $reason shows $code', ({ reason, code }) => { + expect(endingOf({ kind: 'refused', reason })).toEqual({ + kind: 'refused', + code + }) + }) }) diff --git a/apps/billing-web/src/checkout/endingScreen.ts b/apps/billing-web/src/checkout/endingScreen.ts index 67010df6e65..1c661a17a07 100644 --- a/apps/billing-web/src/checkout/endingScreen.ts +++ b/apps/billing-web/src/checkout/endingScreen.ts @@ -1,6 +1,9 @@ import type { CheckoutPage } from '@/checkout/checkoutPage' import { waitingOn } from '@/checkout/checkoutPage' +/** The code a stale plan link shows; the catalog's verdict, not a capability denial. */ +const PLAN_NOT_FOUND = 'PLAN_NOT_FOUND' + /** * The full-page screen a checkout ends on, and the code support can act on. * `success` is the only one that may name a plan: this page's own Pay sent @@ -14,12 +17,21 @@ export type EndingScreen = | { readonly kind: 'in_progress'; readonly code: string } | { readonly kind: 'received'; readonly code: string } | { readonly kind: 'unconfirmed'; readonly code: string } + | { readonly kind: 'refused'; readonly code: string } + | { readonly kind: 'plan_unavailable'; readonly code: string } + | { readonly kind: 'load_failed'; readonly code: string } export type EndingKind = EndingScreen['kind'] /** The page's screen when it has ended, or no screen while capture or verifying owns it. */ export function endingOf(page: CheckoutPage): EndingScreen | undefined { switch (page.kind) { + case 'refused': + return { kind: 'refused', code: page.reason.toUpperCase() } + case 'unavailable': + return { kind: 'load_failed', code: page.code } + case 'plan_unavailable': + return { kind: 'plan_unavailable', code: PLAN_NOT_FOUND } case 'unconfirmed': return { kind: 'unconfirmed', code: page.operationId } case 'waiting': diff --git a/apps/billing-web/src/components/fullPage/CheckoutEnding.test.ts b/apps/billing-web/src/components/fullPage/CheckoutEnding.test.ts index f4659ce159f..fc8ae141e44 100644 --- a/apps/billing-web/src/components/fullPage/CheckoutEnding.test.ts +++ b/apps/billing-web/src/components/fullPage/CheckoutEnding.test.ts @@ -18,13 +18,15 @@ function renderEnding(ending: EndingScreen) { const CLOSE_LINE = "You can close this page. We'll email your invoice once this goes through and this page will automatically update." +type Action = 'Close' | 'Try again' | 'View plans' + describe('CheckoutEnding', () => { it.for<{ ending: EndingScreen title: string body: string codeLabel?: string - close: boolean + action?: Action support: boolean closeLine: boolean }>([ @@ -32,7 +34,7 @@ describe('CheckoutEnding', () => { ending: { kind: 'success' }, title: "You're all set", body: 'Your plan for Acme Team has been successfully updated.', - close: true, + action: 'Close', support: false, closeLine: false }, @@ -41,7 +43,7 @@ describe('CheckoutEnding', () => { title: "You're all set", body: 'A payment on this workspace completed — check your plan in settings.', codeLabel: 'Your reference for this payment:', - close: true, + action: 'Close', support: false, closeLine: false }, @@ -50,7 +52,7 @@ describe('CheckoutEnding', () => { title: 'Already completed', body: "This payment for Acme Team already went through. You won't be charged again.", codeLabel: 'Your reference for this payment:', - close: true, + action: 'Close', support: false, closeLine: false }, @@ -60,7 +62,6 @@ describe('CheckoutEnding', () => { body: "Your bank is still settling this payment — this can take up to a day. Nothing more is needed from you, and don't pay again: you could be charged twice.", codeLabel: 'If nothing has changed after 24 hours, contact support with this code:', - close: false, support: true, closeLine: true }, @@ -70,7 +71,6 @@ describe('CheckoutEnding', () => { body: "Your payment went through and you should receive your credits or subscription soon. You won't be charged again.", codeLabel: 'If nothing has changed after 24 hours, contact support with this code:', - close: false, support: true, closeLine: true }, @@ -80,13 +80,39 @@ describe('CheckoutEnding', () => { body: "Your payment may or may not have gone through. Don't pay again yet, you could be charged twice.", codeLabel: "If this page still can't confirm it after a few minutes, contact support with this code:", - close: false, support: true, closeLine: true + }, + { + ending: { kind: 'refused', code: 'NOT_WORKSPACE_OWNER' }, + title: 'Checkout not available', + body: 'Billing for this workspace is managed by its owner. Ask them to make this change.', + codeLabel: 'If this is an error, contact support with this code:', + support: true, + closeLine: false + }, + { + ending: { kind: 'plan_unavailable', code: 'PLAN_NOT_FOUND' }, + title: 'This plan is no longer available', + body: "The plan in your link isn't offered anymore. Nothing has been charged. See our current plans instead.", + codeLabel: + 'If you think this is a mistake, contact support with this code:', + action: 'View plans', + support: true, + closeLine: false + }, + { + ending: { kind: 'load_failed', code: 'REQUEST_FAILED' }, + title: "Couldn't load your checkout", + body: "We couldn't load your quote. Nothing has been charged. Try again, or contact support if this keeps happening.", + codeLabel: 'If this keeps happening, contact support with this code:', + action: 'Try again', + support: true, + closeLine: false } ])( '$ending.kind reads as designed', - ({ ending, title, body, codeLabel, close, support, closeLine }) => { + ({ ending, title, body, codeLabel, action, support, closeLine }) => { renderEnding(ending) expect(screen.getByRole('heading', { name: title })).toBeInTheDocument() @@ -99,9 +125,11 @@ describe('CheckoutEnding', () => { 'code' in ending ? (ending.code ?? '') : '' ) } - expect(screen.queryByRole('button', { name: 'Close' }) !== null).toBe( - close - ) + const buttons = screen + .queryAllByRole('button') + .map((button) => button.textContent.trim()) + .filter((label) => label !== '') + expect(buttons).toEqual(action === undefined ? [] : [action]) expect( screen.queryByRole('link', { name: 'Contact support' }) !== null ).toBe(support) @@ -120,12 +148,24 @@ describe('CheckoutEnding', () => { ) }) - it('Close emits close', async () => { - const { emitted } = renderEnding({ kind: 'success' }) + it.for<{ ending: EndingScreen; action: Action; event: string }>([ + { ending: { kind: 'success' }, action: 'Close', event: 'close' }, + { + ending: { kind: 'load_failed', code: 'REQUEST_FAILED' }, + action: 'Try again', + event: 'retry' + }, + { + ending: { kind: 'plan_unavailable', code: 'PLAN_NOT_FOUND' }, + action: 'View plans', + event: 'viewPlans' + } + ])('$action emits $event', async ({ ending, action, event }) => { + const { emitted } = renderEnding(ending) - await userEvent.click(screen.getByRole('button', { name: 'Close' })) + await userEvent.click(screen.getByRole('button', { name: action })) - expect(emitted()).toHaveProperty('close') + expect(emitted()).toHaveProperty(event) }) it('mails support with the code the screen shows', () => { diff --git a/apps/billing-web/src/components/fullPage/CheckoutEnding.vue b/apps/billing-web/src/components/fullPage/CheckoutEnding.vue index 8419f3f5ce7..c4f6ac1c151 100644 --- a/apps/billing-web/src/components/fullPage/CheckoutEnding.vue +++ b/apps/billing-web/src/components/fullPage/CheckoutEnding.vue @@ -14,19 +14,19 @@ export interface EndingPlan { readonly period: string } -type Tone = 'done' | 'waiting' +type Tone = 'done' | 'waiting' | 'refused' /** * How each ending reads. The done family closes back to the product; the * waiting family ends on support, since closing changes nothing about money - * still moving. + * still moving; the refused family offers the one action that can help. */ const ENDINGS: Readonly< Record< EndingKind, { readonly tone: Tone - readonly primary?: 'close' + readonly primary?: 'close' | 'retry' | 'view_plans' readonly support: boolean } > @@ -36,12 +36,16 @@ const ENDINGS: Readonly< already_completed: { tone: 'done', primary: 'close', support: false }, in_progress: { tone: 'waiting', support: true }, received: { tone: 'waiting', support: true }, - unconfirmed: { tone: 'waiting', support: true } + unconfirmed: { tone: 'waiting', support: true }, + refused: { tone: 'refused', support: true }, + plan_unavailable: { tone: 'refused', primary: 'view_plans', support: true }, + load_failed: { tone: 'refused', primary: 'retry', support: true } } const ICON: Readonly> = { done: 'icon-[lucide--circle-check-big] text-success-background', - waiting: 'icon-[lucide--clock] text-warning-background' + waiting: 'icon-[lucide--clock] text-warning-background', + refused: 'icon-[lucide--circle-alert] text-muted-foreground' } const { screen, workspace, plan } = defineProps<{ @@ -50,7 +54,7 @@ const { screen, workspace, plan } = defineProps<{ plan?: EndingPlan }>() -const emit = defineEmits<{ close: [] }>() +const emit = defineEmits<{ close: []; retry: []; viewPlans: [] }>() const { t } = useI18n() const { copy, copied } = useClipboard({ legacy: true }) @@ -63,6 +67,8 @@ const primary = computed(() => ending.value.primary) function act() { if (primary.value === 'close') emit('close') + else if (primary.value === 'retry') emit('retry') + else if (primary.value === 'view_plans') emit('viewPlans') } @@ -145,7 +151,14 @@ function act() { - -
Date: Mon, 28 Sep 2026 19:31:35 -0400 Subject: [PATCH 2/5] feat(billing-web): Plan not available for team links without a stop and unreadable checkout links, View plans into the cloud pricing table --- .../billing-web/e2e/full-page-endings.spec.ts | 58 ++++++++++++++- apps/billing-web/src/App.vue | 21 +++++- .../src/checkout/checkoutPage.test.ts | 12 +++- apps/billing-web/src/checkout/checkoutPage.ts | 28 ++++++-- apps/billing-web/src/checkout/cloudLinks.ts | 8 +++ .../src/checkout/endingScreen.test.ts | 12 +++- apps/billing-web/src/checkout/endingScreen.ts | 18 +++-- .../fullPage/CheckoutEnding.test.ts | 4 +- .../src/composables/useFullPageCheckout.ts | 28 ++++++-- apps/billing-web/src/locales/en/main.json | 4 +- .../src/views/CheckoutRouteView.test.ts | 28 ++++++++ .../src/views/CheckoutRouteView.vue | 4 ++ .../src/views/FullPageCheckoutView.test.ts | 70 ++++++++++++++++++- .../src/views/FullPageCheckoutView.vue | 7 +- 14 files changed, 277 insertions(+), 25 deletions(-) diff --git a/apps/billing-web/e2e/full-page-endings.spec.ts b/apps/billing-web/e2e/full-page-endings.spec.ts index b6fc0f22a63..b04ac0e4449 100644 --- a/apps/billing-web/e2e/full-page-endings.spec.ts +++ b/apps/billing-web/e2e/full-page-endings.spec.ts @@ -150,7 +150,7 @@ test('a member the owner manages billing for sees Checkout not available with th ).toBeHidden() }) -test('a link to a plan the catalog lacks renders Plan not available, and View plans goes back to the host catalog', async ({ +test('433-6840: a link to a plan the catalog lacks renders Plan not available with PLAN_NOT_FOUND, and View plans opens the cloud pricing table', async ({ page, cloud, signIn @@ -161,13 +161,65 @@ test('a link to a plan the catalog lacks renders Plan not available, and View pl })) await signIn(CHECKOUT) - await expect(heading(page, 'This plan is no longer available')).toBeVisible() + await expect(heading(page, "This plan isn't available")).toBeVisible() await expect(code(page)).toHaveText('PLAN_NOT_FOUND') await page.getByRole('button', { name: 'View plans' }).click() await expect(heading(page, 'Host app')).toBeVisible() - expect(new URL(page.url()).searchParams.has('billing_result')).toBe(false) + await expect(page).toHaveURL( + 'https://testcloud.comfy.org/?pricing=1&workspace=ws_e2e' + ) +}) + +test('433-6840: a team link without its commit stop is an invalid link, and View plans opens the pricing table on the Team tab', async ({ + page, + cloud, + signIn +}) => { + cloud.scenario.preview = { + ...cloud.scenario.preview, + new_plan: { ...cloud.scenario.preview.new_plan, tier: 'TEAM' } + } + await signIn(entryPath('checkout', { plan: 'team_per_credit_monthly' })) + + await expect(heading(page, "This plan isn't available")).toBeVisible() + await expect(code(page)).toHaveText('CHECKOUT_LINK_INVALID') + await expect(payButton(page)).toBeHidden() + expect(subscribeRequests(cloud)).toHaveLength(0) + + await page.getByRole('button', { name: 'View plans' }).click() + + await expect(heading(page, 'Host app')).toBeVisible() + await expect(page).toHaveURL( + 'https://testcloud.comfy.org/?pricing=team&workspace=ws_e2e' + ) +}) + +test("433-6840: a checkout link the contract cannot read is the checkout's 404 on the full page, and still the entry error on the embedded one", async ({ + page, + cloud, + signIn +}) => { + const unreadable = entryPath('checkout', { + product: 'spreadsheet', + plan: 'pro_monthly' + }) + await signIn(unreadable) + + await expect(heading(page, "This plan isn't available")).toBeVisible() + await expect(code(page)).toHaveText('CHECKOUT_LINK_INVALID') + await expect(payButton(page)).toBeHidden() + + cloud.scenario.checkoutUi = 'embedded' + await page.goto(unreadable) + + await expect( + heading(page, "We couldn't open that billing page") + ).toBeVisible() + await expect( + page.getByText("That link doesn't say which product sent you here.") + ).toBeVisible() }) test("a checkout that couldn't load retries in place on Try again, without leaving the URL", async ({ diff --git a/apps/billing-web/src/App.vue b/apps/billing-web/src/App.vue index 0e9e054ffbc..7b87361e1dc 100644 --- a/apps/billing-web/src/App.vue +++ b/apps/billing-web/src/App.vue @@ -2,6 +2,9 @@ import { computed, watch } from 'vue' import { useRoute, useRouter } from 'vue-router' +import { billingIntentPath } from '@comfyorg/billing-contract' + +import { safeReturnTo } from '@/auth/returnTo' import BillingShell from '@/components/BillingShell.vue' import { useBillingEntry } from '@/entry/billingEntry' import { SIGN_IN_PATH } from '@/router' @@ -25,6 +28,22 @@ watch(billingWebLivePhase, (next) => { }) }) +/** + * A checkout link that cannot be read is the checkout's own 404 on the full + * page, so that route decides how to explain it once the variant is known, + * which takes a signed-in session; every other unreadable link is explained + * here, before any session. On the sign-in page the link is the one it will + * return to. + */ +const CHECKOUT_PATH = billingIntentPath('checkout') +const checkoutLink = computed(() => { + const path = + route.path === SIGN_IN_PATH + ? safeReturnTo(route.query.returnTo).split('?')[0] + : route.path + return path === CHECKOUT_PATH +}) + /** A new key is a new scope, so the shell remounts with a fresh client. */ const scopeKey = computed(() => billedScope.value @@ -35,7 +54,7 @@ const scopeKey = computed(() =>