refactor: address CodeRabbit review feedback

- Add subscribeToRunButton to TestIds and use throughout spec
- Import PENDING_SUBSCRIPTION_CHECKOUT_STORAGE_KEY from source
This commit is contained in:
Glary-Bot
2026-04-19 00:13:28 +00:00
committed by bymyself
parent ec86f067a6
commit 28d0c3cfe8
3 changed files with 16 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
import type { Page, Route } from '@playwright/test'
import { PENDING_SUBSCRIPTION_CHECKOUT_STORAGE_KEY } from '@/platform/cloud/subscription/utils/subscriptionCheckoutTracker'
import {
createBalance,
createSubscriptionStatus,
@@ -181,10 +182,11 @@ export class SubscriptionHelper {
tier: string = 'standard',
cycle: string = 'monthly'
): Promise<void> {
const storageKey = PENDING_SUBSCRIPTION_CHECKOUT_STORAGE_KEY
await this.page.evaluate(
([t, c]) => {
([key, t, c]) => {
localStorage.setItem(
'comfy.subscription.pending_checkout_attempt',
key,
JSON.stringify({
attempt_id: `test-${Date.now()}`,
started_at_ms: Date.now(),
@@ -194,7 +196,7 @@ export class SubscriptionHelper {
})
)
},
[tier, cycle] as const
[storageKey, tier, cycle] as const
)
}

View File

@@ -98,6 +98,7 @@ export const TestIds = {
queueModeMenuTrigger: 'queue-mode-menu-trigger',
saveButton: 'save-workflow-button',
subscribeButton: 'topbar-subscribe-button',
subscribeToRunButton: 'subscribe-to-run-button',
loginButton: 'login-button',
loginButtonPopover: 'login-button-popover',
loginButtonPopoverLearnMore: 'login-button-popover-learn-more',

View File

@@ -45,7 +45,7 @@ unsubscribedTest.describe(
'SubscribeToRun visible when unsubscribed',
async ({ comfyPage }) => {
await expect(
comfyPage.page.getByTestId('subscribe-to-run-button')
comfyPage.page.getByTestId(TestIds.topbar.subscribeToRunButton)
).toBeVisible({ timeout: 10_000 })
}
)
@@ -53,7 +53,9 @@ unsubscribedTest.describe(
unsubscribedTest(
'SubscribeToRun click opens subscription dialog',
async ({ comfyPage }) => {
await comfyPage.page.getByTestId('subscribe-to-run-button').click()
await comfyPage.page
.getByTestId(TestIds.topbar.subscribeToRunButton)
.click()
await expect(comfyPage.page.getByRole('dialog')).toBeVisible({
timeout: 10_000
})
@@ -64,7 +66,9 @@ unsubscribedTest.describe(
'SubscribeToRun shows short label on mobile',
{ tag: '@mobile' },
async ({ comfyPage }) => {
const btn = comfyPage.page.getByTestId('subscribe-to-run-button')
const btn = comfyPage.page.getByTestId(
TestIds.topbar.subscribeToRunButton
)
await expect(btn).toBeVisible({ timeout: 10_000 })
await expect(btn).not.toContainText(/to run/i)
}
@@ -104,7 +108,7 @@ unsubscribedTest.describe(
'Subscription state transition updates UI after re-fetch',
async ({ comfyPage, subscriptionHelper }) => {
await expect(
comfyPage.page.getByTestId('subscribe-to-run-button')
comfyPage.page.getByTestId(TestIds.topbar.subscribeToRunButton)
).toBeVisible({ timeout: 10_000 })
// Simulate returning from Stripe checkout: seed pending checkout,
@@ -118,7 +122,7 @@ unsubscribedTest.describe(
await subscriptionHelper.triggerSubscriptionRefetch()
await expect(
comfyPage.page.getByTestId('subscribe-to-run-button')
comfyPage.page.getByTestId(TestIds.topbar.subscribeToRunButton)
).not.toBeVisible({ timeout: 10_000 })
}
)
@@ -170,7 +174,7 @@ subscribedTest.describe(
comfyPage.page.getByTestId(TestIds.topbar.queueButton)
).toBeVisible({ timeout: 10_000 })
await expect(
comfyPage.page.getByTestId('subscribe-to-run-button')
comfyPage.page.getByTestId(TestIds.topbar.subscribeToRunButton)
).toBeHidden()
}
)