From 28d0c3cfe8d153354d60cd19a8d17c92b4905ab7 Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Sun, 19 Apr 2026 00:13:28 +0000 Subject: [PATCH] refactor: address CodeRabbit review feedback - Add subscribeToRunButton to TestIds and use throughout spec - Import PENDING_SUBSCRIPTION_CHECKOUT_STORAGE_KEY from source --- .../fixtures/helpers/SubscriptionHelper.ts | 8 +++++--- browser_tests/fixtures/selectors.ts | 1 + browser_tests/tests/subscription.spec.ts | 16 ++++++++++------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/browser_tests/fixtures/helpers/SubscriptionHelper.ts b/browser_tests/fixtures/helpers/SubscriptionHelper.ts index 6cc61f73e2..936e4429ca 100644 --- a/browser_tests/fixtures/helpers/SubscriptionHelper.ts +++ b/browser_tests/fixtures/helpers/SubscriptionHelper.ts @@ -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 { + 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 ) } diff --git a/browser_tests/fixtures/selectors.ts b/browser_tests/fixtures/selectors.ts index a6e697042b..a247e70dce 100644 --- a/browser_tests/fixtures/selectors.ts +++ b/browser_tests/fixtures/selectors.ts @@ -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', diff --git a/browser_tests/tests/subscription.spec.ts b/browser_tests/tests/subscription.spec.ts index 6a9871c911..9440ed9d86 100644 --- a/browser_tests/tests/subscription.spec.ts +++ b/browser_tests/tests/subscription.spec.ts @@ -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() } )