Repository navigation
feat(billing): show the top-up's real outcome in the dialog — receipt or decline reason #16413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
comfydesigner
wants to merge
12
commits into
comfydesigner/topup-cancel-states
Choose a base branch
from
comfydesigner/topup-outcome-states
base: comfydesigner/topup-cancel-states
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8a7041c
feat(billing): top-up success and declined outcome states
comfydesigner 089f572
fix(billing): match the top-up outcome screens to their designs
comfydesigner f199373
fix(billing): use the designed button fill on the top-up outcomes
comfydesigner a4b670e
Merge branch 'comfydesigner/topup-cancel-states' into comfydesigner/t…
comfydesigner 3fd4516
Merge branch 'comfydesigner/topup-cancel-states' into comfydesigner/t…
comfydesigner 8e52cab
Merge branch 'comfydesigner/topup-cancel-states' into comfydesigner/t…
comfydesigner b9be89a
Merge branch 'comfydesigner/topup-cancel-states' into comfydesigner/t…
comfydesigner 82c675d
refactor(billing): one home for the cancel-payment outcome machine
comfydesigner d40cfd3
fix(billing): top-up outcomes come from the server, on every path
comfydesigner ecd9a94
Merge branch 'comfydesigner/topup-cancel-states' into comfydesigner/t…
comfydesigner 8e56573
fix(billing): an open top-up dialog owns its outcome
comfydesigner 1d5f7e6
Merge branch 'comfydesigner/topup-cancel-states' into comfydesigner/t…
comfydesigner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
73 changes: 73 additions & 0 deletions
73
src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.stories.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import type { Meta, StoryObj } from '@storybook/vue3-vite' | ||
| import { expect, userEvent, within } from 'storybook/test' | ||
|
|
||
| import { creditsToCents } from '@/base/credits/comfyCredits' | ||
| import { setBillingContextMock } from '@/storybook/mocks/useBillingContext' | ||
|
|
||
| import TopUpCreditsDialogContentWorkspace from './TopUpCreditsDialogContentWorkspace.vue' | ||
|
|
||
| /** | ||
| * The top-up dialog's steps (Figma 5624-32438 / 5631:32731). Each story drives | ||
| * the component the way a customer does — the steps are internal state, not | ||
| * props — so the screens shown here are the ones the flow can actually reach. | ||
| */ | ||
| const STARTING_BALANCE = creditsToCents(46_450) | ||
|
|
||
| const meta: Meta<typeof TopUpCreditsDialogContentWorkspace> = { | ||
| title: 'Components/TopUpCreditsDialog', | ||
| component: TopUpCreditsDialogContentWorkspace, | ||
| parameters: { layout: 'centered' }, | ||
| beforeEach: () => { | ||
| setBillingContextMock({ balanceCents: STARTING_BALANCE }) | ||
| } | ||
| } | ||
|
|
||
| export default meta | ||
| type Story = StoryObj<typeof TopUpCreditsDialogContentWorkspace> | ||
|
|
||
| async function goToConfirm(canvasElement: HTMLElement) { | ||
| const canvas = within(canvasElement) | ||
| await userEvent.click(canvas.getByRole('button', { name: 'Add credits' })) | ||
| } | ||
|
|
||
| async function payAndSettle(canvasElement: HTMLElement) { | ||
| const canvas = within(canvasElement) | ||
| await goToConfirm(canvasElement) | ||
| await userEvent.click(canvas.getByRole('button', { name: /^Pay \$/ })) | ||
| } | ||
|
|
||
| /** Step 1 — choose an amount. */ | ||
| export const Amount: Story = {} | ||
|
|
||
| /** Step 2 — confirm the charge. */ | ||
| export const Confirm: Story = { | ||
| play: async ({ canvasElement }) => { | ||
| await goToConfirm(canvasElement) | ||
| } | ||
| } | ||
|
|
||
| /** Step 4 — the charge went through. */ | ||
| export const Success: Story = { | ||
| play: async ({ canvasElement }) => { | ||
| await payAndSettle(canvasElement) | ||
| await expect( | ||
| within(canvasElement).getByText("You're all set") | ||
| ).toBeInTheDocument() | ||
| } | ||
| } | ||
|
|
||
| /** Step 5 — the card was refused. */ | ||
| export const Declined: Story = { | ||
| beforeEach: () => { | ||
| setBillingContextMock({ | ||
| balanceCents: STARTING_BALANCE, | ||
| topupStatus: 'failed' | ||
| }) | ||
| }, | ||
| play: async ({ canvasElement }) => { | ||
| await payAndSettle(canvasElement) | ||
| await expect( | ||
| within(canvasElement).getByText('Payment declined') | ||
| ).toBeInTheDocument() | ||
| } | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 Low — Stubbing
centsToCreditsas identity leaves the only unit conversion in the new balance math unverified — two reviewers readeffectiveBalanceMicros/amountMicrosliterally and called this a 10,000× error, which suggests the field names are worth double-checking even if they do carry cents. Assert the breakdown through the real helper so a wrong-rate or missing conversion fails the test. Raised by 3 of 8 reviewers (gemini-3.1-pro edge-case, gemini-3.1-pro adversarial, claude-opus-5-thinking-max edge-case).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair on principle, but the conversion has its own unit home (comfyCredits); these component tests assert routing and sourcing of the figures, not arithmetic. The identity stub keeps them from becoming change detectors on the rate.