Files
ComfyUI_frontend/browser_tests/fixtures/components/TopUpCreditsDialog.ts
Dante 2c772077e0 test: add E2E tests for billing dialogs (CancelSubscription, TopUpCredits) (#10969)
## Summary
- Add Playwright E2E tests for `CancelSubscriptionDialogContent` and
`TopUpCreditsDialogContentLegacy`
- CancelSubscription tests: dialog display with date formatting, keep
subscription dismiss, confirm cancel with mocked API, error handling on
API failure
- TopUpCredits tests: dialog display with preset amounts, insufficient
credits variant, preset selection, close button dismiss, pricing link
visibility

Part of the FixIt Burndown test coverage initiative (Untested Dialogs).

## Test plan
- [ ] Verify tests pass in CI against OSS build
- [ ] `pnpm test:browser:local --
browser_tests/tests/dialogs/cancelSubscriptionDialog.spec.ts`
- [ ] `pnpm test:browser:local --
browser_tests/tests/dialogs/topUpCreditsDialog.spec.ts`

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10969-test-add-E2E-tests-for-billing-dialogs-CancelSubscription-TopUpCredits-33c6d73d36508164b268c08c99464ca1)
by [Unito](https://www.unito.io)
2026-04-21 23:17:58 +00:00

55 lines
1.5 KiB
TypeScript

import type { Locator, Page } from '@playwright/test'
import type { WorkspaceStore } from '@e2e/types/globals'
import { BaseDialog } from '@e2e/fixtures/components/BaseDialog'
export class TopUpCreditsDialog extends BaseDialog {
readonly heading: Locator
readonly insufficientHeading: Locator
readonly preset10: Locator
readonly preset25: Locator
readonly preset50: Locator
readonly preset100: Locator
readonly payAmountInput: Locator
readonly pricingLink: Locator
constructor(page: Page) {
super(page)
this.heading = this.root.getByRole('heading', { name: 'Add more credits' })
this.insufficientHeading = this.root.getByRole('heading', {
name: 'Add more credits to run'
})
this.preset10 = this.root.getByRole('button', {
name: '$10',
exact: true
})
this.preset25 = this.root.getByRole('button', {
name: '$25',
exact: true
})
this.preset50 = this.root.getByRole('button', {
name: '$50',
exact: true
})
this.preset100 = this.root.getByRole('button', {
name: '$100',
exact: true
})
this.payAmountInput = this.root
.getByTestId('top-up-pay-amount')
.locator('input')
this.pricingLink = this.root.getByRole('link', {
name: 'View pricing details'
})
}
async open(options?: { isInsufficientCredits?: boolean }) {
await this.page.evaluate((opts) => {
void (
window.app!.extensionManager as WorkspaceStore
).dialog.showTopUpCreditsDialog(opts)
}, options)
await this.waitForVisible()
}
}