diff --git a/browser_tests/fixtures/data/cloudWorkspace.ts b/browser_tests/fixtures/data/cloudWorkspace.ts index cd8a900bd44..a70278dd47d 100644 --- a/browser_tests/fixtures/data/cloudWorkspace.ts +++ b/browser_tests/fixtures/data/cloudWorkspace.ts @@ -24,6 +24,11 @@ export const TEAM_WORKSPACE: WorkspaceWithRole = { subscription_tier: 'PRO' } +export const TEAM_MEMBER_WORKSPACE: WorkspaceWithRole = { + ...TEAM_WORKSPACE, + role: 'member' +} + export const CREATOR: Member = { id: 'u-liz', name: 'Liz', @@ -99,6 +104,14 @@ export const ENDED_STANDARD_BILLING_STATUS = { team_credit_stop: null } satisfies IngestBillingStatusResponse & { billing_rail: 'stripe' } +export const INACTIVE_TEAM_BILLING_STATUS = { + ...TEAM_BILLING_STATUS, + billing_status: 'inactive', + is_active: false, + subscription_status: 'canceled', + subscription_tier: 'TEAM' +} satisfies IngestBillingStatusResponse + export const TEAM_PRO_PLAN: Plan = { slug: TEAM_PLAN_SLUG, tier: 'PRO', diff --git a/browser_tests/fixtures/helpers/CloudWorkspaceMockHelper.ts b/browser_tests/fixtures/helpers/CloudWorkspaceMockHelper.ts index ff5b29227a9..c19aecd0535 100644 --- a/browser_tests/fixtures/helpers/CloudWorkspaceMockHelper.ts +++ b/browser_tests/fixtures/helpers/CloudWorkspaceMockHelper.ts @@ -1,4 +1,4 @@ -import type { Page, Route } from '@playwright/test' +import type { Locator, Page, Route } from '@playwright/test' import type { BillingStatusResponse } from '@comfyorg/ingest-types' import type { @@ -16,6 +16,7 @@ import { WORKSPACE_FEATURE_FLAG } from '@e2e/fixtures/data/cloudWorkspace' import { CloudAuthHelper } from '@e2e/fixtures/helpers/CloudAuthHelper' +import { TestIds } from '@e2e/fixtures/selectors' import { mockWorkspaceTokenMint } from '@e2e/fixtures/utils/workspaceMocks' interface RoleChangeRequest { @@ -45,6 +46,30 @@ const jsonRoute = (body: unknown) => ({ export class CloudWorkspaceMockHelper { constructor(private readonly page: Page) {} + async openWorkspaceSettings(): Promise { + await this.page.goto( + process.env.PLAYWRIGHT_TEST_URL || 'http://localhost:8188' + ) + await this.page.waitForFunction( + () => !!window.app?.extensionManager, + null, + { + timeout: 45_000 + } + ) + await this.page + .getByRole('button', { name: /^Settings/ }) + .first() + .click() + const dialog = this.page.getByTestId(TestIds.dialogs.settings) + await dialog.waitFor({ state: 'visible' }) + await dialog + .locator('nav') + .getByRole('button', { name: 'Workspace', exact: true }) + .click() + return dialog.getByRole('main') + } + async setup( members: Member[] = DEFAULT_TEAM_MEMBERS, activeWorkspace: WorkspaceWithRole = TEAM_WORKSPACE, @@ -138,6 +163,9 @@ export class CloudWorkspaceMockHelper { await page.route('**/api/billing/status', (r) => r.fulfill(jsonRoute(billingStatus)) ) + await page.route('**/api/billing/payment-portal', (r) => + r.fulfill(jsonRoute({ url: 'https://billing.example/portal' })) + ) await page.route('**/api/billing/balance', (r) => r.fulfill( jsonRoute({ diff --git a/browser_tests/fixtures/helpers/SubscriptionHelper.ts b/browser_tests/fixtures/helpers/SubscriptionHelper.ts index f3b6bd80968..69d93a95c3b 100644 --- a/browser_tests/fixtures/helpers/SubscriptionHelper.ts +++ b/browser_tests/fixtures/helpers/SubscriptionHelper.ts @@ -132,6 +132,18 @@ export class SubscriptionHelper { handler: checkoutHandler }) await this.page.route(checkoutPattern, checkoutHandler) + + const billingPortalPattern = '**/customers/billing' + const billingPortalHandler = async (route: Route) => { + await route.fulfill({ + json: { billing_portal_url: 'https://billing.example/portal' } + }) + } + this.routeHandlers.push({ + pattern: billingPortalPattern, + handler: billingPortalHandler + }) + await this.page.route(billingPortalPattern, billingPortalHandler) } configure(...operators: SubscriptionOperator[]): void { diff --git a/browser_tests/tests/dialogs/creditsTile.spec.ts b/browser_tests/tests/dialogs/creditsTile.spec.ts index 9e614f3f352..d4b0148337b 100644 --- a/browser_tests/tests/dialogs/creditsTile.spec.ts +++ b/browser_tests/tests/dialogs/creditsTile.spec.ts @@ -70,7 +70,27 @@ const mockBillingStatus: BillingStatusResponse = { has_funds: true } -async function mockCloudBoot(page: Page, billingControlEnabled = true) { +const freeBillingStatus: BillingStatusResponse = { + is_active: false, + subscription_tier: 'FREE', + has_funds: true +} + +const endedPersonalBillingStatus: BillingStatusResponse = { + is_active: false, + subscription_status: 'ended', + subscription_tier: 'PRO', + subscription_duration: 'MONTHLY', + plan_slug: 'pro-monthly', + billing_status: 'inactive', + has_funds: true +} + +async function mockCloudBoot( + page: Page, + billingControlEnabled = true, + billingStatus = mockBillingStatus +) { // 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:` @@ -150,7 +170,10 @@ async function mockCloudBoot(page: Page, billingControlEnabled = true) { // Workspace billing (flag-on path) — a personal workspace now routes through // `/api/billing/*`. await page.route('**/api/billing/status', (r) => - r.fulfill(jsonRoute(mockBillingStatus)) + r.fulfill(jsonRoute(billingStatus)) + ) + await page.route('**/api/billing/payment-portal', (r) => + r.fulfill(jsonRoute({ url: 'https://billing.example/portal' })) ) await page.route('**/api/billing/balance', (r) => r.fulfill(balanceRoute(DEFAULT_BALANCE)) @@ -211,6 +234,65 @@ async function openPlanAndCredits(page: Page) { } test.describe('Credits tile (Plan & Credits)', { tag: '@cloud' }, () => { + test.beforeEach(async ({ page }) => { + await page.addInitScript(() => { + window.open = (url) => { + document.documentElement.dataset.openedUrl = String(url) + return window + } + }) + }) + + test('opens Billing & invoices for a paid owner without a duplicate invoice link', async ({ + page + }) => { + test.setTimeout(60_000) + + await mockCloudBoot(page) + + const content = await openPlanAndCredits(page) + await expect( + content.getByRole('button', { name: 'Invoice history' }) + ).toHaveCount(0) + await content.getByRole('button', { name: 'Billing & invoices' }).click() + + await expect + .poll(() => page.locator('html').getAttribute('data-opened-url')) + .toBe('https://billing.example/portal') + }) + + test('opens Billing & invoices for a Free owner without a subscription', async ({ + page + }) => { + test.setTimeout(60_000) + + await mockCloudBoot(page, true, freeBillingStatus) + + const content = await openPlanAndCredits(page) + await expect(content.getByRole('heading', { name: 'Free' })).toBeVisible() + await content.getByRole('button', { name: 'Billing & invoices' }).click() + + await expect + .poll(() => page.locator('html').getAttribute('data-opened-url')) + .toBe('https://billing.example/portal') + }) + + test('keeps Billing & invoices available after a Personal subscription ends', async ({ + page + }) => { + test.setTimeout(60_000) + + await mockCloudBoot(page, true, endedPersonalBillingStatus) + + const content = await openPlanAndCredits(page) + await expect(content.getByText('Your subscription has ended')).toBeVisible() + await content.getByRole('button', { name: 'Billing & invoices' }).click() + + await expect + .poll(() => page.locator('html').getAttribute('data-opened-url')) + .toBe('https://billing.example/portal') + }) + test('keeps the legacy Workspace UX when billing controls are disabled', async ({ page }) => { diff --git a/browser_tests/tests/dialogs/endedSubscription.spec.ts b/browser_tests/tests/dialogs/endedSubscription.spec.ts index a9e06aaf775..11413a26c7e 100644 --- a/browser_tests/tests/dialogs/endedSubscription.spec.ts +++ b/browser_tests/tests/dialogs/endedSubscription.spec.ts @@ -1,46 +1,40 @@ import { expect } from '@playwright/test' +import type { Locator } from '@playwright/test' -import { - cloudAppFixture as test, - waitForCloudApp -} from '@e2e/fixtures/cloudAppFixture' +import { cloudAppFixture as test } from '@e2e/fixtures/cloudAppFixture' import { DEFAULT_TEAM_MEMBERS, ENDED_STANDARD_BILLING_STATUS, + INACTIVE_TEAM_BILLING_STATUS, + TEAM_BILLING_STATUS, + TEAM_MEMBER_WORKSPACE, TEAM_WORKSPACE } from '@e2e/fixtures/data/cloudWorkspace' import { CloudWorkspaceMockHelper } from '@e2e/fixtures/helpers/CloudWorkspaceMockHelper' -import { TestIds } from '@e2e/fixtures/selectors' test.describe('Ended workspace subscription', { tag: '@cloud' }, () => { test.describe.configure({ timeout: 60_000 }) + let content: Locator test.beforeEach(async ({ page }) => { - await new CloudWorkspaceMockHelper(page).setup( + await page.addInitScript(() => { + window.open = (url) => { + document.documentElement.dataset.openedUrl = String(url) + return window + } + }) + const workspace = new CloudWorkspaceMockHelper(page) + await workspace.setup( DEFAULT_TEAM_MEMBERS, TEAM_WORKSPACE, ENDED_STANDARD_BILLING_STATUS ) - await page.goto(process.env.PLAYWRIGHT_TEST_URL || 'http://localhost:8188') - await waitForCloudApp(page) - - await page - .getByRole('button', { name: /^Settings/ }) - .first() - .click() - const dialog = page.getByTestId(TestIds.dialogs.settings) - await expect(dialog).toBeVisible() - await dialog - .locator('nav') - .getByRole('button', { name: 'Workspace', exact: true }) - .click() + content = await workspace.openWorkspaceSettings() }) test('shows subscribe prompt instead of stale paid plan metadata', async ({ page }) => { - const content = page.getByTestId(TestIds.dialogs.settings).getByRole('main') - await expect( content.getByRole('heading', { name: 'This workspace is not on a subscription' @@ -52,5 +46,71 @@ test.describe('Ended workspace subscription', { tag: '@cloud' }, () => { await expect( content.getByRole('heading', { name: 'Standard' }) ).toHaveCount(0) + await expect( + content.getByRole('button', { name: 'Invoice history' }) + ).toHaveCount(0) + + await content.getByRole('button', { name: 'Billing & invoices' }).click() + await expect + .poll(() => page.locator('html').getAttribute('data-opened-url')) + .toBe('https://billing.example/portal') + }) +}) + +test.describe('Inactive Team subscription billing', { tag: '@cloud' }, () => { + test.describe.configure({ timeout: 60_000 }) + let content: Locator + + test.beforeEach(async ({ page }) => { + await page.addInitScript(() => { + window.open = (url) => { + document.documentElement.dataset.openedUrl = String(url) + return window + } + }) + const workspace = new CloudWorkspaceMockHelper(page) + await workspace.setup( + DEFAULT_TEAM_MEMBERS, + TEAM_WORKSPACE, + INACTIVE_TEAM_BILLING_STATUS + ) + content = await workspace.openWorkspaceSettings() + }) + + test('keeps the owner billing portal available', async ({ page }) => { + await expect( + content.getByRole('heading', { name: 'Inactive team subscription' }) + ).toBeVisible() + await content.getByRole('button', { name: 'Billing & invoices' }).click() + await expect + .poll(() => page.locator('html').getAttribute('data-opened-url')) + .toBe('https://billing.example/portal') + }) +}) + +test.describe('Team member billing permissions', { tag: '@cloud' }, () => { + test.describe.configure({ timeout: 60_000 }) + let content: Locator + + test.beforeEach(async ({ page }) => { + const workspace = new CloudWorkspaceMockHelper(page) + await workspace.setup( + DEFAULT_TEAM_MEMBERS, + TEAM_MEMBER_WORKSPACE, + TEAM_BILLING_STATUS + ) + content = await workspace.openWorkspaceSettings() + }) + + test('does not expose owner billing actions', async () => { + await expect( + content.getByRole('heading', { name: 'Team', exact: true }) + ).toBeVisible() + await expect( + content.getByRole('button', { name: 'Billing & invoices' }) + ).toHaveCount(0) + await expect( + content.getByRole('button', { name: 'Invoice history' }) + ).toHaveCount(0) }) }) diff --git a/browser_tests/tests/localCreditsNoSubscribeUi.spec.ts b/browser_tests/tests/localCreditsNoSubscribeUi.spec.ts index c8cf166bdca..7a7d3ede5f9 100644 --- a/browser_tests/tests/localCreditsNoSubscribeUi.spec.ts +++ b/browser_tests/tests/localCreditsNoSubscribeUi.spec.ts @@ -55,6 +55,20 @@ test.describe('Local credits surfaces hide subscribe UI (non-cloud)', () => { await expect( creditsContent.getByText('Upgrade to add credits') ).toHaveCount(0) + await expect( + creditsContent.getByRole('button', { name: 'Manage subscription' }) + ).toHaveCount(0) + await expect( + creditsContent.getByRole('button', { name: 'Billing & invoices' }) + ).toHaveCount(0) + await expect( + creditsContent.getByRole('button', { name: 'Invoice history' }) + ).toBeVisible() + const invoiceRequest = page.waitForRequest('**/customers/billing') + await creditsContent + .getByRole('button', { name: 'Invoice history' }) + .click() + expect((await invoiceRequest).method()).toBe('POST') const settingsAddCredits = creditsContent.getByRole('button', { name: 'Add credits' diff --git a/src/platform/cloud/subscription/components/SubscriptionFooterLinks.test.ts b/src/platform/cloud/subscription/components/SubscriptionFooterLinks.test.ts index 80af44467aa..de4a0d0a598 100644 --- a/src/platform/cloud/subscription/components/SubscriptionFooterLinks.test.ts +++ b/src/platform/cloud/subscription/components/SubscriptionFooterLinks.test.ts @@ -1,17 +1,24 @@ import { render, screen } from '@testing-library/vue' import userEvent from '@testing-library/user-event' -import { beforeEach, describe, expect, it, vi } from 'vitest' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { ref } from 'vue' import { createI18n } from 'vue-i18n' import SubscriptionFooterLinks from './SubscriptionFooterLinks.vue' const state = vi.hoisted(() => ({ + isCloud: true, manageSubscription: vi.fn(), handleLearnMoreClick: vi.fn(), handleMessageSupport: vi.fn() })) +vi.mock('@/platform/distribution/types', () => ({ + get isCloud() { + return state.isCloud + } +})) + vi.mock('@/composables/billing/useBillingContext', () => ({ useBillingContext: () => ({ manageSubscription: state.manageSubscription @@ -70,10 +77,49 @@ function renderComponent(showInvoiceHistory?: boolean) { describe('SubscriptionFooterLinks', () => { beforeEach(() => { vi.clearAllMocks() + state.isCloud = true + }) + + afterEach(() => { + vi.restoreAllMocks() + }) + + it('renders working support links without a duplicate invoice action', async () => { + const user = userEvent.setup() + const openSpy = vi.spyOn(window, 'open').mockReturnValue(null) + renderComponent() + + expect( + screen.queryByRole('button', { name: 'Invoice history' }) + ).not.toBeInTheDocument() + expect( + screen.getByRole('button', { name: 'Learn more' }) + ).toBeInTheDocument() + expect( + screen.getByRole('button', { name: 'Partner Nodes pricing' }) + ).toBeInTheDocument() + expect( + screen.getByRole('button', { name: 'Message support' }) + ).toBeInTheDocument() + + await user.click(screen.getByRole('button', { name: 'Learn more' })) + expect(state.handleLearnMoreClick).toHaveBeenCalledOnce() + + await user.click(screen.getByRole('button', { name: 'Message support' })) + expect(state.handleMessageSupport).toHaveBeenCalledOnce() + + await user.click( + screen.getByRole('button', { name: 'Partner Nodes pricing' }) + ) + expect(openSpy).toHaveBeenCalledWith( + 'https://docs.comfy.org/partner-nodes', + '_blank' + ) }) - it('keeps Invoice history visible by default for legacy billing', async () => { + it('keeps Invoice history working outside the cloud distribution', async () => { const user = userEvent.setup() + state.isCloud = false renderComponent() await user.click(screen.getByRole('button', { name: 'Invoice history' })) @@ -81,15 +127,13 @@ describe('SubscriptionFooterLinks', () => { expect(state.manageSubscription).toHaveBeenCalledOnce() }) - it('hides Invoice history without opening the payment portal', () => { + it('hides Invoice history from local users without billing permission', () => { + state.isCloud = false renderComponent(false) expect( screen.queryByRole('button', { name: 'Invoice history' }) ).not.toBeInTheDocument() - expect( - screen.getByRole('button', { name: 'Learn more' }) - ).toBeInTheDocument() expect(state.manageSubscription).not.toHaveBeenCalled() }) }) diff --git a/src/platform/cloud/subscription/components/SubscriptionFooterLinks.vue b/src/platform/cloud/subscription/components/SubscriptionFooterLinks.vue index d9f08c0ff10..9ac64565c97 100644 --- a/src/platform/cloud/subscription/components/SubscriptionFooterLinks.vue +++ b/src/platform/cloud/subscription/components/SubscriptionFooterLinks.vue @@ -31,7 +31,7 @@ ' } -function renderComponent() { +function renderComponent({ stubFooter = true } = {}) { return render(SubscriptionPanelContentWorkspace, { global: { plugins: [createTestingPinia({ createSpy: vi.fn }), i18n], @@ -287,7 +296,9 @@ function renderComponent() { stubs: { CreditsTile: CreditsTileStub, Button: ButtonStub, - SubscriptionFooterLinks: SubscriptionFooterLinksStub, + ...(stubFooter + ? { SubscriptionFooterLinks: SubscriptionFooterLinksStub } + : {}), StatusBadge: true, DropdownMenu: DropdownMenuStub } @@ -302,8 +313,10 @@ describe('SubscriptionPanelContentWorkspace', () => { beforeEach(() => { vi.clearAllMocks() + mockDistributionState.isCloud = true mockSubscriptionStatus.value = 'active' mockBillingStatus.value = 'paid' + mockBillingType.value = 'workspace' mockRenewalDate.value = RENEWAL_DATE_ISO mockEndDate.value = END_DATE_ISO mockScheduledPlanSlug.value = null @@ -469,17 +482,31 @@ describe('SubscriptionPanelContentWorkspace', () => { expect(screen.getByText('$665.50')).toBeInTheDocument() }) - it('wires Manage billing and Change plan actions for subscription managers', async () => { + it('wires Billing & invoices and Change plan actions for subscription managers', async () => { const user = userEvent.setup() renderComponent() - await user.click(screen.getByRole('button', { name: 'Manage billing' })) + await user.click(screen.getByRole('button', { name: 'Billing & invoices' })) expect(mockManageSubscription).toHaveBeenCalledOnce() await user.click(screen.getByRole('button', { name: 'Change plan' })) expect(mockShowSubscriptionDialog).toHaveBeenCalledOnce() }) + it('preserves local Manage billing and Invoice history actions', async () => { + const user = userEvent.setup() + mockDistributionState.isCloud = false + renderComponent({ stubFooter: false }) + + expect( + screen.queryByRole('button', { name: 'Billing & invoices' }) + ).not.toBeInTheDocument() + await user.click(screen.getByRole('button', { name: 'Manage billing' })) + expect(mockManageSubscription).toHaveBeenCalledOnce() + await user.click(screen.getByRole('button', { name: 'Invoice history' })) + expect(mockManageSubscription).toHaveBeenCalledTimes(2) + }) + it('keeps a Personal workspace Team-plan member view read-only', () => { mockIsInPersonalWorkspace.value = true mockCanManageSubscription.value = false @@ -491,7 +518,7 @@ describe('SubscriptionPanelContentWorkspace', () => { expect(screen.getByRole('heading', { name: 'Team' })).toBeInTheDocument() expect(screen.getByTestId('credits-tile')).toBeInTheDocument() expect( - screen.queryByRole('button', { name: 'Manage billing' }) + screen.queryByRole('button', { name: 'Billing & invoices' }) ).not.toBeInTheDocument() expect( screen.queryByRole('button', { name: 'Change plan' }) @@ -521,7 +548,9 @@ describe('SubscriptionPanelContentWorkspace', () => { ).not.toBeInTheDocument() }) - it('shows ended state for an inactive paid Personal workspace despite active status', () => { + it('keeps billing access in the ended state for an inactive paid Personal workspace', async () => { + const user = userEvent.setup() + mockBillingType.value = 'legacy' mockIsInPersonalWorkspace.value = true mockIsActiveSubscription.value = false mockBillingStatus.value = 'inactive' @@ -529,6 +558,8 @@ describe('SubscriptionPanelContentWorkspace', () => { expect(screen.getByText('Your subscription has ended')).toBeInTheDocument() expect(screen.getByRole('heading', { name: 'Free' })).toBeInTheDocument() + await user.click(screen.getByRole('button', { name: 'Billing & invoices' })) + expect(mockManageSubscription).toHaveBeenCalledOnce() expect( screen.getByRole('button', { name: 'Subscribe' }) ).toBeInTheDocument() @@ -596,7 +627,7 @@ describe('SubscriptionPanelContentWorkspace', () => { ).not.toBeInTheDocument() expect(screen.queryByText(/^Changes to/i)).not.toBeInTheDocument() expect( - screen.getByRole('button', { name: 'Manage billing' }) + screen.getByRole('button', { name: 'Billing & invoices' }) ).toBeInTheDocument() expect( screen.queryByRole('button', { name: 'Change plan' }) @@ -627,6 +658,23 @@ describe('SubscriptionPanelContentWorkspace', () => { ).toBeInTheDocument() }) + it('preserves local inactive Team billing and invoice actions', async () => { + const user = userEvent.setup() + mockDistributionState.isCloud = false + mockSubscriptionStatus.value = 'canceled' + mockIsActiveSubscription.value = false + mockIsWorkspaceSubscribed.value = false + renderComponent({ stubFooter: false }) + + expect( + screen.getByRole('heading', { name: 'Inactive team subscription' }) + ).toBeInTheDocument() + await user.click(screen.getByRole('button', { name: 'Billing & invoices' })) + expect(mockManageSubscription).toHaveBeenCalledOnce() + await user.click(screen.getByRole('button', { name: 'Invoice history' })) + expect(mockManageSubscription).toHaveBeenCalledTimes(2) + }) + it('renders an ended Team plan for its owner and routes reactivation to checkout', async () => { mockSubscriptionStatus.value = 'canceled' mockIsActiveSubscription.value = false @@ -722,7 +770,8 @@ describe('SubscriptionPanelContentWorkspace', () => { ).not.toBeInTheDocument() }) - it('shows the zero-state subscribe prompt to unsubscribed team owners', () => { + it('keeps Billing & invoices available to unsubscribed team owners', async () => { + const user = userEvent.setup() mockIsActiveSubscription.value = false mockIsWorkspaceSubscribed.value = false mockHasSubscription.value = false @@ -734,13 +783,13 @@ describe('SubscriptionPanelContentWorkspace', () => { expect( screen.getByRole('button', { name: 'Subscribe Now' }) ).toBeInTheDocument() - expect( - screen.queryByRole('button', { name: 'Billing & invoices' }) - ).not.toBeInTheDocument() expect(screen.getByTestId('credits-tile')).toHaveAttribute( 'data-zero-state', 'true' ) + + await user.click(screen.getByRole('button', { name: 'Billing & invoices' })) + expect(mockManageSubscription).toHaveBeenCalledOnce() }) it('shows a loading indicator instead of a false Free plan while billing loads', () => { @@ -811,10 +860,40 @@ describe('SubscriptionPanelContentWorkspace', () => { 'false' ) + await user.click(screen.getByRole('button', { name: 'Billing & invoices' })) + expect(mockManageSubscription).toHaveBeenCalledOnce() + await user.click(screen.getByRole('button', { name: 'Subscribe' })) expect(mockShowSubscriptionDialog).toHaveBeenCalledOnce() }) + it.for([ + { state: 'never-subscribed', hasSubscription: false, tier: 'PRO' }, + { state: 'Free', hasSubscription: true, tier: 'FREE' } + ] as const)( + 'hides legacy billing access from $state personal workspaces', + ({ hasSubscription, tier }) => { + mockBillingType.value = 'legacy' + mockBillingStatus.value = 'inactive' + mockSubscriptionTier.value = tier + mockIsInPersonalWorkspace.value = true + mockIsActiveSubscription.value = false + mockHasSubscription.value = hasSubscription + mockIsWorkspaceSubscribed.value = false + mockUiConfig.value = personalUiConfig + mockCanLeaveWorkspace.value = false + renderComponent() + + expect(screen.getByRole('heading', { name: 'Free' })).toBeInTheDocument() + expect( + screen.queryByRole('button', { name: 'Billing & invoices' }) + ).not.toBeInTheDocument() + expect( + screen.getByRole('button', { name: 'Subscribe' }) + ).toBeInTheDocument() + } + ) + it('lets a Free personal workspace only rename itself (no Cancel or Delete)', async () => { const user = userEvent.setup() mockIsInPersonalWorkspace.value = true diff --git a/src/platform/workspace/components/SubscriptionPanelContentWorkspace.vue b/src/platform/workspace/components/SubscriptionPanelContentWorkspace.vue index 32e23c9e9c3..99f0ed23ee0 100644 --- a/src/platform/workspace/components/SubscriptionPanelContentWorkspace.vue +++ b/src/platform/workspace/components/SubscriptionPanelContentWorkspace.vue @@ -108,7 +108,10 @@
+