-
Notifications
You must be signed in to change notification settings - Fork 618
feat(billing): role-aware run-lock for cancelled/inactive team plans (FE-978) #12786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dante01yoon
merged 2 commits into
main
from
jaewon/fe-978-team-plan-cancel-inactive-states-run-locked-members-retained
Jun 17, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
src/components/actionbar/ComfyRunButton/CloudRunButtonWrapper.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import { render, screen } from '@testing-library/vue' | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
| import { nextTick, ref } from 'vue' | ||
|
|
||
| import CloudRunButtonWrapper from './CloudRunButtonWrapper.vue' | ||
|
|
||
| const mockIsActiveSubscription = ref(true) | ||
|
|
||
| vi.mock('@/composables/billing/useBillingContext', () => ({ | ||
| useBillingContext: () => ({ | ||
| isActiveSubscription: mockIsActiveSubscription | ||
| }) | ||
| })) | ||
|
|
||
| vi.mock('@/components/actionbar/ComfyRunButton/ComfyQueueButton.vue', () => ({ | ||
| default: { | ||
| name: 'ComfyQueueButton', | ||
| template: '<div data-testid="queue-button" />' | ||
| } | ||
| })) | ||
|
|
||
| vi.mock('@/platform/cloud/subscription/components/SubscribeToRun.vue', () => ({ | ||
| default: { | ||
| name: 'SubscribeToRun', | ||
| template: '<div data-testid="subscribe-to-run-button" />' | ||
| } | ||
| })) | ||
|
|
||
| function renderWrapper() { | ||
| return render(CloudRunButtonWrapper) | ||
| } | ||
|
|
||
| describe('CloudRunButtonWrapper', () => { | ||
| beforeEach(() => { | ||
| mockIsActiveSubscription.value = true | ||
| }) | ||
|
|
||
| it('renders the runnable queue button when the subscription is active', () => { | ||
| renderWrapper() | ||
|
|
||
| expect(screen.getByTestId('queue-button')).toBeInTheDocument() | ||
| expect( | ||
| screen.queryByTestId('subscribe-to-run-button') | ||
| ).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('locks the run button when the subscription is inactive', () => { | ||
| mockIsActiveSubscription.value = false | ||
| renderWrapper() | ||
|
|
||
| expect(screen.getByTestId('subscribe-to-run-button')).toBeInTheDocument() | ||
| expect(screen.queryByTestId('queue-button')).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('unlocks the run button once the subscription becomes active again', async () => { | ||
| mockIsActiveSubscription.value = false | ||
| renderWrapper() | ||
|
|
||
| expect(screen.getByTestId('subscribe-to-run-button')).toBeInTheDocument() | ||
|
|
||
| mockIsActiveSubscription.value = true | ||
| await nextTick() | ||
|
|
||
| expect(screen.getByTestId('queue-button')).toBeInTheDocument() | ||
| expect( | ||
| screen.queryByTestId('subscribe-to-run-button') | ||
| ).not.toBeInTheDocument() | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
src/platform/cloud/subscription/components/SubscribeToRun.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| import type * as VueUseCore from '@vueuse/core' | ||
| import { render, screen } from '@testing-library/vue' | ||
| import userEvent from '@testing-library/user-event' | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
| import { computed, ref } from 'vue' | ||
| import { createI18n } from 'vue-i18n' | ||
|
|
||
| import SubscribeToRun from './SubscribeToRun.vue' | ||
|
|
||
| const mockShowSubscriptionDialog = vi.fn() | ||
| const mockCanManageSubscription = ref(true) | ||
| const mockIsMdOrLarger = ref(true) | ||
|
|
||
| vi.mock('@/composables/billing/useBillingContext', () => ({ | ||
| useBillingContext: () => ({ | ||
| showSubscriptionDialog: mockShowSubscriptionDialog | ||
| }) | ||
| })) | ||
|
|
||
| vi.mock('@/platform/workspace/composables/useWorkspaceUI', () => ({ | ||
| useWorkspaceUI: () => ({ | ||
| permissions: computed(() => ({ | ||
| canManageSubscription: mockCanManageSubscription.value | ||
| })) | ||
| }) | ||
| })) | ||
|
|
||
| vi.mock('@/platform/distribution/types', () => ({ | ||
| isCloud: true | ||
| })) | ||
|
|
||
| vi.mock('@/platform/telemetry', () => ({ | ||
| useTelemetry: () => null | ||
| })) | ||
|
|
||
| vi.mock('@vueuse/core', async (importOriginal) => { | ||
| const actual = await importOriginal<typeof VueUseCore>() | ||
| return { | ||
| ...actual, | ||
| useBreakpoints: () => ({ | ||
| greaterOrEqual: () => mockIsMdOrLarger | ||
| }) | ||
| } | ||
| }) | ||
|
|
||
| const i18n = createI18n({ | ||
| legacy: false, | ||
| locale: 'en', | ||
| messages: { | ||
| en: { | ||
| subscription: { | ||
| subscribeToRun: 'Subscribe', | ||
| subscribeToRunFull: 'Subscribe to Run', | ||
| inactive: { | ||
| runLabel: 'Run', | ||
| memberRunTooltip: 'Contact your workspace owner to resubscribe' | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| function renderButton() { | ||
| const user = userEvent.setup() | ||
| const result = render(SubscribeToRun, { | ||
| global: { | ||
| plugins: [i18n], | ||
| directives: { tooltip: () => {} } | ||
| } | ||
| }) | ||
| return { ...result, user } | ||
| } | ||
|
|
||
| describe('SubscribeToRun', () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks() | ||
| mockCanManageSubscription.value = true | ||
| mockIsMdOrLarger.value = true | ||
| }) | ||
|
|
||
| it('shows the subscribe label for owners who can manage the subscription', () => { | ||
| renderButton() | ||
|
|
||
| expect(screen.getByTestId('subscribe-to-run-button')).toHaveTextContent( | ||
| 'Subscribe to Run' | ||
| ) | ||
| }) | ||
|
|
||
| it('shows a neutral run label for members who cannot subscribe', () => { | ||
| mockCanManageSubscription.value = false | ||
| renderButton() | ||
|
|
||
| const button = screen.getByTestId('subscribe-to-run-button') | ||
| expect(button).toHaveTextContent('Run') | ||
| expect(button).not.toHaveTextContent('Subscribe') | ||
| }) | ||
|
|
||
| it('opens the subscription dialog for owners on click', async () => { | ||
| const { user } = renderButton() | ||
|
|
||
| await user.click(screen.getByTestId('subscribe-to-run-button')) | ||
|
|
||
| expect(mockShowSubscriptionDialog).toHaveBeenCalledOnce() | ||
| }) | ||
|
|
||
| it('routes members to the same role-aware dialog on click', async () => { | ||
| mockCanManageSubscription.value = false | ||
| const { user } = renderButton() | ||
|
|
||
| await user.click(screen.getByTestId('subscribe-to-run-button')) | ||
|
|
||
| expect(mockShowSubscriptionDialog).toHaveBeenCalledOnce() | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/platform/workspace/components/SubscriptionInactiveMemberDialog.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { render, screen } from '@testing-library/vue' | ||
| import userEvent from '@testing-library/user-event' | ||
| import { describe, expect, it, vi } from 'vitest' | ||
| import { createI18n } from 'vue-i18n' | ||
|
|
||
| import SubscriptionInactiveMemberDialog from './SubscriptionInactiveMemberDialog.vue' | ||
|
|
||
| const i18n = createI18n({ | ||
| legacy: false, | ||
| locale: 'en', | ||
| messages: { | ||
| en: { | ||
| g: { close: 'Close' }, | ||
| subscription: { | ||
| inactive: { | ||
| memberTitle: "This workspace's subscription is inactive", | ||
| memberDescription: | ||
| "Ask your workspace owner to reactivate the workspace's subscription to run workflows.", | ||
| memberCta: 'Ok, got it' | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| function renderComponent(onClose = vi.fn()) { | ||
| render(SubscriptionInactiveMemberDialog, { | ||
| props: { onClose }, | ||
| global: { plugins: [i18n] } | ||
| }) | ||
| return onClose | ||
| } | ||
|
|
||
| describe('SubscriptionInactiveMemberDialog', () => { | ||
| it('renders the inactive title, description and CTA', () => { | ||
| renderComponent() | ||
| expect( | ||
| screen.getByText("This workspace's subscription is inactive") | ||
| ).toBeInTheDocument() | ||
| expect( | ||
| screen.getByText( | ||
| "Ask your workspace owner to reactivate the workspace's subscription to run workflows." | ||
| ) | ||
| ).toBeInTheDocument() | ||
| expect( | ||
| screen.getByRole('button', { name: 'Ok, got it' }) | ||
| ).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('exposes no subscribe affordance', () => { | ||
| renderComponent() | ||
| expect(screen.queryByText(/subscribe/i)).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('calls onClose when the CTA is clicked', async () => { | ||
| const user = userEvent.setup() | ||
| const onClose = renderComponent() | ||
|
|
||
| await user.click(screen.getByRole('button', { name: 'Ok, got it' })) | ||
|
|
||
| expect(onClose).toHaveBeenCalledOnce() | ||
| }) | ||
|
|
||
| it('calls onClose when the header close button is clicked', async () => { | ||
| const user = userEvent.setup() | ||
| const onClose = renderComponent() | ||
|
|
||
| await user.click(screen.getByRole('button', { name: 'Close' })) | ||
|
|
||
| expect(onClose).toHaveBeenCalledOnce() | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.