From 029235a432bbe70aa2fc54cefdae4c62465ecfc5 Mon Sep 17 00:00:00 2001 From: Wei Hai Date: Mon, 19 Oct 2026 20:20:00 -0700 Subject: [PATCH 1/2] [backport cloud/1.56] refactor(billing): retire legacy routing override (#21374) --- .../tests/billingFacadeConsumers.spec.ts | 9 +- src/composables/__mocks__/useFeatureFlags.ts | 1 - .../billing/useBillingContext.test.ts | 5 +- .../billing/useBillingRouting.test.ts | 29 +++---- src/composables/billing/useBillingRouting.ts | 13 +-- src/composables/useFeatureFlags.test.ts | 66 --------------- src/composables/useFeatureFlags.ts | 11 --- .../remoteConfig/__mocks__/remoteConfig.ts | 2 - .../remoteConfig/refreshRemoteConfig.test.ts | 84 ++++++++++--------- .../remoteConfig/refreshRemoteConfig.ts | 7 -- src/platform/remoteConfig/remoteConfig.ts | 2 - src/platform/remoteConfig/types.ts | 1 - src/stores/authStore.test.ts | 14 ++-- 13 files changed, 67 insertions(+), 177 deletions(-) diff --git a/browser_tests/tests/billingFacadeConsumers.spec.ts b/browser_tests/tests/billingFacadeConsumers.spec.ts index bcf1d17434d..50cf528a4fa 100644 --- a/browser_tests/tests/billingFacadeConsumers.spec.ts +++ b/browser_tests/tests/billingFacadeConsumers.spec.ts @@ -207,7 +207,7 @@ test.describe('Billing facade consumers (FE-933)', { tag: '@cloud' }, () => { expect(billingRequests.legacyBalance).toBeGreaterThan(0) }) - test('rollout flag migrates a legacy Stripe workspace to workspace billing', async ({ + test('legacy Stripe workspaces retain legacy billing with stale config', async ({ page }) => { test.setTimeout(60_000) @@ -226,10 +226,13 @@ test.describe('Billing facade consumers (FE-933)', { tag: '@cloud' }, () => { await bootApp(page) await expect - .poll(() => billingRequests.workspaceBalance, { timeout: 30_000 }) + .poll(() => billingRequests.legacyBalance, { timeout: 30_000 }) .toBeGreaterThan(0) + await page.getByRole('button', { name: 'Current user' }).click() + const popover = page.locator('.current-user-popover') + await expect(popover.getByText('12,660')).toBeVisible() + await expect(popover.getByText('0', { exact: true })).toHaveCount(0) expect(billingRequests.legacyStatus).toBe(0) - expect(billingRequests.legacyBalance).toBe(0) }) test('subscribe-to-run routes an inactive FREE user to the pricing table', async ({ diff --git a/src/composables/__mocks__/useFeatureFlags.ts b/src/composables/__mocks__/useFeatureFlags.ts index 1ba8c4b1d42..8c6db6a9e48 100644 --- a/src/composables/__mocks__/useFeatureFlags.ts +++ b/src/composables/__mocks__/useFeatureFlags.ts @@ -32,7 +32,6 @@ const defaultFlags: FeatureFlags = { ssoEnabled: false, billingControlEnabled: false, memberCreditLimitsEnabled: false, - legacyBillingMigrationEnabled: false, embeddedCheckoutEnabled: false, billingSdkTopupEnabled: false, billingSdkTopupRailEnabled: false, diff --git a/src/composables/billing/useBillingContext.test.ts b/src/composables/billing/useBillingContext.test.ts index b7f84cbb02c..2644a953de0 100644 --- a/src/composables/billing/useBillingContext.test.ts +++ b/src/composables/billing/useBillingContext.test.ts @@ -466,11 +466,10 @@ describe('useBillingContext', () => { expect(useAuthActions().purchaseCreditsDirect).toHaveBeenCalledWith(5) }) - it('routes migrated legacy Stripe topups through workspace billing', async () => { - remoteConfig.value = { legacy_billing_migration_enabled: true } + it('routes migrated Stripe topups through workspace billing', async () => { remoteConfigState.value = 'authenticated' authenticatedRemoteConfigState.value = 'authenticated' - mockBillingRail.value = 'legacy_stripe' + mockBillingRail.value = 'stripe' const context = useBillingContext() await nextTick() diff --git a/src/composables/billing/useBillingRouting.test.ts b/src/composables/billing/useBillingRouting.test.ts index 40e993be75f..1033c3e2f2a 100644 --- a/src/composables/billing/useBillingRouting.test.ts +++ b/src/composables/billing/useBillingRouting.test.ts @@ -4,7 +4,6 @@ import { storeToRefs } from 'pinia' import type { Ref } from 'vue' import { fromPartial } from '@total-typescript/shoehorn' -import { useFeatureFlags } from '@/composables/useFeatureFlags' import type { BillingRail } from '@/platform/workspace/api/workspaceApi' import { useBillingRouting } from './useBillingRouting' @@ -16,7 +15,6 @@ let mockActiveWorkspace: Ref< > let mockActiveWorkspaceBillingRail: Ref -vi.mock(import('@/composables/useFeatureFlags')) vi.mock(import('@/platform/distribution/types'), () => ({ get isCloud() { return mockIsCloud.value @@ -78,25 +76,18 @@ describe('useBillingRouting', () => { expect(shouldUseUnifiedPricing.value).toBe(true) }) - it('migrates legacy Stripe personal workspaces behind the rollout flag', () => { - vi.mocked(useFeatureFlags().flags).legacyBillingMigrationEnabled = true - mockActiveWorkspaceBillingRail.value = 'legacy_stripe' + it.for(['stripe', 'metronome'] as const)( + 'uses workspace billing for personal workspaces on %s', + (rail) => { + mockActiveWorkspace.value = personal + mockActiveWorkspaceBillingRail.value = rail - const { type, shouldUseWorkspaceBilling } = useBillingRouting() + const { type, shouldUseWorkspaceBilling } = useBillingRouting() - expect(type.value).toBe('workspace') - expect(shouldUseWorkspaceBilling.value).toBe(true) - }) - - it('uses workspace billing for migrated Stripe personal workspaces', () => { - mockActiveWorkspace.value = personal - mockActiveWorkspaceBillingRail.value = 'stripe' - - const { type, shouldUseWorkspaceBilling } = useBillingRouting() - - expect(type.value).toBe('workspace') - expect(shouldUseWorkspaceBilling.value).toBe(true) - }) + expect(type.value).toBe('workspace') + expect(shouldUseWorkspaceBilling.value).toBe(true) + } + ) it('uses workspace billing for team workspaces', () => { mockActiveWorkspace.value = team diff --git a/src/composables/billing/useBillingRouting.ts b/src/composables/billing/useBillingRouting.ts index d2e498842ce..627a4dfe641 100644 --- a/src/composables/billing/useBillingRouting.ts +++ b/src/composables/billing/useBillingRouting.ts @@ -1,22 +1,12 @@ import { computed } from 'vue' -import { useFeatureFlags } from '@/composables/useFeatureFlags' import { isCloud } from '@/platform/distribution/types' import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore' import { usesLegacyAccountOperations } from './billingRail' import type { BillingType } from './types' -/** - * Selects the billing backend for the active workspace: legacy user-scoped - * (`/customers/*`) or workspace-scoped (`/api/billing/*`). Personal workspaces - * use workspace billing unless an explicit legacy Stripe rail selects legacy - * account operations and its migration flag is off. Until a workspace loads - * the type is `unknown`; Local/Desktop resolves to workspace billing once its - * Cloud-backed workspace context loads. - */ export function useBillingRouting() { - const { flags } = useFeatureFlags() const workspaceStore = useTeamWorkspaceStore() const shouldUseUnifiedPricing = computed(() => { @@ -29,8 +19,7 @@ export function useBillingRouting() { if ( workspaceType === 'personal' && - usesLegacyAccountOperations(workspaceStore.activeWorkspaceBillingRail) && - !flags.legacyBillingMigrationEnabled + usesLegacyAccountOperations(workspaceStore.activeWorkspaceBillingRail) ) { return 'legacy' } diff --git a/src/composables/useFeatureFlags.test.ts b/src/composables/useFeatureFlags.test.ts index f76a6bbc0ce..8a4106a1436 100644 --- a/src/composables/useFeatureFlags.test.ts +++ b/src/composables/useFeatureFlags.test.ts @@ -18,7 +18,6 @@ import * as distributionTypes from '@/platform/distribution/types' import { authenticatedRemoteConfigState, cachedBillingControlEnabled, - cachedLegacyBillingMigrationEnabled, cachedV1PaymentRecovery, remoteConfig, remoteConfigState, @@ -560,66 +559,6 @@ describe('useFeatureFlags', () => { }) }) - describe('legacyBillingMigrationEnabled', () => { - beforeEach(() => { - vi.mocked(distributionTypes).isCloud = true - authenticatedRemoteConfigState.value = 'authenticated' - remoteConfigState.value = 'authenticated' - }) - - afterEach(() => { - vi.mocked(distributionTypes).isCloud = false - authenticatedRemoteConfigState.value = 'unloaded' - remoteConfigState.value = 'unloaded' - remoteConfig.value = {} - cachedLegacyBillingMigrationEnabled.value = undefined - }) - - it('migrates legacy billing when enabled by remote config', () => { - remoteConfig.value = { legacy_billing_migration_enabled: true } - - const { flags } = useFeatureFlags() - - expect(flags.legacyBillingMigrationEnabled).toBe(true) - }) - - it('keeps migration off when remote config explicitly disables it', () => { - remoteConfig.value = { legacy_billing_migration_enabled: false } - vi.mocked(api.getServerFeature).mockReturnValue(true) - - const { flags } = useFeatureFlags() - - expect(flags.legacyBillingMigrationEnabled).toBe(false) - }) - - it('uses the server feature when authenticated config leaves it unset', () => { - vi.mocked(api.getServerFeature).mockImplementation( - (path, defaultValue) => - path === ServerFeatureFlag.LEGACY_BILLING_MIGRATION_ENABLED - ? true - : defaultValue - ) - - const { flags } = useFeatureFlags() - - expect(flags.legacyBillingMigrationEnabled).toBe(true) - expect(api.getServerFeature).toHaveBeenCalledWith( - ServerFeatureFlag.LEGACY_BILLING_MIGRATION_ENABLED, - false - ) - }) - - it('keeps legacy billing when the rollout flag is unset', () => { - vi.mocked(api.getServerFeature).mockImplementation( - (_path, defaultValue) => defaultValue - ) - - const { flags } = useFeatureFlags() - - expect(flags.legacyBillingMigrationEnabled).toBe(false) - }) - }) - describe('onboardingTourEnabled', () => { afterEach(() => { remoteConfig.value = {} @@ -709,7 +648,6 @@ describe('useFeatureFlags', () => { remoteConfigState.value = 'unloaded' remoteConfig.value = {} cachedBillingControlEnabled.value = undefined - cachedLegacyBillingMigrationEnabled.value = undefined cachedV1PaymentRecovery.value = undefined }) @@ -718,25 +656,21 @@ describe('useFeatureFlags', () => { remoteConfigState.value = 'unloaded' remoteConfig.value = {} cachedBillingControlEnabled.value = undefined - cachedLegacyBillingMigrationEnabled.value = undefined cachedV1PaymentRecovery.value = undefined }) it('returns the cached session value during the auth window', () => { cachedBillingControlEnabled.value = true - cachedLegacyBillingMigrationEnabled.value = true cachedV1PaymentRecovery.value = true const { flags } = useFeatureFlags() expect(flags.billingControlEnabled).toBe(true) - expect(flags.legacyBillingMigrationEnabled).toBe(true) expect(flags.v1PaymentRecovery).toBe(true) }) it('defaults to false during the auth window when nothing is cached', () => { const { flags } = useFeatureFlags() expect(flags.billingControlEnabled).toBe(false) - expect(flags.legacyBillingMigrationEnabled).toBe(false) expect(flags.v1PaymentRecovery).toBe(false) }) diff --git a/src/composables/useFeatureFlags.ts b/src/composables/useFeatureFlags.ts index 884ebb7ad4c..4179b676399 100644 --- a/src/composables/useFeatureFlags.ts +++ b/src/composables/useFeatureFlags.ts @@ -5,7 +5,6 @@ import { normalizeHostedBillingDestination } from '@/config/billingWeb' import { isCloud, isNightly } from '@/platform/distribution/types' import { cachedBillingControlEnabled, - cachedLegacyBillingMigrationEnabled, cachedV1PaymentRecovery, isAuthenticatedConfigLoaded, remoteConfig, @@ -44,7 +43,6 @@ export enum ServerFeatureFlag { SSO_ENABLED = 'sso_enabled', BILLING_CONTROL_ENABLED = 'billing_control_enabled', MEMBER_CREDIT_LIMITS_ENABLED = 'member_credit_limits_enabled', - LEGACY_BILLING_MIGRATION_ENABLED = 'legacy_billing_migration_enabled', EMBEDDED_CHECKOUT_ENABLED = 'embedded_checked_enabled', BILLING_SDK_TOPUP_ENABLED = 'billing_sdk_topup_enabled', BILLING_SDK_SUBSCRIPTION_ENABLED = 'billing_sdk_subscription_enabled', @@ -317,13 +315,6 @@ export function useFeatureFlags() { remoteConfig.value.member_credit_limits_enabled ) }, - get legacyBillingMigrationEnabled() { - return resolveAuthGatedFlag( - ServerFeatureFlag.LEGACY_BILLING_MIGRATION_ENABLED, - remoteConfig.value.legacy_billing_migration_enabled, - cachedLegacyBillingMigrationEnabled - ) - }, get embeddedCheckoutEnabled() { return resolveStrictBooleanFlag( ServerFeatureFlag.EMBEDDED_CHECKOUT_ENABLED, @@ -445,8 +436,6 @@ export function startFeatureFlagTelemetry() { [ServerFeatureFlag.BILLING_CONTROL_ENABLED]: flags.billingControlEnabled, [ServerFeatureFlag.MEMBER_CREDIT_LIMITS_ENABLED]: flags.memberCreditLimitsEnabled, - [ServerFeatureFlag.LEGACY_BILLING_MIGRATION_ENABLED]: - flags.legacyBillingMigrationEnabled, [ServerFeatureFlag.EMBEDDED_CHECKOUT_ENABLED]: flags.embeddedCheckoutEnabled, [ServerFeatureFlag.BILLING_SDK_TOPUP_ENABLED]: diff --git a/src/platform/remoteConfig/__mocks__/remoteConfig.ts b/src/platform/remoteConfig/__mocks__/remoteConfig.ts index d6a0265b621..360bde35119 100644 --- a/src/platform/remoteConfig/__mocks__/remoteConfig.ts +++ b/src/platform/remoteConfig/__mocks__/remoteConfig.ts @@ -54,7 +54,6 @@ const remoteConfigModule: typeof realRemoteConfig = { return remoteConfig[key] || defaultValue }, cachedBillingControlEnabled: testScopedRemovableRef(undefined), - cachedLegacyBillingMigrationEnabled: testScopedRef(undefined), cachedV1PaymentRecovery: testScopedRemovableRef(undefined), sessionAgentGrant: testScopedRef(undefined), sessionAgentGrantValidUntil: testScopedRef(undefined) @@ -69,7 +68,6 @@ export const { remoteConfig, configValueOrDefault, cachedBillingControlEnabled, - cachedLegacyBillingMigrationEnabled, sessionAgentGrant, sessionAgentGrantValidUntil, cachedV1PaymentRecovery diff --git a/src/platform/remoteConfig/refreshRemoteConfig.test.ts b/src/platform/remoteConfig/refreshRemoteConfig.test.ts index 390d409b8d1..5e3e2cd9b53 100644 --- a/src/platform/remoteConfig/refreshRemoteConfig.test.ts +++ b/src/platform/remoteConfig/refreshRemoteConfig.test.ts @@ -9,7 +9,6 @@ import { import { authenticatedRemoteConfigState, cachedBillingControlEnabled, - cachedLegacyBillingMigrationEnabled, cachedV1PaymentRecovery, remoteConfig, remoteConfigErrorStatus, @@ -62,7 +61,6 @@ describe('refreshRemoteConfig', () => { remoteConfigState.value = 'unloaded' authenticatedRemoteConfigState.value = 'unloaded' remoteConfigRevision.value = 0 - cachedLegacyBillingMigrationEnabled.value = undefined cachedBillingControlEnabled.value = undefined cachedV1PaymentRecovery.value = undefined sessionAgentGrant.value = undefined @@ -156,16 +154,6 @@ describe('refreshRemoteConfig', () => { expect(authenticatedRemoteConfigState.value).toBe('error') }) - it('caches authenticated legacy billing migration eligibility', async () => { - mockAuthenticatedFetch( - mockSuccessResponse({ legacy_billing_migration_enabled: true }) - ) - - await refreshRemoteConfig() - - expect(cachedLegacyBillingMigrationEnabled.value).toBe(true) - }) - it('passes an AbortSignal on the authenticated branch', async () => { mockAuthenticatedFetch(mockSuccessResponse()) @@ -175,31 +163,51 @@ describe('refreshRemoteConfig', () => { expect(init?.signal).toBeInstanceOf(AbortSignal) }) - it('discards a failed response from a superseded refresh', async () => { - let resolveFirst: ((response: Response) => void) | undefined - vi.mocked(api.fetchApi) - .mockImplementationOnce( - (_route, options) => - new Promise((resolve) => { - options?.onAuthHeader?.(true) - resolveFirst = resolve - }) - ) - .mockImplementationOnce(async (_route, options) => { - options?.onAuthHeader?.(true) - return mockSuccessResponse({ subscription_required: true }) - }) + it.for([200, 401])( + 'discards a superseded response with status %s without changing cached flags', + async (status) => { + const latestConfig = { + subscription_required: true, + billing_control_enabled: false, + v1_payment_recovery: false + } + let resolveFirst: ((response: Response) => void) | undefined + vi.mocked(api.fetchApi) + .mockImplementationOnce( + (_route, options) => + new Promise((resolve) => { + options?.onAuthHeader?.(true) + resolveFirst = resolve + }) + ) + .mockImplementationOnce(async (_route, options) => { + options?.onAuthHeader?.(true) + return mockSuccessResponse(latestConfig) + }) - const firstRefresh = refreshRemoteConfig({ useAuth: true }) - await vi.waitFor(() => expect(api.fetchApi).toHaveBeenCalledTimes(1)) - await refreshRemoteConfig({ useAuth: true }) - resolveFirst?.(mockErrorResponse(401, 'Unauthorized')) - await firstRefresh + const firstRefresh = refreshRemoteConfig({ useAuth: true }) + await vi.waitFor(() => expect(api.fetchApi).toHaveBeenCalledTimes(1)) + await refreshRemoteConfig({ useAuth: true }) + expect(cachedBillingControlEnabled.value).toBe(false) + expect(cachedV1PaymentRecovery.value).toBe(false) + resolveFirst?.( + new Response( + JSON.stringify({ + billing_control_enabled: true, + v1_payment_recovery: true + }), + { status } + ) + ) + await firstRefresh - expect(remoteConfig.value).toEqual({ subscription_required: true }) - expect(remoteConfigState.value).toBe('authenticated') - expect(remoteConfigErrorStatus.value).toBeNull() - }) + expect(remoteConfig.value).toEqual(latestConfig) + expect(remoteConfigState.value).toBe('authenticated') + expect(remoteConfigErrorStatus.value).toBeNull() + expect(cachedBillingControlEnabled.value).toBe(false) + expect(cachedV1PaymentRecovery.value).toBe(false) + } + ) it('preserves shared state when the caller cancels the refresh', async () => { const existingConfig = { subscription_required: true } @@ -257,7 +265,6 @@ describe('refreshRemoteConfig', () => { describe('without auth', () => { it('builds the no-auth url via api.apiURL so a path prefix is respected', async () => { - cachedLegacyBillingMigrationEnabled.value = true vi.mocked(global.fetch).mockResolvedValue(mockSuccessResponse()) await refreshRemoteConfig({ useAuth: false }) @@ -270,7 +277,6 @@ describe('refreshRemoteConfig', () => { expect(api.fetchApi).not.toHaveBeenCalled() expect(remoteConfig.value).toEqual(mockConfig) expect(window.__CONFIG__).toEqual(mockConfig) - expect(cachedLegacyBillingMigrationEnabled.value).toBe(true) }) it('clears authenticated state and its grant when anonymous config commits', async () => { @@ -356,14 +362,12 @@ describe('refreshRemoteConfig', () => { describe('error handling', () => { it('clears config on 401 response', async () => { - cachedLegacyBillingMigrationEnabled.value = true mockAuthenticatedFetch(mockErrorResponse(401, 'Unauthorized')) await refreshRemoteConfig() expect(remoteConfig.value).toEqual({}) expect(window.__CONFIG__).toEqual({}) - expect(cachedLegacyBillingMigrationEnabled.value).toBeUndefined() }) it("records this session's grant without persisting it anywhere", async () => { @@ -432,7 +436,6 @@ describe('refreshRemoteConfig', () => { subscription_required: true, comfy_cloud_base_url: 'https://cloud.example.com' } - cachedLegacyBillingMigrationEnabled.value = true remoteConfig.value = existingConfig window.__CONFIG__ = existingConfig vi.mocked(api.fetchApi).mockRejectedValue(new Error('Network error')) @@ -441,7 +444,6 @@ describe('refreshRemoteConfig', () => { expect(remoteConfig.value).toEqual(existingConfig) expect(window.__CONFIG__).toEqual(existingConfig) - expect(cachedLegacyBillingMigrationEnabled.value).toBeUndefined() }) it('preserves config on 500 response', async () => { diff --git a/src/platform/remoteConfig/refreshRemoteConfig.ts b/src/platform/remoteConfig/refreshRemoteConfig.ts index 78e970e6221..6054b0f3139 100644 --- a/src/platform/remoteConfig/refreshRemoteConfig.ts +++ b/src/platform/remoteConfig/refreshRemoteConfig.ts @@ -5,7 +5,6 @@ import { isCloud } from '@/platform/distribution/types' import { authenticatedRemoteConfigState, cachedBillingControlEnabled, - cachedLegacyBillingMigrationEnabled, cachedV1PaymentRecovery, remoteConfig, remoteConfigErrorStatus, @@ -70,7 +69,6 @@ export function invalidateRemoteConfig(): void { remoteConfigErrorStatus.value = null remoteConfigState.value = 'unloaded' authenticatedRemoteConfigState.value = 'unloaded' - cachedLegacyBillingMigrationEnabled.value = undefined clearSessionAgentGrant() } @@ -111,9 +109,6 @@ function commitRemoteConfigSuccess( authenticatedRemoteConfigState.value = 'authenticated' authenticatedLoadingGeneration = undefined cachedBillingControlEnabled.value = Boolean(config.billing_control_enabled) - cachedLegacyBillingMigrationEnabled.value = Boolean( - config.legacy_billing_migration_enabled - ) cachedV1PaymentRecovery.value = Boolean(config.v1_payment_recovery) cacheSessionAgentGrant(config['agent-in-app-experience'] === true) } else { @@ -162,7 +157,6 @@ function commitRemoteConfigFailure(response: Response, useAuth: boolean): void { } else { remoteConfigErrorStatus.value = null } - if (useAuth) cachedLegacyBillingMigrationEnabled.value = undefined if (useAuth) { authenticatedRemoteConfigState.value = 'error' authenticatedLoadingGeneration = undefined @@ -174,7 +168,6 @@ function commitRemoteConfigFailure(response: Response, useAuth: boolean): void { function commitRemoteConfigException(error: unknown, useAuth: boolean): void { console.error('Failed to fetch remote config:', error) remoteConfigErrorStatus.value = null - if (useAuth) cachedLegacyBillingMigrationEnabled.value = undefined if (useAuth) { authenticatedRemoteConfigState.value = 'error' authenticatedLoadingGeneration = undefined diff --git a/src/platform/remoteConfig/remoteConfig.ts b/src/platform/remoteConfig/remoteConfig.ts index 136d656002b..c5d7db01d3c 100644 --- a/src/platform/remoteConfig/remoteConfig.ts +++ b/src/platform/remoteConfig/remoteConfig.ts @@ -67,8 +67,6 @@ export const cachedBillingControlEnabled = useStorage( undefined ) -export const cachedLegacyBillingMigrationEnabled = ref() - /** * Last authenticated answer for the agent allowlist, so a transient /features * failure cannot unmount the panel mid-session. Deliberately NOT `useStorage` diff --git a/src/platform/remoteConfig/types.ts b/src/platform/remoteConfig/types.ts index 604efec7798..9b413bc12b6 100644 --- a/src/platform/remoteConfig/types.ts +++ b/src/platform/remoteConfig/types.ts @@ -136,7 +136,6 @@ export type RemoteConfig = Partial & { billing_sdk_subscription_enabled?: boolean billing_control_enabled?: boolean member_credit_limits_enabled?: boolean - legacy_billing_migration_enabled?: boolean v1_payment_recovery?: boolean sentry_dsn?: string turnstile_sitekey?: string diff --git a/src/stores/authStore.test.ts b/src/stores/authStore.test.ts index 4dc9ea8ce31..d8e8fdde568 100644 --- a/src/stores/authStore.test.ts +++ b/src/stores/authStore.test.ts @@ -22,7 +22,6 @@ import { requestOnboardingReplay } from '@/platform/onboarding/onboardingReplay' import { - cachedLegacyBillingMigrationEnabled, remoteConfig, remoteConfigState } from '@/platform/remoteConfig/remoteConfig' @@ -2626,7 +2625,7 @@ describe('useAuthStore', () => { .mockImplementationOnce(async (_route, options) => { options?.onAuthHeader?.(true) return new Response( - JSON.stringify({ legacy_billing_migration_enabled: false }), + JSON.stringify({ subscription_required: false }), { status: 200 } ) }) @@ -2637,19 +2636,16 @@ describe('useAuthStore', () => { authStateCallback(accountB) expect(accountASignal?.aborted).toBe(true) expect(remoteConfigState.value).toBe('unloaded') - expect(cachedLegacyBillingMigrationEnabled.value).toBeUndefined() await refreshRemoteConfig() resolveAccountA?.( - new Response( - JSON.stringify({ legacy_billing_migration_enabled: true }), - { status: 200 } - ) + new Response(JSON.stringify({ subscription_required: true }), { + status: 200 + }) ) await accountARefresh - expect(remoteConfig.value.legacy_billing_migration_enabled).toBe(false) - expect(cachedLegacyBillingMigrationEnabled.value).toBe(false) + expect(remoteConfig.value.subscription_required).toBe(false) }) it('does not reconnect on a same-account token refresh', () => { From 937c843a33935a1af01698fc9cf85c54001200fe Mon Sep 17 00:00:00 2001 From: Wei Hai Date: Mon, 19 Oct 2026 20:41:59 -0700 Subject: [PATCH 2/2] test(billing): select the user popover by test id --- browser_tests/tests/billingFacadeConsumers.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser_tests/tests/billingFacadeConsumers.spec.ts b/browser_tests/tests/billingFacadeConsumers.spec.ts index 50cf528a4fa..edc775e55fa 100644 --- a/browser_tests/tests/billingFacadeConsumers.spec.ts +++ b/browser_tests/tests/billingFacadeConsumers.spec.ts @@ -229,7 +229,7 @@ test.describe('Billing facade consumers (FE-933)', { tag: '@cloud' }, () => { .poll(() => billingRequests.legacyBalance, { timeout: 30_000 }) .toBeGreaterThan(0) await page.getByRole('button', { name: 'Current user' }).click() - const popover = page.locator('.current-user-popover') + const popover = page.getByTestId('current-user-popover') await expect(popover.getByText('12,660')).toBeVisible() await expect(popover.getByText('0', { exact: true })).toHaveCount(0) expect(billingRequests.legacyStatus).toBe(0)