Repository navigation
fix(billing): let unsubscribed workspaces add credits on Local #15799
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c5cb26f
fix(billing): let unsubscribed workspaces add credits on Local
dante01yoon c144da7
fix(billing): keep local team credit top-up instead of the subscribe …
dante01yoon 6619d40
test(billing): cover the workspace-rail credit surfaces
dante01yoon ee3a647
test(billing): exercise the local team add-credits flow
dante01yoon 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { test as base } from '@playwright/test' | ||
|
|
||
| import type { operations } from '@/types/comfyRegistryTypes' | ||
| import { ComfyPage } from '@e2e/fixtures/ComfyPage' | ||
| import { | ||
| createSubscriptionHelper, | ||
| withUnsubscribed | ||
| } from '@e2e/fixtures/helpers/SubscriptionHelper' | ||
| import type { SubscriptionOperator } from '@e2e/fixtures/helpers/SubscriptionHelper' | ||
| import { mockWorkspace, workspace } from '@e2e/fixtures/utils/workspaceMocks' | ||
|
|
||
| type CreateCustomerResponse = | ||
| operations['createCustomer']['responses']['201']['content']['application/json'] | ||
|
|
||
| // The subscription fixture pins billing_rail to legacy_stripe, which routes | ||
| // local billing through the legacy rail and its Local exemption from the | ||
| // subscription gate. The 1.51 QA finding #11 (no way to add credits without | ||
| // an active subscription) only reproduces on the workspace rail, so this | ||
| // fixture overrides the rail; localAuthFixture keeps the legacy-rail | ||
| // coverage. | ||
| const onWorkspaceRail: SubscriptionOperator = (config) => ({ | ||
| ...config, | ||
| status: { ...config.status, billing_rail: 'stripe' } | ||
| }) | ||
|
|
||
| /** | ||
| * Boots the local (non-Cloud) build as a logged-in unsubscribed workspace | ||
| * owner on the workspace billing rail. See localAuthFixture for the boot | ||
| * ordering constraints this mirrors. | ||
| */ | ||
| export const workspaceRailAuthFixture = base.extend<{ comfyPage: ComfyPage }>({ | ||
| comfyPage: async ({ page, request }, use, testInfo) => { | ||
| testInfo.setTimeout(45_000) | ||
|
|
||
| const comfyPage = new ComfyPage(page, request) | ||
| const userId = await comfyPage.setupUser( | ||
| `playwright-workspace-rail-${testInfo.parallelIndex}` | ||
| ) | ||
| await comfyPage.setupSettings({ | ||
| 'Comfy.TutorialCompleted': true, | ||
| 'Comfy.userId': userId | ||
| }) | ||
|
|
||
| await comfyPage.cloudAuth.mockAuth() | ||
| await mockWorkspace(page, workspace('personal', 'owner'), []) | ||
| await page.route('**/customers', (route) => | ||
| route.fulfill({ | ||
| status: 201, | ||
| json: { id: 'test-user-e2e' } satisfies CreateCustomerResponse | ||
| }) | ||
| ) | ||
| await page.route('**/api/billing/balance', (route) => | ||
| route.fulfill({ | ||
| json: { amount_micros: 0, currency: 'usd', effective_balance_micros: 0 } | ||
| }) | ||
| ) | ||
| const subscriptionHelper = createSubscriptionHelper( | ||
| page, | ||
| withUnsubscribed(), | ||
| onWorkspaceRail | ||
| ) | ||
| await subscriptionHelper.mock() | ||
|
|
||
| await page.evaluate((id) => { | ||
| localStorage.clear() | ||
| sessionStorage.clear() | ||
| localStorage.setItem('Comfy.userId', id) | ||
| }, userId) | ||
|
|
||
| await comfyPage.goto() | ||
| await page.waitForFunction(() => document.fonts.ready) | ||
| await comfyPage.waitForAppReady() | ||
|
|
||
| await use(comfyPage) | ||
| await subscriptionHelper.clearMocks() | ||
| } | ||
| }) |
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,55 @@ | ||
| import { expect } from '@playwright/test' | ||
|
|
||
| import { TopUpCreditsDialog } from '@e2e/fixtures/components/TopUpCreditsDialog' | ||
| import { TestIds } from '@e2e/fixtures/selectors' | ||
| import { workspaceRailAuthFixture as test } from '@e2e/fixtures/workspaceRailAuthFixture' | ||
|
|
||
| /** | ||
| * Regression coverage for 1.51 QA finding #11: on a local (non-Cloud) | ||
| * distribution, a workspace without an active subscription had no way to add | ||
| * credits — the subscribe CTA is hidden on Local and both Add credits entry | ||
| * points were gated on an active subscription. Only reproduces on the | ||
| * workspace billing rail; localCreditsNoSubscribeUi.spec.ts covers the | ||
| * legacy rail. | ||
| */ | ||
| test.describe('Local credits surfaces on the workspace billing rail', () => { | ||
| test('lets an unsubscribed workspace owner reach the top-up dialog', async ({ | ||
| comfyPage | ||
| }) => { | ||
| const page = comfyPage.page | ||
| const topUpDialog = new TopUpCreditsDialog(page) | ||
|
|
||
| await page.getByTestId(TestIds.user.currentUserButton).click() | ||
| const popover = page.getByTestId(TestIds.user.currentUserPopover) | ||
| await expect(popover).toBeVisible() | ||
| await expect(popover.getByTestId('add-credits-button')).toBeVisible() | ||
| await expect( | ||
| popover.getByTestId('upgrade-to-add-credits-button') | ||
| ).toHaveCount(0) | ||
| await expect( | ||
| popover.getByRole('button', { name: 'Subscribe', exact: true }) | ||
| ).toHaveCount(0) | ||
|
|
||
| await popover.getByTestId('add-credits-button').click() | ||
| await expect(topUpDialog.heading).toBeVisible() | ||
| await topUpDialog.close() | ||
|
|
||
| await page.getByTestId(TestIds.user.currentUserButton).click() | ||
| await page | ||
| .getByTestId(TestIds.user.currentUserPopover) | ||
| .getByTestId('plans-credits-menu-item') | ||
| .click() | ||
|
|
||
| const settingsDialog = comfyPage.settingDialog | ||
| await settingsDialog.waitForVisible() | ||
| const settingsAddCredits = settingsDialog.contentArea.getByRole('button', { | ||
| name: 'Add credits' | ||
| }) | ||
| await expect(settingsAddCredits).toBeVisible() | ||
| await expect( | ||
| settingsDialog.contentArea.getByText('Upgrade to add credits') | ||
| ).toHaveCount(0) | ||
| await settingsAddCredits.click() | ||
| await expect(topUpDialog.heading).toBeVisible() | ||
| }) | ||
| }) | ||
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
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
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
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
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
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.
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.
Could we move this spec into a feature folder such as
browser_tests/tests/billing/? The browser-test guide asks new specs to be nested by product surface and explicitly rejects new top-leveltests/*.spec.tsfiles.Current-head UI evidence
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.
Moved to browser_tests/tests/billing/localCreditsWorkspaceRail.spec.ts in 7d776fe — thanks for the pointer to the browser-test guide.
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.
Correction: the branch is locked in the merge queue, so the folder move could not be pushed to this PR — it will land as an immediate follow-up PR after this merges.
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.
Follow-up PR with the move: #15831 (main). The core/1.51 backport #15830 already places the spec under tests/billing/.