From 07d4adbca53f8eeab4c53064a3ba18cf5ffa3393 Mon Sep 17 00:00:00 2001 From: dante01yoon Date: Tue, 29 Sep 2026 18:54:21 -0400 Subject: [PATCH 1/2] fix(billing-web): name a scheduled change's plan the way the summary names a kept plan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A change already scheduled read "Pro · Yearly". It now reads "Pro" for monthly and "Pro Yearly" for yearly, from the same naming the summary's "You'll keep … until" line uses, with the full UTC date (Figma 643-14661). --- .../billing-web/e2e/full-page-endings.spec.ts | 2 +- .../billing-web/src/checkout/summaryLedger.ts | 19 +++++--- .../fullPage/CheckoutEnding.test.ts | 44 +++++++++++-------- .../components/fullPage/CheckoutEnding.vue | 9 +++- .../src/views/FullPageCheckoutView.test.ts | 2 +- 5 files changed, 48 insertions(+), 28 deletions(-) diff --git a/apps/billing-web/e2e/full-page-endings.spec.ts b/apps/billing-web/e2e/full-page-endings.spec.ts index e88c5df6fdb..3ed383d7b85 100644 --- a/apps/billing-web/e2e/full-page-endings.spec.ts +++ b/apps/billing-web/e2e/full-page-endings.spec.ts @@ -181,7 +181,7 @@ test('643-14654: a change already scheduled is named from the server, and withou await expect(heading(page, 'Checkout not available')).toBeVisible() await expect( page.getByText( - 'Your plan is set to change to Pro · Monthly on October 28, 2026. Cancel that change in your billing settings to make a different one.' + 'Your plan is set to change to Pro on October 28, 2026. Cancel that change in your billing settings to make a different one.' ) ).toBeVisible() await expect(code(page)).toHaveText('SUBSCRIPTION_CHANGE_IN_PROGRESS') diff --git a/apps/billing-web/src/checkout/summaryLedger.ts b/apps/billing-web/src/checkout/summaryLedger.ts index 0a056281bd0..c566f310a48 100644 --- a/apps/billing-web/src/checkout/summaryLedger.ts +++ b/apps/billing-web/src/checkout/summaryLedger.ts @@ -126,8 +126,8 @@ function verbOf(quote: SubscriptionPreview, commitChange: boolean) { return commitChange ? 'change' : 'upgrade' } -function planLabeller({ t, tierName }: LedgerContext) { - return (plan: Plan, cadenceShown: boolean) => +function planLabeller({ t, tierName }: Pick) { + return (plan: Pick, cadenceShown: boolean) => cadenceShown ? t(`${S}.planWithCadence`, { tier: tierName(plan.tier), @@ -266,11 +266,20 @@ function scheduledLedger(r: QuoteReading): FamilyLedger { } } +/** A plan named in a sentence: "Pro", or "Pro Yearly" when its cadence matters. */ +export function namedPlan( + context: Pick, + plan: Pick, + cadenceShown: boolean +): string { + return cadenceShown + ? planLabeller(context)(plan, true) + : context.tierName(plan.tier) +} + /** A team plan is one tier at many commitments, so the kept one is named by its rate. */ function keptPlanLine(r: QuoteReading, current: Plan, until: string): string { - const plan = r.cadenceChanges - ? r.planLabel(current, true) - : r.tierName(current.tier) + const plan = namedPlan(r, current, r.cadenceChanges) if (!r.commitChange) return r.t(`${S}.trailing.keepUntil`, { plan, date: until }) return r.t(`${S}.trailing.keepCommitmentUntil`, { diff --git a/apps/billing-web/src/components/fullPage/CheckoutEnding.test.ts b/apps/billing-web/src/components/fullPage/CheckoutEnding.test.ts index 6970a7afbb0..b08752e7e52 100644 --- a/apps/billing-web/src/components/fullPage/CheckoutEnding.test.ts +++ b/apps/billing-web/src/components/fullPage/CheckoutEnding.test.ts @@ -81,27 +81,33 @@ describe('CheckoutEnding', () => { } ) - it('a refusal for a change already scheduled names the plan and the date it takes effect', () => { - const ending = endingOf({ - kind: 'refused', - reason: 'subscription_change_in_progress', - scheduled: { - plan: { tier: 'PRO', duration: 'ANNUAL' }, - effectiveAt: '2026-10-28T00:00:00.000Z' - } - }) - if (ending === undefined) throw new Error('a refusal is an ending') - renderEnding(ending) + it.for([ + { duration: 'MONTHLY', plan: 'Pro' }, + { duration: 'ANNUAL', plan: 'Pro Yearly' } + ] as const)( + 'a refusal for a change already scheduled to $duration names it $plan and the full date it takes effect', + ({ duration, plan }) => { + const ending = endingOf({ + kind: 'refused', + reason: 'subscription_change_in_progress', + scheduled: { + plan: { tier: 'PRO', duration }, + effectiveAt: '2026-10-28T00:00:00.000Z' + } + }) + if (ending === undefined) throw new Error('a refusal is an ending') + renderEnding(ending) - expect( - screen.getByText( - 'Your plan is set to change to Pro · Yearly on October 28, 2026. Cancel that change in your billing settings to make a different one.' + expect( + screen.getByText( + `Your plan is set to change to ${plan} on October 28, 2026. Cancel that change in your billing settings to make a different one.` + ) + ).toBeInTheDocument() + expect(screen.getByTestId('checkout-ending-code')).toHaveTextContent( + 'SUBSCRIPTION_CHANGE_IN_PROGRESS' ) - ).toBeInTheDocument() - expect(screen.getByTestId('checkout-ending-code')).toHaveTextContent( - 'SUBSCRIPTION_CHANGE_IN_PROGRESS' - ) - }) + } + ) it.for<{ ending: EndingScreen diff --git a/apps/billing-web/src/components/fullPage/CheckoutEnding.vue b/apps/billing-web/src/components/fullPage/CheckoutEnding.vue index fca4e0da89b..805ff0285da 100644 --- a/apps/billing-web/src/components/fullPage/CheckoutEnding.vue +++ b/apps/billing-web/src/components/fullPage/CheckoutEnding.vue @@ -8,6 +8,7 @@ import { cn } from '@comfyorg/tailwind-utils' import type { EndingKind, EndingScreen } from '@/checkout/endingScreen' import { longDate } from '@/checkout/longDate' import { supportLinkWithCode } from '@/checkout/payVerdict' +import { namedPlan } from '@/checkout/summaryLedger' import EndingCodeCard from '@/components/fullPage/EndingCodeCard.vue' import SuccessCloseFooter from '@/components/fullPage/SuccessCloseFooter.vue' import { useHostedCopy } from '@/composables/useHostedCopy' @@ -68,7 +69,7 @@ const { const emit = defineEmits<{ close: []; retry: []; viewPlans: [] }>() const { t, locale } = useI18n() -const { planName } = useHostedCopy() +const { coded } = useHostedCopy() const ending = computed(() => ENDINGS[screen.kind]) const copyKey = computed(() => `checkout.fullPage.ending.${screen.kind}`) @@ -81,7 +82,11 @@ const bodyParams = computed(() => screen.kind === 'refused' && screen.copy === 'change_scheduled' ? { workspace, - plan: planName(screen.scheduled.plan), + plan: namedPlan( + { t, tierName: (tier) => coded('tier', tier) }, + screen.scheduled.plan, + screen.scheduled.plan.duration === 'ANNUAL' + ), date: longDate(screen.scheduled.effectiveAt, locale.value) } : { workspace } diff --git a/apps/billing-web/src/views/FullPageCheckoutView.test.ts b/apps/billing-web/src/views/FullPageCheckoutView.test.ts index 747e813eb35..778fc1da6a8 100644 --- a/apps/billing-web/src/views/FullPageCheckoutView.test.ts +++ b/apps/billing-web/src/views/FullPageCheckoutView.test.ts @@ -488,7 +488,7 @@ describe('FullPageCheckoutView', () => { duration: 'ANNUAL' }) const CHANGE_NAMED = - 'Your plan is set to change to Pro · Yearly on October 28, 2026. Cancel that change in your billing settings to make a different one.' + 'Your plan is set to change to Pro Yearly on October 28, 2026. Cancel that change in your billing settings to make a different one.' const CHANGE_UNNAMED = 'Your plan already has a change scheduled. Cancel it in your billing settings to make a different one.' From 5a0dc5dadcc002bef123b00622d4bb51a7300fd5 Mon Sep 17 00:00:00 2001 From: dante01yoon Date: Tue, 29 Sep 2026 18:55:38 -0400 Subject: [PATCH 2/2] fix(billing-web): fold the failed payment re-check into Couldn't load your checkout The re-check failure was its own ending with its own copy. It is now the Couldn't load ending with a recheck cause that picks the body: "We couldn't check your recent payments, so checkout can't open yet." Title, Try again and the reference code are shared with the quote-load failure, which keeps "Nothing has been charged" (Figma 677-14662). --- .../billing-web/e2e/full-page-endings.spec.ts | 5 +++ .../src/checkout/checkoutPage.test.ts | 18 +++++++--- apps/billing-web/src/checkout/checkoutPage.ts | 36 ++++++++++--------- .../src/checkout/endingScreen.test.ts | 8 ++--- apps/billing-web/src/checkout/endingScreen.ts | 12 ++++--- .../fullPage/CheckoutEnding.test.ts | 12 +++---- .../components/fullPage/CheckoutEnding.vue | 14 ++++---- apps/billing-web/src/locales/en/main.json | 10 +++--- .../src/views/FullPageCheckoutView.test.ts | 5 +++ 9 files changed, 71 insertions(+), 49 deletions(-) diff --git a/apps/billing-web/e2e/full-page-endings.spec.ts b/apps/billing-web/e2e/full-page-endings.spec.ts index 3ed383d7b85..01c3da00a63 100644 --- a/apps/billing-web/e2e/full-page-endings.spec.ts +++ b/apps/billing-web/e2e/full-page-endings.spec.ts @@ -417,6 +417,11 @@ test("a re-read of the workspace's payments that fails never claims nothing was await signIn(CHECKOUT) await expect(heading(page, "Couldn't load your checkout")).toBeVisible() + await expect( + page.getByText( + "We couldn't check your recent payments, so checkout can't open yet. Try again, or contact support if this keeps happening." + ) + ).toBeVisible() await expect(page.getByText(/Nothing has been charged/)).toBeHidden() await expect(payButton(page)).toBeHidden() diff --git a/apps/billing-web/src/checkout/checkoutPage.test.ts b/apps/billing-web/src/checkout/checkoutPage.test.ts index d51269eec37..cd5486c1931 100644 --- a/apps/billing-web/src/checkout/checkoutPage.test.ts +++ b/apps/billing-web/src/checkout/checkoutPage.test.ts @@ -134,7 +134,7 @@ describe('reduceCheckoutPage', () => { { name: 'a failed read', events: [unavailable], - expected: { kind: 'unavailable', code: 'REQUEST_FAILED' }, + expected: { kind: 'unavailable', cause: 'quote', code: 'REQUEST_FAILED' }, pay: false }, { @@ -571,7 +571,11 @@ describe('reduceCheckoutPage after Pay', () => { { type: 'requoteFailed', code: 'REQUEST_FAILED' } ]) - expect(page).toEqual({ kind: 'unavailable', code: 'REQUEST_FAILED' }) + expect(page).toEqual({ + kind: 'unavailable', + cause: 'quote', + code: 'REQUEST_FAILED' + }) expect(railAcceptsPay(page)).toBe(false) } ) @@ -936,9 +940,13 @@ describe('reduceCheckoutPage endings', () => { expected: RESOLVING }, { - name: "a re-read of the workspace's payments that fails is its own ending, not a failed load", + name: "a re-read of the workspace's payments that fails is a failed load of the re-read", events: [recheckFailed], - expected: { kind: 'recheck_failed', code: 'REQUEST_FAILED' } + expected: { + kind: 'unavailable', + cause: 'recheck', + code: 'REQUEST_FAILED' + } }, { name: 'Try again after a failed re-read resolves again', @@ -1241,7 +1249,7 @@ describe('isLocked', () => { }, { name: 'unavailable', - page: { kind: 'unavailable', code: 'REQUEST_FAILED' }, + page: { kind: 'unavailable', cause: 'quote', code: 'REQUEST_FAILED' }, locked: false }, { diff --git a/apps/billing-web/src/checkout/checkoutPage.ts b/apps/billing-web/src/checkout/checkoutPage.ts index 033dceed693..5050db439a7 100644 --- a/apps/billing-web/src/checkout/checkoutPage.ts +++ b/apps/billing-web/src/checkout/checkoutPage.ts @@ -105,11 +105,14 @@ type Attribution = 'started' | 'followed' | 'settled' * settles. `unconfirmed` is money whose outcome the page could not learn, so * it neither offers a form nor claims a charge. `sibling` on either marks * money another tab sent while this one had its form open, whose verdict and - * challenge belong to that tab. `recheck_failed` is a re-read of what the - * workspace is waiting on that failed before any form showed, so the page - * cannot say whether money is moving. `terminal` is a payment that went - * through. + * challenge belong to that tab. `unavailable` is a read that failed before + * any form showed: the quote, or the re-read of what the workspace is + * waiting on, after which the page cannot say whether money is moving. + * `terminal` is a payment that went through. */ +/** Which read failed: the quote, or the re-read of the workspace's payments. */ +export type LoadFailure = 'quote' | 'recheck' + export type CheckoutPage = | { readonly kind: 'resolving'; readonly outcome?: InlineOutcome } | { @@ -117,8 +120,11 @@ export type CheckoutPage = readonly reason: CapabilityDenialReason readonly scheduled?: ScheduledChange } - | { readonly kind: 'unavailable'; readonly code: string } - | { readonly kind: 'recheck_failed'; readonly code: string } + | { + readonly kind: 'unavailable' + readonly cause: LoadFailure + readonly code: string + } | { readonly kind: 'plan_unavailable' readonly reason: PlanUnavailableReason @@ -297,20 +303,14 @@ function stoppedOn(event: StopEvent): CheckoutPage { ...(event.scheduled === undefined ? {} : { scheduled: event.scheduled }) } case 'unavailable': - return { kind: 'unavailable', code: event.code } + return { kind: 'unavailable', cause: 'quote', code: event.code } case 'recheckFailed': - return { kind: 'recheck_failed', code: event.code } + return { kind: 'unavailable', cause: 'recheck', code: event.code } case 'planUnavailable': return { kind: 'plan_unavailable', reason: event.reason } } } -/** Try again re-reads a checkout whose load or re-read failed. */ -const RETRYABLE: ReadonlySet = new Set([ - 'unavailable', - 'recheck_failed' -]) - /** An event that means nothing in the current state returns it untouched. */ export function reduceCheckoutPage( page: CheckoutPage, @@ -325,9 +325,13 @@ export function reduceCheckoutPage( case 'planUnavailable': return page.kind === 'resolving' ? stoppedOn(event) : page case 'requoteFailed': - return leavingCapture(page, { kind: 'unavailable', code: event.code }) + return leavingCapture(page, { + kind: 'unavailable', + cause: 'quote', + code: event.code + }) case 'retried': - return RETRYABLE.has(page.kind) ? RESOLVING : page + 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 9bbdf9c7ded..179aec4d9fa 100644 --- a/apps/billing-web/src/checkout/endingScreen.test.ts +++ b/apps/billing-web/src/checkout/endingScreen.test.ts @@ -91,13 +91,13 @@ describe('endingOf', () => { }, { name: 'a checkout that could not load', - page: { kind: 'unavailable', code: 'REQUEST_FAILED' }, - screen: { kind: 'load_failed', code: 'REQUEST_FAILED' } + page: { kind: 'unavailable', cause: 'quote', code: 'REQUEST_FAILED' }, + screen: { kind: 'load_failed', cause: 'quote', code: 'REQUEST_FAILED' } }, { name: "a re-read of the workspace's payments that failed", - page: { kind: 'recheck_failed', code: 'REQUEST_FAILED' }, - screen: { kind: 'recheck_failed', code: 'REQUEST_FAILED' } + page: { kind: 'unavailable', cause: 'recheck', code: 'REQUEST_FAILED' }, + screen: { kind: 'load_failed', cause: 'recheck', code: 'REQUEST_FAILED' } }, { name: 'a plan the catalog lacks', diff --git a/apps/billing-web/src/checkout/endingScreen.ts b/apps/billing-web/src/checkout/endingScreen.ts index 8aed6dc9829..c9d83c6567f 100644 --- a/apps/billing-web/src/checkout/endingScreen.ts +++ b/apps/billing-web/src/checkout/endingScreen.ts @@ -2,6 +2,7 @@ import type { CapabilityDenialReason } from '@comfyorg/account-core/billing' import type { CheckoutPage, + LoadFailure, PlanUnavailableReason, ScheduledChange } from '@/checkout/checkoutPage' @@ -61,8 +62,11 @@ export type EndingScreen = readonly scheduled: ScheduledChange } | { readonly kind: 'plan_unavailable'; readonly code: string } - | { readonly kind: 'load_failed'; readonly code: string } - | { readonly kind: 'recheck_failed'; readonly code: string } + | { + readonly kind: 'load_failed' + readonly cause: LoadFailure + readonly code: string + } export type EndingKind = EndingScreen['kind'] @@ -72,9 +76,7 @@ export function endingOf(page: CheckoutPage): EndingScreen | undefined { case 'refused': return refusedEnding(page) case 'unavailable': - return { kind: 'load_failed', code: page.code } - case 'recheck_failed': - return { kind: 'recheck_failed', code: page.code } + return { kind: 'load_failed', cause: page.cause, code: page.code } case 'plan_unavailable': return { kind: 'plan_unavailable', diff --git a/apps/billing-web/src/components/fullPage/CheckoutEnding.test.ts b/apps/billing-web/src/components/fullPage/CheckoutEnding.test.ts index b08752e7e52..3eb0195011f 100644 --- a/apps/billing-web/src/components/fullPage/CheckoutEnding.test.ts +++ b/apps/billing-web/src/components/fullPage/CheckoutEnding.test.ts @@ -182,7 +182,7 @@ describe('CheckoutEnding', () => { closeLine: false }, { - ending: { kind: 'load_failed', code: 'REQUEST_FAILED' }, + ending: { kind: 'load_failed', cause: 'quote', 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:', @@ -191,16 +191,16 @@ describe('CheckoutEnding', () => { closeLine: false }, { - ending: { kind: 'recheck_failed', code: 'REQUEST_FAILED' }, + ending: { kind: 'load_failed', cause: 'recheck', code: 'REQUEST_FAILED' }, title: "Couldn't load your checkout", - body: "We couldn't check this workspace's payments, so we can't show your checkout yet. Try again, or contact support if this keeps happening.", + body: "We couldn't check your recent payments, so checkout can't open yet. 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.kind reads as designed: $body', ({ ending, title, body, codeLabel, action, support, closeLine }) => { renderEnding(ending) @@ -240,12 +240,12 @@ describe('CheckoutEnding', () => { it.for<{ ending: EndingScreen; action: Action; event: string }>([ { ending: { kind: 'success' }, action: 'Close', event: 'close' }, { - ending: { kind: 'load_failed', code: 'REQUEST_FAILED' }, + ending: { kind: 'load_failed', cause: 'quote', code: 'REQUEST_FAILED' }, action: 'Try again', event: 'retry' }, { - ending: { kind: 'recheck_failed', code: 'REQUEST_FAILED' }, + ending: { kind: 'load_failed', cause: 'recheck', code: 'REQUEST_FAILED' }, action: 'Try again', event: 'retry' }, diff --git a/apps/billing-web/src/components/fullPage/CheckoutEnding.vue b/apps/billing-web/src/components/fullPage/CheckoutEnding.vue index 805ff0285da..22801d95d60 100644 --- a/apps/billing-web/src/components/fullPage/CheckoutEnding.vue +++ b/apps/billing-web/src/components/fullPage/CheckoutEnding.vue @@ -44,8 +44,7 @@ const ENDINGS: Readonly< 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 }, - recheck_failed: { tone: 'refused', primary: 'retry', support: true } + load_failed: { tone: 'refused', primary: 'retry', support: true } } const ICON: Readonly> = { @@ -73,11 +72,12 @@ const { coded } = useHostedCopy() const ending = computed(() => ENDINGS[screen.kind]) const copyKey = computed(() => `checkout.fullPage.ending.${screen.kind}`) -const bodyKey = computed(() => - screen.kind === 'refused' - ? `${copyKey.value}.body.${screen.copy}` - : `${copyKey.value}.body` -) +const bodyKey = computed(() => { + if (screen.kind === 'refused') return `${copyKey.value}.body.${screen.copy}` + if (screen.kind === 'load_failed') + return `${copyKey.value}.body.${screen.cause}` + return `${copyKey.value}.body` +}) const bodyParams = computed(() => screen.kind === 'refused' && screen.copy === 'change_scheduled' ? { diff --git a/apps/billing-web/src/locales/en/main.json b/apps/billing-web/src/locales/en/main.json index fcbf96a0d63..7f980e961b0 100644 --- a/apps/billing-web/src/locales/en/main.json +++ b/apps/billing-web/src/locales/en/main.json @@ -326,12 +326,10 @@ }, "load_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:" - }, - "recheck_failed": { - "title": "Couldn't load your checkout", - "body": "We couldn't check this workspace's payments, so we can't show your checkout yet. Try again, or contact support if this keeps happening.", + "body": { + "quote": "We couldn't load your quote. Nothing has been charged. Try again, or contact support if this keeps happening.", + "recheck": "We couldn't check your recent payments, so checkout can't open yet. Try again, or contact support if this keeps happening." + }, "codeLabel": "If this keeps happening, contact support with this code:" } }, diff --git a/apps/billing-web/src/views/FullPageCheckoutView.test.ts b/apps/billing-web/src/views/FullPageCheckoutView.test.ts index 778fc1da6a8..54d0581d2a7 100644 --- a/apps/billing-web/src/views/FullPageCheckoutView.test.ts +++ b/apps/billing-web/src/views/FullPageCheckoutView.test.ts @@ -1512,6 +1512,11 @@ describe('FullPageCheckoutView mount reconciliation', () => { name: "Couldn't load your checkout" }) ).toBeInTheDocument() + expect( + screen.getByText( + "We couldn't check your recent payments, so checkout can't open yet. Try again, or contact support if this keeps happening." + ) + ).toBeInTheDocument() expect( screen.queryByText(/Nothing has been charged/) ).not.toBeInTheDocument()