Repository navigation
[backport cloud/1.53] fix(billing): obtain a server quote before the team confirmation step - #16715
Merged
Merged
Conversation
…#16647) ## Summary With embedded checkout off, the Team confirmation step opened before any quote was requested — so "Total due today" rendered with no amount, and a plan change that could not be priced emptied the dialog entirely. Found on staging during 1.52 QA (Denys), after #16517 fixed the same symptom for Personal. ## Root cause `handleSubscribeTeamClick`'s legacy branch set the step *before* fetching, and then usually never fetched: ```ts checkoutStep.value = 'preview' // step first const needsPreview = payload.isChange || isSubscriptionCancelled() if (!needsPreview || !payload.stop.id) return // fresh subscribe: no request at all ``` `previewData` is reset to `null` immediately above this, so a fresh team subscribe reached the confirmation with no quote. `SubscriptionAddPaymentPreviewWorkspace` renders the total from `previewData`, so the amount and the whole renewal line came out empty. Everything else on that screen ($665, billing cycle, refill credits) is derived from the `teamPlan` prop, which is why the screen looked otherwise healthy. Personal was never affected: `handleSubscribeClick` calls `previewSubscribe` on both sides of the flag and only then advances the step. So #16517 (legacy quote formatting) could not have fixed Team — there was no preview to format. The same early step change produced the empty modal on Team → Change plan. `previewVariant` returns `'team-change'` from `checkoutType` alone, and the two exits at `if (!payload.stop.id) return` and `if (!isSubscriptionCancelled()) return` leave `previewData` null. `SubscriptionTransitionPreviewWorkspace` declares `previewData: PreviewSubscribeResponse` (required) and dereferences it during setup (`previewData.promotion_code`), so setup throws and only the dialog chrome renders. The `:preview-data="previewData!"` assertion at the call site is what kept this off the type checker. ## Changes - **What**: the legacy team path fetches and installs the preview first, and advances to the confirmation only when `isUsableTeamPreview` accepts it — otherwise it reports the failure and stays on pricing, matching the personal and embedded paths. Removed the `previewData!` assertions so a null preview can no longer reach a required prop. The total row is omitted rather than rendered blank when nothing can price it (the id-less OSS stop, the one case with no server quote available). - **Breaking**: a preview failure now blocks a fresh team subscribe instead of showing an unpriced confirmation. This matches what the flag-on path already does. ## Review Focus `isUsableTeamPreview` keeps the three acceptance rules that were previously inline and adds the new-subscription case, which had no rule because it never fetched: cancelled needs a reactivation-capable preview, a change needs an existing-plan transition, a new subscribe needs any allowed preview. Worth knowing for the release call: `embeddedCheckoutEnabled` appears exactly once in `useSubscriptionCheckout.test.ts` — as the `setup()` default of `true`. Every one of the 131 existing tests ran the flag-on branch, so the entire legacy branch shipped uncovered. That is the actual reason this reached staging, and the four new tests are scoped to it. Amounts stay server-resolved throughout; nothing here derives a price from `teamPlan`. - Fixes FE-1974 ## Screenshots (if applicable) Captured against a cloud-distribution dev server with embedded checkout off, driving the real flow: Settings → Plan & Credits → Change plan → pick a different Team credit stop → Change plan. ### AS IS — `main`  The step is entered with `previewData` still null. `SubscriptionTransitionPreviewWorkspace` declares that prop required and dereferences it during setup, so setup throws and the body renders nothing — only the shell's own header is left. This is the same failure QA hit on staging. ### TO BE — this PR > This shot still shows a duplicated "Choose a Plan" header and a second back arrow. That is a separate defect, fixed in #16648 — it is left visible here so this PR's own contribution is legible on its own.  The preview is fetched and installed before the step is entered, so the confirmation renders and `Total due today` is priced from the server's legacy `cost_*` fields — $361.00 here, with the renewal line resolved too. ### TO BE — with #16648 applied as well  How the step looks once both PRs are in. They are two halves of the same report and ship together for 1.52.
Contributor
🎭 Playwright: ✅ 1893 passed, 0 failed📊 Browser Reports
🎨 Storybook: ✅ Built — View Storybook |
dante01yoon
approved these changes
Sep 2, 2026
DrJKL
approved these changes
Sep 2, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## cloud/1.53 #16715 +/- ##
=============================================
Coverage ? 83.29%
=============================================
Files ? 2023
Lines ? 116996
Branches ? 33032
=============================================
Hits ? 97456
Misses ? 19194
Partials ? 346
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #16647 to
cloud/1.53Automatically created by backport workflow.