From 19331428e87babcb01ff7baeda990a7880851af1 Mon Sep 17 00:00:00 2001 From: Dante <6510430+dante01yoon@users.noreply.github.com> Date: Tue, 4 Aug 2026 03:13:24 +0000 Subject: [PATCH 1/8] feat: retire team workspace rollout flags Amp-Thread-ID: https://ampcode.com/threads/T-019fc8cd-b288-7161-a590-cd76d51212bf Co-authored-by: Amp --- browser_tests/fixtures/data/cloudWorkspace.ts | 7 +- .../fixtures/data/workspaceSwitcher.ts | 1 - .../helpers/CloudWorkspaceMockHelper.ts | 6 +- browser_tests/fixtures/utils/cloudAppSetup.ts | 1 - browser_tests/tests/authAccountSwitch.spec.ts | 6 +- .../tests/billingFacadeConsumers.spec.ts | 97 ++++++---- .../tests/currentUserPopoverCredits.spec.ts | 9 +- .../tests/dialogs/creditsTile.spec.ts | 12 +- .../dialogs/pricingTableDeepLink.spec.ts | 4 - .../topbar/CurrentUserButton.test.ts | 15 -- src/components/topbar/CurrentUserButton.vue | 14 +- .../billing/useBillingContext.test.ts | 170 +++++------------- src/composables/billing/useBillingContext.ts | 4 +- .../billing/useBillingRouting.test.ts | 87 +++++---- src/composables/billing/useBillingRouting.ts | 13 +- src/composables/useFeatureFlags.test.ts | 19 -- src/composables/useFeatureFlags.ts | 20 --- src/composables/useUrlActionLoaders.test.ts | 20 +-- src/composables/useUrlActionLoaders.ts | 8 +- .../auth/session/useSessionCookie.test.ts | 9 - src/platform/auth/session/useSessionCookie.ts | 20 +-- .../remoteConfig/refreshRemoteConfig.ts | 4 - src/platform/remoteConfig/remoteConfig.ts | 10 +- src/platform/remoteConfig/types.ts | 1 - .../settings/composables/useSettingUI.test.ts | 14 +- .../settings/composables/useSettingUI.ts | 17 +- .../composables/useSettingsDialog.test.ts | 15 +- .../settings/composables/useSettingsDialog.ts | 5 +- .../workspace/auth/WorkspaceAuthGate.test.ts | 29 +-- .../workspace/auth/WorkspaceAuthGate.vue | 21 +-- .../SubscriptionCheckoutSteps.stories.ts | 2 +- .../SubscriptionSuccessWorkspace.test.ts | 15 -- .../SubscriptionSuccessWorkspace.vue | 6 +- .../components/UnifiedPricingTable.stories.ts | 5 +- .../components/UnifiedPricingTable.test.ts | 10 -- .../components/UnifiedPricingTable.vue | 13 +- .../workspace/stores/useWorkspaceAuth.test.ts | 83 --------- .../workspace/stores/workspaceAuthStore.ts | 15 +- .../__tests__/authTokenPriority.test.ts | 24 +-- src/stores/authStore.test.ts | 10 -- src/stores/authStore.ts | 6 +- src/storybook/mocks/useFeatureFlags.ts | 5 +- src/utils/devFeatureFlagOverride.ts | 4 +- 43 files changed, 214 insertions(+), 642 deletions(-) diff --git a/browser_tests/fixtures/data/cloudWorkspace.ts b/browser_tests/fixtures/data/cloudWorkspace.ts index cd8a900bd44..86cd0bbd263 100644 --- a/browser_tests/fixtures/data/cloudWorkspace.ts +++ b/browser_tests/fixtures/data/cloudWorkspace.ts @@ -7,12 +7,7 @@ import type { } from '@/platform/workspace/api/workspaceApi' import type { RemoteConfig } from '@/platform/remoteConfig/types' -// `/api/features` is the remote-config source: production builds resolve the -// workspaces flag from it (the `ff:` localStorage override is dev-only). -export const WORKSPACE_FEATURE_FLAG: RemoteConfig = { - team_workspaces_enabled: true, - consolidated_billing_enabled: true -} +export const CLOUD_REMOTE_CONFIG: RemoteConfig = {} export const TEAM_WORKSPACE: WorkspaceWithRole = { id: 'ws-team', diff --git a/browser_tests/fixtures/data/workspaceSwitcher.ts b/browser_tests/fixtures/data/workspaceSwitcher.ts index d28a6f3a257..d6593f20088 100644 --- a/browser_tests/fixtures/data/workspaceSwitcher.ts +++ b/browser_tests/fixtures/data/workspaceSwitcher.ts @@ -8,7 +8,6 @@ export const TEAM_WORKSPACE_NAME = 'Team Workspace' export const OFF_SCREEN_WORKSPACE_NAME = 'Off-screen Team Workspace' export const WORKSPACE_SWITCHER_REMOTE_CONFIG: RemoteConfig = { - team_workspaces_enabled: true, unified_cloud_auth: true } diff --git a/browser_tests/fixtures/helpers/CloudWorkspaceMockHelper.ts b/browser_tests/fixtures/helpers/CloudWorkspaceMockHelper.ts index ff5b29227a9..b17f4bbba28 100644 --- a/browser_tests/fixtures/helpers/CloudWorkspaceMockHelper.ts +++ b/browser_tests/fixtures/helpers/CloudWorkspaceMockHelper.ts @@ -9,11 +9,11 @@ import type { import { mockSystemStats } from '@e2e/fixtures/data/systemStats' import { + CLOUD_REMOTE_CONFIG, DEFAULT_TEAM_MEMBERS, TEAM_BILLING_STATUS, TEAM_PRO_PLAN, - TEAM_WORKSPACE, - WORKSPACE_FEATURE_FLAG + TEAM_WORKSPACE } from '@e2e/fixtures/data/cloudWorkspace' import { CloudAuthHelper } from '@e2e/fixtures/helpers/CloudAuthHelper' import { mockWorkspaceTokenMint } from '@e2e/fixtures/utils/workspaceMocks' @@ -71,7 +71,7 @@ export class CloudWorkspaceMockHelper { const { page } = this await page.route('**/api/features', (r) => - r.fulfill(jsonRoute(WORKSPACE_FEATURE_FLAG)) + r.fulfill(jsonRoute(CLOUD_REMOTE_CONFIG)) ) await page.route('**/api/system_stats', (r) => r.fulfill(jsonRoute(mockSystemStats)) diff --git a/browser_tests/fixtures/utils/cloudAppSetup.ts b/browser_tests/fixtures/utils/cloudAppSetup.ts index d56f8bdd929..0d3aabc96c7 100644 --- a/browser_tests/fixtures/utils/cloudAppSetup.ts +++ b/browser_tests/fixtures/utils/cloudAppSetup.ts @@ -18,7 +18,6 @@ export const APP_URL = // billing surfaces the cloud specs assert; without it they fall back to the // legacy variants. const DEFAULT_FEATURES = { - team_workspaces_enabled: true, consolidated_billing_enabled: true } satisfies RemoteConfig diff --git a/browser_tests/tests/authAccountSwitch.spec.ts b/browser_tests/tests/authAccountSwitch.spec.ts index e6e5b88e2e9..c81476f3450 100644 --- a/browser_tests/tests/authAccountSwitch.spec.ts +++ b/browser_tests/tests/authAccountSwitch.spec.ts @@ -6,9 +6,9 @@ import type { WorkspaceTokenResponse } from '@/platform/workspace/stores/workspa import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage' import { AssetsSidebarTab } from '@e2e/fixtures/components/SidebarTab' import { + CLOUD_REMOTE_CONFIG, DEFAULT_TEAM_MEMBERS, - TEAM_WORKSPACE, - WORKSPACE_FEATURE_FLAG + TEAM_WORKSPACE } from '@e2e/fixtures/data/cloudWorkspace' import { AssetsHelper, createMockJob } from '@e2e/fixtures/helpers/AssetsHelper' import { CloudWorkspaceMockHelper } from '@e2e/fixtures/helpers/CloudWorkspaceMockHelper' @@ -141,7 +141,7 @@ test.describe('Cloud account switch', { tag: '@cloud' }, () => { await page.unroute('**/securetoken.googleapis.com/**') const features = { - ...WORKSPACE_FEATURE_FLAG, + ...CLOUD_REMOTE_CONFIG, onboarding_survey_enabled: false, unified_cloud_auth: false } satisfies RemoteConfig diff --git a/browser_tests/tests/billingFacadeConsumers.spec.ts b/browser_tests/tests/billingFacadeConsumers.spec.ts index f702b221711..fbc162b68b9 100644 --- a/browser_tests/tests/billingFacadeConsumers.spec.ts +++ b/browser_tests/tests/billingFacadeConsumers.spec.ts @@ -19,11 +19,9 @@ import { /** * Billing facade consumers — FE-933 (B3) regression. * - * The repointed surfaces (avatar popover tier badge / balance, free-tier - * dialog renewal date) must keep rendering from `useBillingContext`. The facade - * selects its backend by flag: `team_workspaces_enabled: false` routes through - * the legacy `/customers/*` endpoints, while `true` routes a personal workspace - * through the workspace `/api/billing/*` endpoints. Both shapes are mocked here. + * The repointed surfaces (avatar popover balance, free-tier dialog renewal + * date) must keep rendering from `useBillingContext`. Cloud + * personal workspaces route through the workspace `/api/billing/*` endpoints. * Drives a raw `page` (not the `comfyPage` fixture) so the cloud app boots * against fully mocked endpoints — same pattern as creditsTile.spec.ts. */ @@ -56,11 +54,24 @@ const mockBalance: BillingBalanceResponse = { effective_balance_micros: 6000 } +const mockWorkspaceBalance: BillingBalanceResponse = { + amount_micros: 0, + currency: 'usd', + effective_balance_micros: 0 +} + async function mockCloudBoot( page: Page, subscriptionStatus: CloudSubscriptionStatusResponse, - remoteConfig: RemoteConfig = { team_workspaces_enabled: false } + remoteConfig: RemoteConfig = {}, + billingRail?: BillingStatusResponse['billing_rail'] ) { + const billingRequests = { + legacyStatus: 0, + legacyBalance: 0, + workspaceStatus: 0 + } + await page.route('**/api/features', (r) => r.fulfill(jsonRoute(remoteConfig))) await page.route('**/api/system_stats', (r) => r.fulfill(jsonRoute(mockSystemStats)) @@ -106,25 +117,34 @@ async function mockCloudBoot( ) ) - // Legacy backend (team_workspaces_enabled: false). - await page.route('**/customers/cloud-subscription-status', (r) => - r.fulfill(jsonRoute(subscriptionStatus)) - ) - await page.route('**/customers/balance', (r) => - r.fulfill(jsonRoute(mockBalance)) - ) + // Legacy endpoints remain mocked for consumers that explicitly use them. + await page.route('**/customers/cloud-subscription-status', (r) => { + billingRequests.legacyStatus++ + return r.fulfill(jsonRoute(subscriptionStatus)) + }) + await page.route('**/customers/balance', (r) => { + billingRequests.legacyBalance++ + return r.fulfill(jsonRoute(mockBalance)) + }) - // Workspace backend (team_workspaces_enabled: true) — a personal workspace - // now routes through `/api/billing/*`. - await page.route('**/api/billing/status', (r) => - r.fulfill(jsonRoute(toWorkspaceStatus(subscriptionStatus))) - ) - await page.route('**/api/billing/balance', (r) => - r.fulfill(jsonRoute(mockBalance)) - ) + // Cloud personal workspaces route through `/api/billing/*`. + await page.route('**/api/billing/status', (r) => { + billingRequests.workspaceStatus++ + return r.fulfill( + jsonRoute({ + ...toWorkspaceStatus(subscriptionStatus), + billing_rail: billingRail + }) + ) + }) + await page.route('**/api/billing/balance', (r) => { + return r.fulfill(jsonRoute(mockWorkspaceBalance)) + }) await page.route('**/api/billing/plans', (r) => r.fulfill(jsonRoute({ plans: [] })) ) + + return billingRequests } async function bootApp(page: Page) { @@ -142,27 +162,34 @@ async function bootApp(page: Page) { } test.describe('Billing facade consumers (FE-933)', { tag: '@cloud' }, () => { - test('avatar popover renders tier badge and balance from the facade', async ({ + test('avatar popover renders a legacy-rail balance from the facade', async ({ page }) => { test.setTimeout(60_000) - await mockCloudBoot(page, { - is_active: true, - subscription_tier: 'PRO', - subscription_duration: 'MONTHLY', - renewal_date: '2099-02-20T10:00:00Z', - end_date: null - }) + const billingRequests = await mockCloudBoot( + page, + { + is_active: true, + subscription_tier: 'PRO', + subscription_duration: 'MONTHLY', + renewal_date: '2099-02-20T10:00:00Z', + end_date: null + }, + {}, + 'legacy_stripe' + ) await bootApp(page) await page.getByRole('button', { name: 'Current user' }).click() const popover = page.locator('.current-user-popover') await expect(popover).toBeVisible() - await expect(popover.getByText('Pro', { exact: true })).toBeVisible() await expect(popover.getByText('12,660')).toBeVisible() await expect(popover.getByTestId('add-credits-button')).toBeVisible() + expect(billingRequests.workspaceStatus).toBeGreaterThan(0) + expect(billingRequests.legacyStatus).toBeGreaterThan(0) + expect(billingRequests.legacyBalance).toBeGreaterThan(0) }) test('subscribe-to-run routes an inactive FREE user to the pricing table', async ({ @@ -170,8 +197,8 @@ test.describe('Billing facade consumers (FE-933)', { tag: '@cloud' }, () => { }) => { test.setTimeout(60_000) - // Boots with team workspaces enabled (production shape); the facade routes a - // personal workspace through the workspace `/api/billing/*` endpoints. With + // The facade routes a personal workspace through the workspace + // `/api/billing/*` endpoints. With // subscription gating on, an inactive FREE user gets the "Subscribe to run" // button, which opens the pricing table on click. (refreshRemoteConfig // overwrites window.__CONFIG__ from /api/features, so the flags must come @@ -186,12 +213,14 @@ test.describe('Billing facade consumers (FE-933)', { tag: '@cloud' }, () => { renewal_date: '2099-02-20T10:00:00Z', end_date: null }, - { team_workspaces_enabled: true, subscription_required: true } + { subscription_required: true } ) await bootApp(page) await page.getByTestId('subscribe-to-run-button').click() - await expect(page.getByRole('heading', { name: /Plans for/ })).toBeVisible() + await expect( + page.getByRole('heading', { name: 'Choose a Plan' }) + ).toBeVisible() }) }) diff --git a/browser_tests/tests/currentUserPopoverCredits.spec.ts b/browser_tests/tests/currentUserPopoverCredits.spec.ts index 4a7eda3b42d..6666766423e 100644 --- a/browser_tests/tests/currentUserPopoverCredits.spec.ts +++ b/browser_tests/tests/currentUserPopoverCredits.spec.ts @@ -17,7 +17,7 @@ type CustomerBalanceResponse = NonNullable< const PERSONAL_WORKSPACE_NAME = 'Personal Workspace' const FUTURE_DATE = '2099-01-01T00:00:00Z' -const mockRemoteConfig: RemoteConfig = { team_workspaces_enabled: true } +const mockRemoteConfig: RemoteConfig = {} const mockListWorkspacesResponse: { workspaces: WorkspaceWithRole[] } = { workspaces: [ @@ -54,8 +54,8 @@ const mockSubscriptionStatus: CloudSubscriptionStatusResponse = { end_date: FUTURE_DATE } -// With team workspaces enabled, the facade routes a personal workspace through -// `/api/billing/*`. The cancelled-but-active state maps to `is_active: true` +// The facade routes a Cloud personal workspace through `/api/billing/*`. The +// cancelled-but-active state maps to `is_active: true` // with `subscription_status: 'canceled'`; a paid tier keeps "Add credits" // visible (free tier would swap it for "Upgrade to add credits"). const mockBillingStatus: BillingStatusResponse = { @@ -128,8 +128,7 @@ const test = comfyPageFixture.extend({ }) ) - // Flag-on (team workspaces enabled) routes a personal workspace through the - // workspace billing endpoints, so the popover sources its data from here. + // The popover sources its data from the workspace billing endpoints. await page.route('**/api/billing/status', (route) => route.fulfill({ status: 200, diff --git a/browser_tests/tests/dialogs/creditsTile.spec.ts b/browser_tests/tests/dialogs/creditsTile.spec.ts index 9e614f3f352..dc8ecfedd77 100644 --- a/browser_tests/tests/dialogs/creditsTile.spec.ts +++ b/browser_tests/tests/dialogs/creditsTile.spec.ts @@ -27,10 +27,9 @@ import { * The credits tile only lives inside the authenticated cloud app, which the * shared `comfyPage` fixture can't boot (it expects the OSS devtools backend). * Instead this drives a raw page: mock Firebase auth + every boot endpoint so - * the cloud app initializes against fully stubbed data. With team workspaces - * enabled the facade routes a personal workspace through the workspace - * `/api/billing/*` endpoints (mocked with an active Pro subscription); the - * legacy `/customers/*` shapes are mocked too for the flag-off path. The tile + * the cloud app initializes against fully stubbed data. The facade routes a + * personal workspace through the workspace `/api/billing/*` endpoints (mocked + * with an active Pro subscription). The tile * should then render its total / progress bar / monthly+additional breakdown / * add-credits. */ @@ -72,13 +71,10 @@ const mockBillingStatus: BillingStatusResponse = { async function mockCloudBoot(page: Page, billingControlEnabled = true) { // Frontend-origin boot endpoints (proxied to the backend in production). - // `/api/features` is the remote-config source: production builds resolve - // workspace availability and the billing UX rollout from it (the `ff:` - // localStorage override is dev-only). + // `/api/features` is the remote-config source for the billing UX rollout. await page.route('**/api/features', (r) => r.fulfill( jsonRoute({ - team_workspaces_enabled: true, consolidated_billing_enabled: true, billing_control_enabled: billingControlEnabled } satisfies RemoteConfig) diff --git a/browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts b/browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts index 6095ad686f9..883f42f1cd5 100644 --- a/browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts +++ b/browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts @@ -41,11 +41,7 @@ const APP_URL = process.env.PLAYWRIGHT_TEST_URL || 'http://localhost:8188' const SELF_EMAIL = 'e2e@test.comfy.org' -// consolidated_billing_enabled routes personal workspaces to the unified -// pricing table asserted here; without it they fall back to the legacy table. const BOOT_FEATURES = { - team_workspaces_enabled: true, - consolidated_billing_enabled: true, billing_control_enabled: true } satisfies RemoteConfig // Disable the experimental Asset API: with it on (cloud default) the unmocked diff --git a/src/components/topbar/CurrentUserButton.test.ts b/src/components/topbar/CurrentUserButton.test.ts index 4403b9648b0..7b166c05ee4 100644 --- a/src/components/topbar/CurrentUserButton.test.ts +++ b/src/components/topbar/CurrentUserButton.test.ts @@ -8,10 +8,6 @@ import enMessages from '@/locales/en/main.json' with { type: 'json' } import CurrentUserButton from './CurrentUserButton.vue' -const mockFeatureFlags = vi.hoisted(() => ({ - teamWorkspacesEnabled: false -})) - const mockTeamWorkspaceStore = vi.hoisted(() => ({ workspaceName: { value: '' }, initState: { value: 'idle' }, @@ -40,13 +36,6 @@ vi.mock('pinia', () => ({ storeToRefs: vi.fn((store: Record) => store) })) -// Mock the useFeatureFlags composable -vi.mock('@/composables/useFeatureFlags', () => ({ - useFeatureFlags: vi.fn(() => ({ - flags: mockFeatureFlags - })) -})) - // Mock the useTeamWorkspaceStore vi.mock('@/platform/workspace/stores/teamWorkspaceStore', () => ({ useTeamWorkspaceStore: vi.fn(() => mockTeamWorkspaceStore) @@ -127,7 +116,6 @@ vi.mock('./CurrentUserPopoverLegacy.vue', () => ({ describe('CurrentUserButton', () => { beforeEach(() => { vi.clearAllMocks() - mockFeatureFlags.teamWorkspacesEnabled = false mockTeamWorkspaceStore.workspaceName.value = '' mockTeamWorkspaceStore.initState.value = 'idle' mockTeamWorkspaceStore.isInPersonalWorkspace.value = false @@ -189,7 +177,6 @@ describe('CurrentUserButton', () => { 'shows account actions while Cloud workspace initialization is %s', async (initState) => { mockIsCloud.value = true - mockFeatureFlags.teamWorkspacesEnabled = true mockTeamWorkspaceStore.initState.value = initState const { user } = renderComponent() @@ -213,7 +200,6 @@ describe('CurrentUserButton', () => { it('shows UserAvatar in personal workspace', () => { mockIsCloud.value = true - mockFeatureFlags.teamWorkspacesEnabled = true mockTeamWorkspaceStore.initState.value = 'ready' mockTeamWorkspaceStore.isInPersonalWorkspace.value = true @@ -224,7 +210,6 @@ describe('CurrentUserButton', () => { it('shows WorkspaceProfilePic in team workspace', () => { mockIsCloud.value = true - mockFeatureFlags.teamWorkspacesEnabled = true mockTeamWorkspaceStore.initState.value = 'ready' mockTeamWorkspaceStore.isInPersonalWorkspace.value = false mockTeamWorkspaceStore.workspaceName.value = 'My Team' diff --git a/src/components/topbar/CurrentUserButton.vue b/src/components/topbar/CurrentUserButton.vue index 47c2c5988d8..490d6011f34 100644 --- a/src/components/topbar/CurrentUserButton.vue +++ b/src/components/topbar/CurrentUserButton.vue @@ -49,7 +49,7 @@ @show="onPopoverShow" > () -const { flags } = useFeatureFlags() -const teamWorkspacesEnabled = computed(() => flags.teamWorkspacesEnabled) - const { isLoggedIn, userPhotoUrl } = useCurrentUser() const photoURL = computed( @@ -102,14 +98,10 @@ const { } = storeToRefs(useTeamWorkspaceStore()) const showWorkspaceSkeleton = computed( - () => isCloud && teamWorkspacesEnabled.value && initState.value === 'loading' + () => isCloud && initState.value === 'loading' ) const showWorkspaceIcon = computed( - () => - isCloud && - teamWorkspacesEnabled.value && - initState.value === 'ready' && - !isInPersonalWorkspace.value + () => isCloud && initState.value === 'ready' && !isInPersonalWorkspace.value ) const workspaceName = computed(() => { diff --git a/src/composables/billing/useBillingContext.test.ts b/src/composables/billing/useBillingContext.test.ts index d6a7adc6bf7..f5b2e6851e6 100644 --- a/src/composables/billing/useBillingContext.test.ts +++ b/src/composables/billing/useBillingContext.test.ts @@ -21,7 +21,6 @@ const DEFAULT_BILLING_STATUS: BillingStatusResponse = { } const { - mockTeamWorkspacesEnabled, mockConsolidatedBillingEnabled, mockIsPersonal, mockBillingRail, @@ -35,8 +34,7 @@ const { mockSetWorkspaceBillingRail, mockBillingStatus } = vi.hoisted(() => ({ - mockTeamWorkspacesEnabled: { value: false }, - mockConsolidatedBillingEnabled: { value: false }, + mockConsolidatedBillingEnabled: { value: true }, mockIsPersonal: { value: true }, mockBillingRail: { value: undefined as BillingRail | undefined }, mockPlans: { value: [] as Plan[] }, @@ -57,6 +55,16 @@ const { } })) +vi.mock('@/composables/useFeatureFlags', () => ({ + useFeatureFlags: () => ({ + flags: { + get consolidatedBillingEnabled() { + return mockConsolidatedBillingEnabled.value + } + } + }) +})) + vi.mock('@vueuse/core', async (importOriginal) => { const original = await importOriginal() return { @@ -65,37 +73,7 @@ vi.mock('@vueuse/core', async (importOriginal) => { } }) -vi.mock('@/composables/useFeatureFlags', async () => { - const { ref } = await import('vue') - const teamWorkspacesEnabledRef = ref(mockTeamWorkspacesEnabled.value) - Object.defineProperty(mockTeamWorkspacesEnabled, 'value', { - get: () => teamWorkspacesEnabledRef.value, - set: (value: boolean) => { - teamWorkspacesEnabledRef.value = value - } - }) - const consolidatedBillingEnabledRef = ref( - mockConsolidatedBillingEnabled.value - ) - Object.defineProperty(mockConsolidatedBillingEnabled, 'value', { - get: () => consolidatedBillingEnabledRef.value, - set: (value: boolean) => { - consolidatedBillingEnabledRef.value = value - } - }) - return { - useFeatureFlags: () => ({ - flags: { - get teamWorkspacesEnabled() { - return mockTeamWorkspacesEnabled.value - }, - get consolidatedBillingEnabled() { - return mockConsolidatedBillingEnabled.value - } - } - }) - } -}) +vi.mock('@/platform/distribution/types', () => ({ isCloud: true })) vi.mock('@/platform/workspace/stores/teamWorkspaceStore', async () => { const { ref } = await import('vue') @@ -195,8 +173,7 @@ describe('useBillingContext', () => { beforeEach(() => { setActivePinia(createPinia()) vi.clearAllMocks() - mockTeamWorkspacesEnabled.value = false - mockConsolidatedBillingEnabled.value = false + mockConsolidatedBillingEnabled.value = true mockIsPersonal.value = true mockBillingRail.value = undefined mockSetWorkspaceBillingRail.mockImplementation( @@ -208,33 +185,22 @@ describe('useBillingContext', () => { mockBillingStatus.value = { ...DEFAULT_BILLING_STATUS } }) - it('selects legacy type when team workspaces are disabled', () => { - mockTeamWorkspacesEnabled.value = false - const { type } = useBillingContext() - expect(type.value).toBe('legacy') - }) - - it('keeps personal on legacy when consolidated billing is disabled', () => { - mockTeamWorkspacesEnabled.value = true - mockConsolidatedBillingEnabled.value = false + it('selects workspace type for a Cloud personal workspace', () => { mockIsPersonal.value = true const { type } = useBillingContext() - expect(type.value).toBe('legacy') + expect(type.value).toBe('workspace') }) - it('selects workspace type for personal when consolidated billing is enabled', () => { - mockTeamWorkspacesEnabled.value = true - mockConsolidatedBillingEnabled.value = true - mockIsPersonal.value = true + it('keeps a Cloud personal workspace on legacy while consolidation is off', () => { + mockConsolidatedBillingEnabled.value = false const { type } = useBillingContext() - expect(type.value).toBe('workspace') + + expect(type.value).toBe('legacy') }) - it('selects workspace type for team regardless of consolidated billing', () => { - mockTeamWorkspacesEnabled.value = true - mockConsolidatedBillingEnabled.value = false + it('selects workspace type for a Cloud team workspace', () => { mockIsPersonal.value = false const { type } = useBillingContext() @@ -242,6 +208,7 @@ describe('useBillingContext', () => { }) it('provides subscription info from legacy billing', () => { + mockBillingRail.value = 'legacy_stripe' const { subscription } = useBillingContext() expect(subscription.value).toEqual({ @@ -257,6 +224,7 @@ describe('useBillingContext', () => { }) it('provides balance info from legacy billing', () => { + mockBillingRail.value = 'legacy_stripe' const { balance } = useBillingContext() expect(balance.value).toEqual({ @@ -285,15 +253,19 @@ describe('useBillingContext', () => { it('exposes subscribe action', async () => { const { subscribe } = useBillingContext() - await expect(subscribe('pro-monthly')).resolves.toBeUndefined() + await expect(subscribe('pro-monthly')).resolves.toEqual({ + status: 'subscribed' + }) }) it('exposes manageSubscription action', async () => { + mockBillingRail.value = 'legacy_stripe' const { manageSubscription } = useBillingContext() await expect(manageSubscription()).resolves.toBeUndefined() }) it('converts topup cents to whole dollars for the legacy credit endpoint', async () => { + mockBillingRail.value = 'legacy_stripe' const { topup } = useBillingContext() await topup(500) @@ -301,8 +273,6 @@ describe('useBillingContext', () => { }) it('uses workspace checkout while keeping legacy topups on legacy Stripe', async () => { - mockTeamWorkspacesEnabled.value = true - mockConsolidatedBillingEnabled.value = true mockBillingRail.value = 'legacy_stripe' mockPlans.value = [ { @@ -331,7 +301,7 @@ describe('useBillingContext', () => { await context.fetchStatus() expect(mockFetchPlans).toHaveBeenCalledOnce() - expect(mockLegacyFetchStatus).toHaveBeenCalledOnce() + expect(mockLegacyFetchStatus).toHaveBeenCalled() expect(workspaceApi.getBillingStatus).not.toHaveBeenCalled() await context.previewSubscribe('creator-annual') @@ -351,8 +321,6 @@ describe('useBillingContext', () => { }) it('switches billing adapters before refreshing a migrated balance', async () => { - mockTeamWorkspacesEnabled.value = true - mockConsolidatedBillingEnabled.value = true mockBillingRail.value = 'legacy_stripe' mockBillingStatus.value = { ...DEFAULT_BILLING_STATUS, @@ -360,6 +328,10 @@ describe('useBillingContext', () => { } const context = useBillingContext() + await vi.waitFor(() => { + expect(mockLegacyFetchStatus).toHaveBeenCalled() + expect(mockLegacyFetchBalance).toHaveBeenCalled() + }) vi.clearAllMocks() await context.reconcileSubscriptionSuccess() @@ -376,11 +348,13 @@ describe('useBillingContext', () => { }) it('does not refresh a balance through a stale rail after discovery fails', async () => { - mockTeamWorkspacesEnabled.value = true - mockConsolidatedBillingEnabled.value = true mockBillingRail.value = 'legacy_stripe' const context = useBillingContext() + await vi.waitFor(() => { + expect(mockLegacyFetchStatus).toHaveBeenCalled() + expect(mockLegacyFetchBalance).toHaveBeenCalled() + }) vi.clearAllMocks() vi.mocked(workspaceApi.getBillingStatus).mockRejectedValueOnce( new Error('status unavailable') @@ -407,6 +381,12 @@ describe('useBillingContext', () => { expect(canAccessSubscriptionFeatures.value).toBe(true) }) + it('provides isActiveSubscription convenience computed', () => { + mockBillingRail.value = 'legacy_stripe' + const { isActiveSubscription } = useBillingContext() + expect(isActiveSubscription.value).toBe(true) + }) + it('exposes requireActiveSubscription action', async () => { const { requireActiveSubscription } = useBillingContext() await expect(requireActiveSubscription()).resolves.toBeUndefined() @@ -417,48 +397,8 @@ describe('useBillingContext', () => { expect(() => showSubscriptionDialog()).not.toThrow() }) - it('reinitializes workspace billing when the type flips on after legacy init', async () => { - mockTeamWorkspacesEnabled.value = false - mockIsPersonal.value = true - - const { type, initialize } = useBillingContext() - await initialize() - await nextTick() - - expect(type.value).toBe('legacy') - expect(workspaceApi.getBillingStatus).not.toHaveBeenCalled() - - // Authenticated remote config resolves the flag on for the same workspace - mockConsolidatedBillingEnabled.value = true - mockTeamWorkspacesEnabled.value = true - - await vi.waitFor(() => { - expect(type.value).toBe('workspace') - expect(workspaceApi.getBillingStatus).toHaveBeenCalled() - }) - }) - - it('moves a personal workspace to workspace billing when consolidated billing flips on', async () => { - mockTeamWorkspacesEnabled.value = true - mockConsolidatedBillingEnabled.value = false - mockIsPersonal.value = true - - const { type } = useBillingContext() - await nextTick() - expect(type.value).toBe('legacy') - - mockConsolidatedBillingEnabled.value = true - - await vi.waitFor(() => { - expect(type.value).toBe('workspace') - expect(workspaceApi.getBillingStatus).toHaveBeenCalled() - }) - }) - describe('subscription mirror to workspace store', () => { - it('mirrors subscription for personal workspaces on the consolidated billing flow', async () => { - mockTeamWorkspacesEnabled.value = true - mockConsolidatedBillingEnabled.value = true + it('mirrors subscription for personal workspaces', async () => { mockIsPersonal.value = true const { initialize } = useBillingContext() @@ -472,7 +412,6 @@ describe('useBillingContext', () => { }) it('never clobbers the list-derived store when a subscription is absent', async () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false const { initialize } = useBillingContext() @@ -487,16 +426,15 @@ describe('useBillingContext', () => { }) describe('getMaxSeats', () => { - it('returns 1 for personal workspaces regardless of tier', () => { + it('uses plan seat limits for Cloud personal workspaces', () => { const { getMaxSeats } = useBillingContext() expect(getMaxSeats('standard')).toBe(1) - expect(getMaxSeats('creator')).toBe(1) - expect(getMaxSeats('pro')).toBe(1) + expect(getMaxSeats('creator')).toBe(5) + expect(getMaxSeats('pro')).toBe(20) expect(getMaxSeats('founder')).toBe(1) }) it('falls back to hardcoded values when no API plans available', () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false const { getMaxSeats } = useBillingContext() @@ -507,7 +445,6 @@ describe('useBillingContext', () => { }) it('prefers API max_seats when plans are loaded', () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false mockPlans.value = [ { @@ -540,7 +477,6 @@ describe('useBillingContext', () => { }) it('is true for an active team plan: team- slug and no credit stop', async () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false mockBillingStatus.value = { is_active: true, @@ -557,7 +493,6 @@ describe('useBillingContext', () => { }) it('is true for any legacy team tier, not just standard', async () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false mockBillingStatus.value = { is_active: true, @@ -574,7 +509,6 @@ describe('useBillingContext', () => { }) it('is false for a new credit-slider team subscriber', async () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false // Real BE shape: underscore slug + populated credit stop. (subscription_tier // is 'TEAM' on the wire, not yet in the FE SubscriptionTier union, so it is @@ -599,7 +533,6 @@ describe('useBillingContext', () => { }) it('is false for a new team sub even before its credit stop is populated', async () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false // Provisioning lag: credit stop not yet attached. The underscore slug // (team_per_credit, not team-) must still exclude it from the legacy table. @@ -618,7 +551,6 @@ describe('useBillingContext', () => { }) it('is false for a team workspace on a personal-tier plan', async () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false mockBillingStatus.value = { is_active: true, @@ -635,7 +567,6 @@ describe('useBillingContext', () => { }) it('stays true for a cancelled-but-still-active legacy team sub', async () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false mockBillingStatus.value = { is_active: true, @@ -654,7 +585,6 @@ describe('useBillingContext', () => { }) it('is false for a FREE-tier team even on a team- prefixed slug', async () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false mockBillingStatus.value = { is_active: true, @@ -670,7 +600,6 @@ describe('useBillingContext', () => { }) it('matches the legacy slug case-insensitively', async () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false mockBillingStatus.value = { is_active: true, @@ -699,7 +628,6 @@ describe('useBillingContext', () => { // isTeamPlan reads the credit stop and the slug, never the tier — which is // what keeps it working despite that divergence. it('is true for a credit-slider team sub, which carries a credit stop', async () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false mockBillingStatus.value = { is_active: true, @@ -719,8 +647,6 @@ describe('useBillingContext', () => { }) it('is true for a per-credit Team plan in a personal workspace before its credit stop is populated', async () => { - mockTeamWorkspacesEnabled.value = true - mockConsolidatedBillingEnabled.value = true mockIsPersonal.value = true mockBillingStatus.value = { is_active: true, @@ -737,7 +663,6 @@ describe('useBillingContext', () => { }) it('is true for a legacy team sub, identified by slug rather than credit stop', async () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false mockBillingStatus.value = { is_active: true, @@ -757,7 +682,6 @@ describe('useBillingContext', () => { // spend gate folds billing_status into it. Coupling isTeamPlan to an active // subscription would blank the banner precisely when it is needed. it('stays true for a paused team plan, which the backend reports inactive', async () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false mockBillingStatus.value = { is_active: false, @@ -778,7 +702,6 @@ describe('useBillingContext', () => { }) it('stays true for a legacy team plan whose payment failed', async () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false mockBillingStatus.value = { is_active: false, @@ -795,7 +718,6 @@ describe('useBillingContext', () => { }) it('is false for a team workspace on a personal-tier plan', async () => { - mockTeamWorkspacesEnabled.value = true mockIsPersonal.value = false mockBillingStatus.value = { is_active: true, diff --git a/src/composables/billing/useBillingContext.ts b/src/composables/billing/useBillingContext.ts index 6ceb6e167e2..3d1260ca662 100644 --- a/src/composables/billing/useBillingContext.ts +++ b/src/composables/billing/useBillingContext.ts @@ -236,9 +236,7 @@ function useBillingContextInternal(): BillingContext { error.value = null } - // type flips when the team-workspaces or consolidated-billing flag resolves - // from authenticated config, swapping the active backend. Reset then reinit - // on every workspace-id or type change. + // Reset and reinitialize when the active workspace or billing backend changes. watch( [() => store.activeWorkspace?.id, () => type.value], async ([newWorkspaceId]) => { diff --git a/src/composables/billing/useBillingRouting.test.ts b/src/composables/billing/useBillingRouting.test.ts index 5298b760d82..289c64983bd 100644 --- a/src/composables/billing/useBillingRouting.test.ts +++ b/src/composables/billing/useBillingRouting.test.ts @@ -4,22 +4,36 @@ import type { BillingRail } from '@/platform/workspace/api/workspaceApi' import { useBillingRouting } from './useBillingRouting' -const { mockFlags, mockActiveWorkspace, mockActiveWorkspaceBillingRail } = - vi.hoisted(() => ({ - mockFlags: { - teamWorkspacesEnabled: false, - consolidatedBillingEnabled: false - }, - mockActiveWorkspace: { - value: null as { id: string; type: 'personal' | 'team' } | null - }, - mockActiveWorkspaceBillingRail: { - value: null as BillingRail | null - } - })) +const { + mockIsCloud, + mockConsolidatedBillingEnabled, + mockActiveWorkspace, + mockActiveWorkspaceBillingRail +} = vi.hoisted(() => ({ + mockIsCloud: { value: true }, + mockConsolidatedBillingEnabled: { value: false }, + mockActiveWorkspace: { + value: null as { id: string; type: 'personal' | 'team' } | null + }, + mockActiveWorkspaceBillingRail: { + value: null as BillingRail | null + } +})) vi.mock('@/composables/useFeatureFlags', () => ({ - useFeatureFlags: () => ({ flags: mockFlags }) + useFeatureFlags: () => ({ + flags: { + get consolidatedBillingEnabled() { + return mockConsolidatedBillingEnabled.value + } + } + }) +})) + +vi.mock('@/platform/distribution/types', () => ({ + get isCloud() { + return mockIsCloud.value + } })) vi.mock('@/platform/workspace/stores/teamWorkspaceStore', () => ({ @@ -38,14 +52,14 @@ const team = { id: 'w-team', type: 'team' as const } describe('useBillingRouting', () => { beforeEach(() => { - mockFlags.teamWorkspacesEnabled = false - mockFlags.consolidatedBillingEnabled = false + mockIsCloud.value = true + mockConsolidatedBillingEnabled.value = false mockActiveWorkspace.value = personal mockActiveWorkspaceBillingRail.value = null }) - it('uses legacy billing when team workspaces are disabled', () => { - mockFlags.teamWorkspacesEnabled = false + it('uses legacy billing off Cloud', () => { + mockIsCloud.value = false mockActiveWorkspace.value = team const { type, shouldUseWorkspaceBilling } = useBillingRouting() @@ -54,20 +68,17 @@ describe('useBillingRouting', () => { expect(shouldUseWorkspaceBilling.value).toBe(false) }) - it('keeps personal on legacy when consolidated billing is disabled', () => { - mockFlags.teamWorkspacesEnabled = true - mockFlags.consolidatedBillingEnabled = false + it('keeps a Cloud personal workspace on legacy while consolidation is off', () => { mockActiveWorkspace.value = personal - const { type } = useBillingRouting() + const { type, shouldUseWorkspaceBilling } = useBillingRouting() expect(type.value).toBe('legacy') + expect(shouldUseWorkspaceBilling.value).toBe(false) }) - it('moves personal to workspace billing when consolidated billing is enabled', () => { - mockFlags.teamWorkspacesEnabled = true - mockFlags.consolidatedBillingEnabled = true - mockActiveWorkspace.value = personal + it('uses workspace billing for a Cloud personal workspace when consolidation is on', () => { + mockConsolidatedBillingEnabled.value = true const { type, shouldUseWorkspaceBilling } = useBillingRouting() @@ -76,8 +87,7 @@ describe('useBillingRouting', () => { }) it('uses unified pricing while keeping legacy Stripe top-ups on Checkout', () => { - mockFlags.teamWorkspacesEnabled = true - mockFlags.consolidatedBillingEnabled = true + mockConsolidatedBillingEnabled.value = true mockActiveWorkspace.value = personal mockActiveWorkspaceBillingRail.value = 'legacy_stripe' @@ -90,8 +100,7 @@ describe('useBillingRouting', () => { }) it('uses workspace billing for migrated Stripe personal workspaces', () => { - mockFlags.teamWorkspacesEnabled = true - mockFlags.consolidatedBillingEnabled = true + mockConsolidatedBillingEnabled.value = true mockActiveWorkspace.value = personal mockActiveWorkspaceBillingRail.value = 'stripe' @@ -101,9 +110,7 @@ describe('useBillingRouting', () => { expect(shouldUseWorkspaceBilling.value).toBe(true) }) - it('uses workspace billing for team workspaces regardless of consolidated billing', () => { - mockFlags.teamWorkspacesEnabled = true - mockFlags.consolidatedBillingEnabled = false + it('uses workspace billing for team workspaces', () => { mockActiveWorkspace.value = team mockActiveWorkspaceBillingRail.value = 'legacy_stripe' @@ -113,21 +120,7 @@ describe('useBillingRouting', () => { expect(shouldUseWorkspaceBilling.value).toBe(true) }) - it('uses workspace billing for team workspaces with consolidated billing enabled', () => { - mockFlags.teamWorkspacesEnabled = true - mockFlags.consolidatedBillingEnabled = true - mockActiveWorkspace.value = team - mockActiveWorkspaceBillingRail.value = 'stripe' - - const { type, shouldUseWorkspaceBilling } = useBillingRouting() - - expect(type.value).toBe('workspace') - expect(shouldUseWorkspaceBilling.value).toBe(true) - }) - it('defaults to legacy while the workspace has not loaded', () => { - mockFlags.teamWorkspacesEnabled = true - mockFlags.consolidatedBillingEnabled = true mockActiveWorkspace.value = null const { type } = useBillingRouting() diff --git a/src/composables/billing/useBillingRouting.ts b/src/composables/billing/useBillingRouting.ts index 6a3cee5e84c..a2cdbc90531 100644 --- a/src/composables/billing/useBillingRouting.ts +++ b/src/composables/billing/useBillingRouting.ts @@ -1,6 +1,7 @@ import { computed } from 'vue' import { useFeatureFlags } from '@/composables/useFeatureFlags' +import { isCloud } from '@/platform/distribution/types' import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore' import type { BillingType } from './types' @@ -8,18 +9,16 @@ import type { BillingType } from './types' /** * Selects the billing backend for the active workspace: legacy user-scoped * (`/customers/*`) or workspace-scoped (`/api/billing/*`). Personal workspaces - * stay legacy until `consolidatedBillingEnabled`, and known legacy Stripe - * workspaces remain legacy after it is enabled. An unknown rail keeps the - * flag-based route so workspace status can load it. Team workspaces are always - * workspace-scoped. Pricing follows feature availability independently of the - * billing rail. The routing matrix is covered in useBillingRouting.test.ts. + * stay legacy until consolidated billing is enabled; an explicit legacy Stripe + * rail continues to use legacy account operations after enablement. An unloaded + * workspace remains legacy during bootstrap, and OSS always uses legacy billing. */ export function useBillingRouting() { const { flags } = useFeatureFlags() const workspaceStore = useTeamWorkspaceStore() const shouldUseUnifiedPricing = computed(() => { - if (!flags.teamWorkspacesEnabled) return false + if (!isCloud) return false const workspaceType = workspaceStore.activeWorkspace?.type if (!workspaceType) return false @@ -28,7 +27,7 @@ export function useBillingRouting() { }) const type = computed(() => { - if (!flags.teamWorkspacesEnabled) return 'legacy' + if (!isCloud) return 'legacy' // An unloaded workspace has no type yet; stay legacy so bootstrap never // eagerly routes to workspace billing. diff --git a/src/composables/useFeatureFlags.test.ts b/src/composables/useFeatureFlags.test.ts index da0c9d40d2f..537c67ad916 100644 --- a/src/composables/useFeatureFlags.test.ts +++ b/src/composables/useFeatureFlags.test.ts @@ -9,7 +9,6 @@ import * as distributionTypes from '@/platform/distribution/types' import { cachedBillingControlEnabled, cachedConsolidatedBillingEnabled, - cachedTeamWorkspacesEnabled, cachedV1PaymentRecovery, remoteConfig, remoteConfigState @@ -271,14 +270,6 @@ describe('useFeatureFlags', () => { expect(flags.supportsPreviewMetadata).toBe('overridden') }) - it('teamWorkspacesEnabled override bypasses isCloud and isAuthenticatedConfigLoaded guards', () => { - vi.mocked(distributionTypes).isCloud = false - localStorage.setItem('ff:team_workspaces_enabled', 'true') - - const { flags } = useFeatureFlags() - expect(flags.teamWorkspacesEnabled).toBe(true) - }) - it('billingControlEnabled override bypasses isCloud and isAuthenticatedConfigLoaded guards', () => { vi.mocked(distributionTypes).isCloud = false localStorage.setItem('ff:billing_control_enabled', 'true') @@ -308,7 +299,6 @@ describe('useFeatureFlags', () => { const { flags } = useFeatureFlags() expect(flags.billingControlEnabled).toBe(false) - expect(flags.consolidatedBillingEnabled).toBe(false) }) }) @@ -317,7 +307,6 @@ describe('useFeatureFlags', () => { vi.mocked(distributionTypes).isCloud = true remoteConfigState.value = 'unloaded' remoteConfig.value = {} - cachedTeamWorkspacesEnabled.value = undefined cachedConsolidatedBillingEnabled.value = undefined cachedBillingControlEnabled.value = undefined cachedV1PaymentRecovery.value = undefined @@ -328,7 +317,6 @@ describe('useFeatureFlags', () => { vi.mocked(distributionTypes).isCloud = false remoteConfigState.value = 'unloaded' remoteConfig.value = {} - cachedTeamWorkspacesEnabled.value = undefined cachedConsolidatedBillingEnabled.value = undefined cachedBillingControlEnabled.value = undefined cachedV1PaymentRecovery.value = undefined @@ -336,13 +324,11 @@ describe('useFeatureFlags', () => { }) it('returns the cached session value during the auth window', () => { - cachedTeamWorkspacesEnabled.value = false cachedConsolidatedBillingEnabled.value = true cachedBillingControlEnabled.value = true cachedV1PaymentRecovery.value = true const { flags } = useFeatureFlags() - expect(flags.teamWorkspacesEnabled).toBe(false) expect(flags.consolidatedBillingEnabled).toBe(true) expect(flags.billingControlEnabled).toBe(true) expect(flags.v1PaymentRecovery).toBe(true) @@ -350,7 +336,6 @@ describe('useFeatureFlags', () => { it('defaults to false during the auth window when nothing is cached', () => { const { flags } = useFeatureFlags() - expect(flags.teamWorkspacesEnabled).toBe(false) expect(flags.consolidatedBillingEnabled).toBe(false) expect(flags.billingControlEnabled).toBe(false) expect(flags.v1PaymentRecovery).toBe(false) @@ -359,7 +344,6 @@ describe('useFeatureFlags', () => { it('prefers authenticated remoteConfig over the server feature fallback', () => { remoteConfigState.value = 'authenticated' remoteConfig.value = { - team_workspaces_enabled: true, consolidated_billing_enabled: true, billing_control_enabled: false, v1_payment_recovery: true @@ -367,7 +351,6 @@ describe('useFeatureFlags', () => { vi.mocked(api.getServerFeature).mockReturnValue(false) const { flags } = useFeatureFlags() - expect(flags.teamWorkspacesEnabled).toBe(true) expect(flags.consolidatedBillingEnabled).toBe(true) expect(flags.billingControlEnabled).toBe(false) expect(flags.v1PaymentRecovery).toBe(true) @@ -378,7 +361,6 @@ describe('useFeatureFlags', () => { remoteConfig.value = {} vi.mocked(api.getServerFeature).mockImplementation( (path, defaultValue) => { - if (path === ServerFeatureFlag.TEAM_WORKSPACES_ENABLED) return true if (path === ServerFeatureFlag.CONSOLIDATED_BILLING_ENABLED) return true if (path === ServerFeatureFlag.BILLING_CONTROL_ENABLED) return true @@ -388,7 +370,6 @@ describe('useFeatureFlags', () => { ) const { flags } = useFeatureFlags() - expect(flags.teamWorkspacesEnabled).toBe(true) expect(flags.consolidatedBillingEnabled).toBe(true) expect(flags.billingControlEnabled).toBe(true) expect(flags.v1PaymentRecovery).toBe(true) diff --git a/src/composables/useFeatureFlags.ts b/src/composables/useFeatureFlags.ts index 72ca66bd8fa..fea5b0daf32 100644 --- a/src/composables/useFeatureFlags.ts +++ b/src/composables/useFeatureFlags.ts @@ -5,7 +5,6 @@ import { isCloud, isNightly } from '@/platform/distribution/types' import { cachedBillingControlEnabled, cachedConsolidatedBillingEnabled, - cachedTeamWorkspacesEnabled, cachedV1PaymentRecovery, isAuthenticatedConfigLoaded, remoteConfig @@ -25,7 +24,6 @@ export enum ServerFeatureFlag { PRIVATE_MODELS_ENABLED = 'private_models_enabled', ONBOARDING_SURVEY_ENABLED = 'onboarding_survey_enabled', LINEAR_TOGGLE_ENABLED = 'linear_toggle_enabled', - TEAM_WORKSPACES_ENABLED = 'team_workspaces_enabled', PARTNER_NODE_GOVERNANCE_ENABLED = 'partner_node_governance_enabled', USER_SECRETS_ENABLED = 'user_secrets_enabled', NODE_REPLACEMENTS = 'node_replacements', @@ -129,19 +127,6 @@ export function useFeatureFlags() { false ) }, - /** - * Whether team workspaces feature is enabled. - * IMPORTANT: Returns false until authenticated remote config is loaded. - * This ensures we never use workspace tokens when the feature is disabled, - * and prevents race conditions during initialization. - */ - get teamWorkspacesEnabled() { - return resolveAuthGatedFlag( - ServerFeatureFlag.TEAM_WORKSPACES_ENABLED, - remoteConfig.value.team_workspaces_enabled, - cachedTeamWorkspacesEnabled - ) - }, get partnerNodeGovernanceEnabled() { return resolveFlag( ServerFeatureFlag.PARTNER_NODE_GOVERNANCE_ENABLED, @@ -206,11 +191,6 @@ export function useFeatureFlags() { false ) }, - /** - * Whether personal workspaces use the consolidated (workspace-scoped) - * billing flow. While false (default), personal workspaces stay on the - * legacy per-user billing flow; team workspaces are unaffected. - */ get consolidatedBillingEnabled() { return resolveAuthGatedFlag( ServerFeatureFlag.CONSOLIDATED_BILLING_ENABLED, diff --git a/src/composables/useUrlActionLoaders.test.ts b/src/composables/useUrlActionLoaders.test.ts index ebc01ceb0a7..7ee41727c12 100644 --- a/src/composables/useUrlActionLoaders.test.ts +++ b/src/composables/useUrlActionLoaders.test.ts @@ -9,11 +9,6 @@ vi.mock('@/platform/distribution/types', () => ({ } })) -const mockFlags = vi.hoisted(() => ({ value: { teamWorkspacesEnabled: true } })) -vi.mock('@/composables/useFeatureFlags', () => ({ - useFeatureFlags: () => ({ flags: mockFlags.value }) -})) - const mocks = vi.hoisted(() => ({ loadInvite: vi.fn().mockResolvedValue(undefined), loadCreateWorkspace: vi.fn().mockResolvedValue(undefined), @@ -55,7 +50,6 @@ describe('useUrlActionLoaders', () => { beforeEach(() => { vi.clearAllMocks() mockIsCloud.value = true - mockFlags.value = { teamWorkspacesEnabled: true } }) it('does not instantiate or run any loader off cloud', async () => { @@ -74,7 +68,7 @@ describe('useUrlActionLoaders', () => { expect(mocks.loadTopUp).not.toHaveBeenCalled() }) - it('runs all loaders on cloud when team workspaces are enabled', async () => { + it('runs all loaders on Cloud', async () => { const { runUrlActionLoaders } = useUrlActionLoaders() await runUrlActionLoaders() @@ -84,18 +78,6 @@ describe('useUrlActionLoaders', () => { expect(mocks.loadTopUp).toHaveBeenCalledOnce() }) - it('runs the pricing and top-up loaders but skips the flag-gated loaders when team workspaces are disabled', async () => { - mockFlags.value = { teamWorkspacesEnabled: false } - - const { runUrlActionLoaders } = useUrlActionLoaders() - await runUrlActionLoaders() - - expect(mocks.loadInvite).not.toHaveBeenCalled() - expect(mocks.loadCreateWorkspace).not.toHaveBeenCalled() - expect(mocks.loadPricingTable).toHaveBeenCalledOnce() - expect(mocks.loadTopUp).toHaveBeenCalledOnce() - }) - it('isolates a pricing-loader failure so it does not abort the boot chain', async () => { mocks.loadPricingTable.mockRejectedValueOnce(new Error('boom')) diff --git a/src/composables/useUrlActionLoaders.ts b/src/composables/useUrlActionLoaders.ts index 0725826380f..42e69bfc1b7 100644 --- a/src/composables/useUrlActionLoaders.ts +++ b/src/composables/useUrlActionLoaders.ts @@ -1,4 +1,3 @@ -import { useFeatureFlags } from '@/composables/useFeatureFlags' import { usePricingTableUrlLoader } from '@/platform/cloud/subscription/composables/usePricingTableUrlLoader' import { useTopUpUrlLoader } from '@/platform/cloud/subscription/composables/useTopUpUrlLoader' import { isCloud } from '@/platform/distribution/types' @@ -12,7 +11,6 @@ import { useInviteUrlLoader } from '@/platform/workspace/composables/useInviteUr * `runUrlActionLoaders()` from `onMounted` once the app is ready. */ export function useUrlActionLoaders() { - const { flags } = useFeatureFlags() const inviteUrlLoader = isCloud ? useInviteUrlLoader() : null const createWorkspaceUrlLoader = isCloud ? useCreateWorkspaceUrlLoader() @@ -22,13 +20,12 @@ export function useUrlActionLoaders() { async function runUrlActionLoaders() { // Accept workspace invite from URL if present (e.g., ?invite=TOKEN). - // WorkspaceAuthGate ensures flag state is resolved before the app mounts. - if (inviteUrlLoader && flags.teamWorkspacesEnabled) { + if (inviteUrlLoader) { await inviteUrlLoader.loadInviteFromUrl() } // Open create workspace dialog from URL if present (e.g., ?create_workspace=1). - if (createWorkspaceUrlLoader && flags.teamWorkspacesEnabled) { + if (createWorkspaceUrlLoader) { try { await createWorkspaceUrlLoader.loadCreateWorkspaceFromUrl() } catch (error) { @@ -40,7 +37,6 @@ export function useUrlActionLoaders() { } // Open the pricing table from URL if present (e.g., ?pricing=1 / ?pricing=team). - // Not gated on the team-workspaces flag: it also drives personal/legacy users. if (pricingTableUrlLoader) { try { await pricingTableUrlLoader.loadPricingTableFromUrl() diff --git a/src/platform/auth/session/useSessionCookie.test.ts b/src/platform/auth/session/useSessionCookie.test.ts index f526ce62ed9..56c3aa383d1 100644 --- a/src/platform/auth/session/useSessionCookie.test.ts +++ b/src/platform/auth/session/useSessionCookie.test.ts @@ -5,19 +5,12 @@ const mockGetAuthHeader = vi.fn() const mockAuthState = vi.hoisted(() => ({ currentUser: { uid: 'user-a' } as { uid: string } | null })) -const mockFlags = vi.hoisted(() => ({ teamWorkspacesEnabled: true })) const originalFetch = globalThis.fetch vi.mock('@/platform/distribution/types', () => ({ isCloud: true })) -vi.mock('@/composables/useFeatureFlags', () => ({ - useFeatureFlags: () => ({ - flags: mockFlags - }) -})) - vi.mock('@/stores/authStore', () => ({ useAuthStore: () => ({ getIdToken: mockGetIdToken, @@ -41,7 +34,6 @@ describe('useSessionCookie', () => { mockGetIdToken.mockReset() mockGetAuthHeader.mockReset() mockAuthState.currentUser = { uid: 'user-a' } - mockFlags.teamWorkspacesEnabled = true globalThis.fetch = vi.fn() }) @@ -209,7 +201,6 @@ describe('useSessionCookie', () => { }) it('does not let strict Firebase creation join a weaker request', async () => { - mockFlags.teamWorkspacesEnabled = false mockGetAuthHeader.mockResolvedValue(null) mockGetIdToken.mockResolvedValue('firebase-id-token') vi.mocked(globalThis.fetch).mockResolvedValue( diff --git a/src/platform/auth/session/useSessionCookie.ts b/src/platform/auth/session/useSessionCookie.ts index 5e09e5da30b..75d11b1915d 100644 --- a/src/platform/auth/session/useSessionCookie.ts +++ b/src/platform/auth/session/useSessionCookie.ts @@ -1,4 +1,3 @@ -import { useFeatureFlags } from '@/composables/useFeatureFlags' import { isCloud } from '@/platform/distribution/types' import { api } from '@/scripts/api' import { useAuthStore } from '@/stores/authStore' @@ -41,10 +40,9 @@ export const useSessionCookie = () => { const getSessionHeaderOrThrow = async ( useFirebaseToken: boolean ): Promise> => { - const { flags } = useFeatureFlags() const authStore = useAuthStore() - if (useFirebaseToken || flags.teamWorkspacesEnabled) { + if (isCloud || useFirebaseToken) { const firebaseToken = await authStore.getIdToken() if (!firebaseToken) { throw new Error('No Firebase token available for session creation') @@ -60,14 +58,7 @@ export const useSessionCookie = () => { return authHeader } - /** - * Creates or refreshes the session cookie. - * Called after login and on token refresh. - * - * When team_workspaces_enabled is true, uses Firebase token directly - * (since getAuthHeader() returns workspace token which shouldn't be used for session creation). - * When disabled, uses getAuthHeader() for backward compatibility. - */ + /** Creates or refreshes the session cookie after login or token refresh. */ const performCreateSession = async ( expectedOwnerUid: string, useFirebaseToken: boolean @@ -91,6 +82,7 @@ export const useSessionCookie = () => { forceRefresh: boolean, useFirebaseToken = false ): Promise => { + const usesFirebaseToken = isCloud || useFirebaseToken if ( !forceRefresh && pendingSessionMutations === 0 && @@ -100,7 +92,7 @@ export const useSessionCookie = () => { } if ( inFlightCreateSession?.ownerUid === ownerUid && - (!useFirebaseToken || inFlightCreateSession.usesFirebaseToken) + (!usesFirebaseToken || inFlightCreateSession.usesFirebaseToken) ) { return inFlightCreateSession.promise } @@ -108,13 +100,13 @@ export const useSessionCookie = () => { pendingSessionMutations++ const request: InFlightCreateSession = { ownerUid, - usesFirebaseToken: useFirebaseToken, + usesFirebaseToken, promise: sessionMutationTail .then(async () => { if ((useAuthStore().currentUser?.uid ?? null) !== ownerUid) { throw new Error('Session identity changed before creation') } - await performCreateSession(ownerUid, useFirebaseToken) + await performCreateSession(ownerUid, usesFirebaseToken) confirmedSessionOwnerUid = ownerUid if ((useAuthStore().currentUser?.uid ?? null) !== ownerUid) { throw new Error('Session identity changed during creation') diff --git a/src/platform/remoteConfig/refreshRemoteConfig.ts b/src/platform/remoteConfig/refreshRemoteConfig.ts index 6bf56352909..50130da9ee6 100644 --- a/src/platform/remoteConfig/refreshRemoteConfig.ts +++ b/src/platform/remoteConfig/refreshRemoteConfig.ts @@ -1,7 +1,6 @@ import { cachedBillingControlEnabled, cachedConsolidatedBillingEnabled, - cachedTeamWorkspacesEnabled, cachedV1PaymentRecovery, remoteConfig, remoteConfigErrorStatus, @@ -73,9 +72,6 @@ export async function refreshRemoteConfig( remoteConfigErrorStatus.value = null remoteConfigState.value = useAuth ? 'authenticated' : 'anonymous' if (useAuth) { - cachedTeamWorkspacesEnabled.value = Boolean( - config.team_workspaces_enabled - ) cachedConsolidatedBillingEnabled.value = Boolean( config.consolidated_billing_enabled ) diff --git a/src/platform/remoteConfig/remoteConfig.ts b/src/platform/remoteConfig/remoteConfig.ts index 0a3a3abe5ca..ac65c281d48 100644 --- a/src/platform/remoteConfig/remoteConfig.ts +++ b/src/platform/remoteConfig/remoteConfig.ts @@ -34,10 +34,7 @@ export const remoteConfigState = ref('unloaded') export const remoteConfigErrorStatus = ref(null) -/** - * Whether the authenticated config has been loaded. - * Use this to gate access to user-specific feature flags like teamWorkspacesEnabled. - */ +/** Whether the authenticated config has been loaded. */ export const isAuthenticatedConfigLoaded = computed( () => remoteConfigState.value === 'authenticated' ) @@ -57,11 +54,6 @@ export function configValueOrDefault( return configValue || defaultValue } -export const cachedTeamWorkspacesEnabled = useStorage( - 'team_workspaces_enabled' satisfies `${ServerFeatureFlag.TEAM_WORKSPACES_ENABLED}`, - undefined -) - export const cachedConsolidatedBillingEnabled = useStorage( 'consolidated_billing_enabled' satisfies `${ServerFeatureFlag.CONSOLIDATED_BILLING_ENABLED}`, undefined diff --git a/src/platform/remoteConfig/types.ts b/src/platform/remoteConfig/types.ts index 05a47703e4e..0104d9856f7 100644 --- a/src/platform/remoteConfig/types.ts +++ b/src/platform/remoteConfig/types.ts @@ -107,7 +107,6 @@ export type RemoteConfig = { /** Full hosted (external) survey URL embedded in the Nodes Manager modal on Cloud. */ manager_survey_url?: string linear_toggle_enabled?: boolean - team_workspaces_enabled?: boolean partner_node_governance_enabled?: boolean user_secrets_enabled?: boolean node_library_essentials_enabled?: boolean diff --git a/src/platform/settings/composables/useSettingUI.test.ts b/src/platform/settings/composables/useSettingUI.test.ts index 19c1af6c2a1..bb8284d5816 100644 --- a/src/platform/settings/composables/useSettingUI.test.ts +++ b/src/platform/settings/composables/useSettingUI.test.ts @@ -16,7 +16,6 @@ const env = vi.hoisted(() => { isCloud: false, isDesktop: false, isLoggedIn: false, - teamWorkspacesEnabled: false, billingControlEnabled: false, authenticatedConfigLoaded: false, partnerNodeGovernanceEnabled: false, @@ -51,9 +50,6 @@ vi.mock('@/composables/billing/useBillingContext', () => ({ vi.mock('@/composables/useFeatureFlags', () => ({ useFeatureFlags: () => ({ flags: { - get teamWorkspacesEnabled() { - return env.state.teamWorkspacesEnabled - }, get billingControlEnabled() { return env.state.billingControlEnabled }, @@ -133,7 +129,6 @@ describe('useSettingUI', () => { isCloud: false, isDesktop: false, isLoggedIn: false, - teamWorkspacesEnabled: false, billingControlEnabled: false, authenticatedConfigLoaded: false, partnerNodeGovernanceEnabled: false, @@ -202,7 +197,6 @@ describe('useSettingUI', () => { it('hides the empty Workspace navigation group for logged-out Cloud users', () => { env.state.isCloud = true env.state.isLoggedIn = false - env.state.teamWorkspacesEnabled = true const { navGroups } = useSettingUI() @@ -219,7 +213,6 @@ describe('useSettingUI', () => { Object.assign(env.state, { isCloud: true, isLoggedIn: true, - teamWorkspacesEnabled: true, authenticatedConfigLoaded: true, isActiveSubscription: true, billingType: 'workspace' @@ -297,7 +290,6 @@ describe('useSettingUI', () => { Object.assign(env.state, { isCloud: true, isLoggedIn: true, - teamWorkspacesEnabled: true, billingControlEnabled: true, authenticatedConfigLoaded: true, partnerNodeGovernanceEnabled: true, @@ -348,11 +340,11 @@ describe('useSettingUI', () => { expect(navKeys(navGroups.value)).not.toContain('workspace-allowlist') }) - it('keeps the legacy plan panel in the legacy layout', () => { - env.state.teamWorkspacesEnabled = false + it('keeps OSS account navigation on the legacy layout', () => { + env.state.isCloud = false const { navGroups } = useSettingUI() - expect(navKeys(navGroups.value)).toContain('subscription') + expect(navKeys(navGroups.value)).toContain('credits') expect(navKeys(navGroups.value)).not.toContain('workspace') }) }) diff --git a/src/platform/settings/composables/useSettingUI.ts b/src/platform/settings/composables/useSettingUI.ts index 5e70751be97..3a794594dc2 100644 --- a/src/platform/settings/composables/useSettingUI.ts +++ b/src/platform/settings/composables/useSettingUI.ts @@ -62,10 +62,6 @@ export function useSettingUI( useBillingContext() const { workspaceRole } = useWorkspaceUI() - const teamWorkspacesEnabled = computed( - () => isCloud && flags.teamWorkspacesEnabled - ) - const settingRoot = computed(() => { const root = buildTree( Object.values(settingStore.settingsById).filter( @@ -229,9 +225,7 @@ export function useSettingUI( props: { section: 'allowlist' } } - const shouldShowWorkspacePanel = computed( - () => teamWorkspacesEnabled.value && isLoggedIn.value - ) + const shouldShowWorkspacePanel = computed(() => isCloud && isLoggedIn.value) const shouldShowWorkspaceAllowlist = computed( () => shouldShowWorkspacePanel.value && @@ -349,7 +343,7 @@ export function useSettingUI( ) }) - // Sidebar structure when team workspaces is enabled + // Cloud workspace sidebar structure const workspaceMenuTreeNodes = computed(() => [ // Workspace settings translateCategory({ @@ -395,7 +389,7 @@ export function useSettingUI( : []) ]) - // Sidebar structure when team workspaces is disabled (legacy) + // OSS legacy sidebar structure const legacyMenuTreeNodes = computed(() => [ // Account settings - show different panels based on distribution and auth state { @@ -433,9 +427,7 @@ export function useSettingUI( ]) const groupedMenuTreeNodes = computed(() => - teamWorkspacesEnabled.value - ? workspaceMenuTreeNodes.value - : legacyMenuTreeNodes.value + isCloud ? workspaceMenuTreeNodes.value : legacyMenuTreeNodes.value ) const navGroups = computed(() => @@ -483,7 +475,6 @@ export function useSettingUI( groupedMenuTreeNodes, settingCategories, navGroups, - teamWorkspacesEnabled, findCategoryByKey, findPanelByKey } diff --git a/src/platform/settings/composables/useSettingsDialog.test.ts b/src/platform/settings/composables/useSettingsDialog.test.ts index 55f98832019..08a32c5fde4 100644 --- a/src/platform/settings/composables/useSettingsDialog.test.ts +++ b/src/platform/settings/composables/useSettingsDialog.test.ts @@ -7,23 +7,12 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' const showDialog = vi.hoisted(() => vi.fn()) -const teamWorkspacesFlag = vi.hoisted(() => ({ value: false })) const isCloudRef = vi.hoisted(() => ({ value: false })) vi.mock('@/stores/dialogStore', () => ({ useDialogStore: () => ({ showDialog, closeDialog: vi.fn() }) })) -vi.mock('@/composables/useFeatureFlags', () => ({ - useFeatureFlags: () => ({ - flags: { - get teamWorkspacesEnabled() { - return teamWorkspacesFlag.value - } - } - }) -})) - vi.mock('@/platform/distribution/types', () => ({ get isCloud() { return isCloudRef.value @@ -49,7 +38,6 @@ import { useSettingsDialog } from '@/platform/settings/composables/useSettingsDi describe('useSettingsDialog', () => { beforeEach(() => { showDialog.mockReset() - teamWorkspacesFlag.value = false isCloudRef.value = false }) @@ -78,9 +66,8 @@ describe('useSettingsDialog', () => { expect(args.dialogComponentProps.overlayClass).toBeUndefined() }) - it("show() sets overlayClass 'p-8' when isCloud && teamWorkspacesEnabled", () => { + it("show() sets overlayClass 'p-8' on Cloud", () => { isCloudRef.value = true - teamWorkspacesFlag.value = true useSettingsDialog().show() const [args] = showDialog.mock.calls[0] diff --git a/src/platform/settings/composables/useSettingsDialog.ts b/src/platform/settings/composables/useSettingsDialog.ts index cdc257893e8..c39d7b58b89 100644 --- a/src/platform/settings/composables/useSettingsDialog.ts +++ b/src/platform/settings/composables/useSettingsDialog.ts @@ -1,4 +1,3 @@ -import { useFeatureFlags } from '@/composables/useFeatureFlags' import { isCloud } from '@/platform/distribution/types' import { useDialogService } from '@/services/dialogService' import { useDialogStore } from '@/stores/dialogStore' @@ -15,14 +14,12 @@ const SETTINGS_CONTENT_CLASS = export function useSettingsDialog() { const dialogService = useDialogService() const dialogStore = useDialogStore() - const { flags } = useFeatureFlags() function hide() { dialogStore.closeDialog({ key: DIALOG_KEY }) } function show(panel?: SettingPanelType, settingId?: string) { - const isWorkspaceMode = isCloud && flags.teamWorkspacesEnabled dialogService.showLayoutDialog({ key: DIALOG_KEY, component: SettingDialog, @@ -46,7 +43,7 @@ export function useSettingsDialog() { dismissOnFocusOutside: false, size: 'full', contentClass: SETTINGS_CONTENT_CLASS, - overlayClass: isWorkspaceMode ? 'p-8' : undefined + overlayClass: isCloud ? 'p-8' : undefined } }) } diff --git a/src/platform/workspace/auth/WorkspaceAuthGate.test.ts b/src/platform/workspace/auth/WorkspaceAuthGate.test.ts index 81be966951d..0fba17b41e8 100644 --- a/src/platform/workspace/auth/WorkspaceAuthGate.test.ts +++ b/src/platform/workspace/auth/WorkspaceAuthGate.test.ts @@ -52,14 +52,10 @@ vi.mock('@/platform/remoteConfig/remoteConfig', () => ({ remoteConfigErrorStatus: mockRemoteConfigErrorStatus })) -const mockTeamWorkspacesEnabled = vi.hoisted(() => ({ value: false })) const mockUnifiedCloudAuthEnabled = vi.hoisted(() => ({ value: false })) vi.mock('@/composables/useFeatureFlags', () => ({ useFeatureFlags: () => ({ flags: { - get teamWorkspacesEnabled() { - return mockTeamWorkspacesEnabled.value - }, get unifiedCloudAuthEnabled() { return mockUnifiedCloudAuthEnabled.value } @@ -122,7 +118,6 @@ describe('WorkspaceAuthGate', () => { mockIsCloud.value = true mockIsInitialized.value = false mockCurrentUser.value = null - mockTeamWorkspacesEnabled.value = false mockUnifiedCloudAuthEnabled.value = false mockRemoteConfigState.value = 'authenticated' mockRemoteConfigErrorStatus.value = null @@ -218,16 +213,6 @@ describe('WorkspaceAuthGate', () => { }) }) - it('renders slot when teamWorkspacesEnabled is false', async () => { - mockTeamWorkspacesEnabled.value = false - - mountComponent() - await flushPromises() - - expect(screen.getByTestId('slot-content')).toBeInTheDocument() - expect(mockWorkspaceStoreInitialize).not.toHaveBeenCalled() - }) - it('mints unified auth after refreshing authenticated flags', async () => { mockRefreshRemoteConfig.mockImplementation(async () => { mockUnifiedCloudAuthEnabled.value = true @@ -240,9 +225,7 @@ describe('WorkspaceAuthGate', () => { expect(screen.getByTestId('slot-content')).toBeInTheDocument() }) - it('initializes workspace store when teamWorkspacesEnabled is true', async () => { - mockTeamWorkspacesEnabled.value = true - + it('initializes the workspace store', async () => { mountComponent() await flushPromises() @@ -252,7 +235,6 @@ describe('WorkspaceAuthGate', () => { it('stops initialization when unmounted', async () => { let resolveRefresh: (() => void) | undefined - mockTeamWorkspacesEnabled.value = true mockRefreshRemoteConfig.mockImplementation( () => new Promise((resolve) => { @@ -276,7 +258,6 @@ describe('WorkspaceAuthGate', () => { }) it('calls resumePendingPricingFlow after successful workspace init', async () => { - mockTeamWorkspacesEnabled.value = true mockWorkspaceStoreInitState.value = 'ready' mountComponent() @@ -286,7 +267,6 @@ describe('WorkspaceAuthGate', () => { }) it('skips workspace init when store is already initialized', async () => { - mockTeamWorkspacesEnabled.value = true mockWorkspaceStoreInitState.value = 'ready' mountComponent() @@ -355,7 +335,6 @@ describe('WorkspaceAuthGate', () => { }) it('shows a recoverable error when authenticated config is unavailable', async () => { - mockTeamWorkspacesEnabled.value = true mockRemoteConfigState.value = 'error' mountComponent() @@ -400,7 +379,6 @@ describe('WorkspaceAuthGate', () => { }) it('shows a recoverable error when workspace store initialization fails', async () => { - mockTeamWorkspacesEnabled.value = true mockWorkspaceStoreInitialize.mockRejectedValue( new Error('Workspace init failed') ) @@ -414,7 +392,6 @@ describe('WorkspaceAuthGate', () => { }) it('requires sign out when no workspace is available', async () => { - mockTeamWorkspacesEnabled.value = true mockWorkspaceStoreInitialize.mockRejectedValue( new Error('No workspaces available') ) @@ -432,7 +409,6 @@ describe('WorkspaceAuthGate', () => { it('shows a recoverable error when workspace setup clears unified auth', async () => { mockUnifiedCloudAuthEnabled.value = true - mockTeamWorkspacesEnabled.value = true mockGetUnifiedToken.mockReturnValue(undefined) mountComponent() @@ -444,7 +420,6 @@ describe('WorkspaceAuthGate', () => { }) it('shows a recoverable error without a ready workspace context', async () => { - mockTeamWorkspacesEnabled.value = true mockWorkspaceStoreInitState.value = 'loading' mountComponent() @@ -457,7 +432,6 @@ describe('WorkspaceAuthGate', () => { it('renders the app after retrying a failed initialization', async () => { const user = userEvent.setup() - mockTeamWorkspacesEnabled.value = true mockWorkspaceStoreInitialize .mockImplementationOnce(async () => { mockWorkspaceStoreInitState.value = 'error' @@ -503,7 +477,6 @@ describe('WorkspaceAuthGate', () => { it('stops a pending retry before logging out', async () => { const user = userEvent.setup() let resolveRetry: (() => void) | undefined - mockTeamWorkspacesEnabled.value = true mockRefreshRemoteConfig .mockRejectedValueOnce(new Error('Network error')) .mockImplementationOnce( diff --git a/src/platform/workspace/auth/WorkspaceAuthGate.vue b/src/platform/workspace/auth/WorkspaceAuthGate.vue index bf10e8c9fb8..95cd8946b45 100644 --- a/src/platform/workspace/auth/WorkspaceAuthGate.vue +++ b/src/platform/workspace/auth/WorkspaceAuthGate.vue @@ -43,16 +43,15 @@