Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -3359,6 +3359,16 @@
"reactivate": "Resume plan",
"contactSales": "Contact sales"
},
"planEnded": {
"teamTitle": "Your team plan ended on {date}",
"teamBody": "Resubscribe to run workflows and get shared credits again.",
"teamMemberBody": "Ask your workspace owner to resubscribe.",
"enterpriseTitle": "Your Enterprise plan ended on {date}",
"enterpriseBody": "Contact sales to start a new Enterprise plan.",
"planTitle": "Your plan ended on {date}",
"salesBody": "Contact sales to start a new plan.",
"salesMemberBody": "Ask your workspace owner to contact sales."
},
"planChange": {
"title": "Your plan changes to {plan} on {date}.",
"body": "Your current plan stays active until then."
Expand Down Expand Up @@ -3431,6 +3441,7 @@
"reactivateTeam": "Reactivate Team",
"totalMembersCount": "{count} of {maxSeats} total members.",
"needMoreMembers": "Need more members?",
"planEndedFooter": "Your plan has ended, so you can't add new members.",
"contactUs": "Contact us",
"noInvites": "No pending invites",
"noInvitesMatch": "No invites match \"{query}\"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,32 @@ const enterpriseEnding: Partial<BillingContextMockState> = {
export const EndingEnterpriseOwner: Story = story(enterpriseEnding, owner)

export const EndingEnterpriseMember: Story = story(enterpriseEnding, member)

const endedTeam: Partial<BillingContextMockState> = {
subscription: {
...cancelled,
tier: 'PRO',
hasFunds: false,
endDate: '2026-09-12T12:00:00Z'
},
canAccessSubscriptionFeatures: false,
billingStatus: 'inactive',
subscriptionStatus: 'ended'
}

/** The plan is over. Ships without the billing control flag. */
export const PlanEndedOwner: Story = story(endedTeam, owner)

export const PlanEndedMember: Story = story(endedTeam, member, {
canTopUp: false
})

const endedEnterprise: Partial<BillingContextMockState> = {
...endedTeam,
subscription: { ...endedTeam.subscription!, tier: 'ENTERPRISE' },
isTeamPlan: false
}

export const PlanEndedEnterpriseOwner: Story = story(endedEnterprise, owner)

export const PlanEndedEnterpriseMember: Story = story(endedEnterprise, member)
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const state = vi.hoisted(() => ({
canAccessSubscriptionFeatures: true,
isTeamPlan: true,
billingStatus: 'paid' as string | null,
subscriptionStatus: 'active' as string | null,
subscription: {
hasFunds: true,
isCancelled: false,
Expand All @@ -41,7 +42,8 @@ const state = vi.hoisted(() => ({
canReactivatePlan: true,
shouldUseWorkspaceBilling: true,
manageSubscription: vi.fn(),
handleResubscribe: vi.fn()
handleResubscribe: vi.fn(),
showSubscriptionDialog: vi.fn()
}))

vi.mock<unknown>(import('@/composables/billing/useBillingRouting'), () => ({
Expand All @@ -61,6 +63,7 @@ vi.mock<unknown>(import('@/composables/billing/useBillingContext'), () => ({
),
isTeamPlan: computed(() => state.isTeamPlan),
billingStatus: computed(() => state.billingStatus as BillingStatus | null),
subscriptionStatus: computed(() => state.subscriptionStatus),
subscription: computed(() => state.subscription),
plans: computed(() => [
{ slug: 'pro-annual', tier: 'PRO', duration: 'ANNUAL' }
Expand Down Expand Up @@ -98,12 +101,25 @@ vi.mock(import('@/platform/workspace/composables/useResubscribe'), () => ({

vi.mock(import('@/services/dialogService'))

vi.mock<unknown>(
import('@/platform/cloud/subscription/composables/useSubscriptionDialog'),
() => ({
useSubscriptionDialog: () => ({ show: state.showSubscriptionDialog })
})
)

const i18n = createI18n({
legacy: false,
locale: 'en',
messages: {
en: {
workspacePanel: {
members: {
resubscribe: 'Resubscribe',
endedTeamTitle: 'Your team plan has ended',
endedEnterpriseTitle: 'Your Enterprise plan has ended',
endedPlanTitle: 'Your plan has ended'
},
billingStatus: {
paused: {
title: 'Subscription paused',
Expand Down Expand Up @@ -132,6 +148,17 @@ const i18n = createI18n({
reactivate: 'Resume plan',
contactSales: 'Contact sales'
},
planEnded: {
teamTitle: 'Your team plan ended on {date}',
teamBody:
'Resubscribe to run workflows and get shared credits again.',
teamMemberBody: 'Ask your workspace owner to resubscribe.',
enterpriseTitle: 'Your Enterprise plan ended on {date}',
enterpriseBody: 'Contact sales to start a new Enterprise plan.',
planTitle: 'Your plan ended on {date}',
salesBody: 'Contact sales to start a new plan.',
salesMemberBody: 'Ask your workspace owner to contact sales.'
},
planChange: {
title: 'Your plan changes to {plan} on {date}.',
body: 'Your current plan stays active until then.'
Expand Down Expand Up @@ -202,6 +229,7 @@ describe('BillingStatusBanner', () => {
state.canAccessSubscriptionFeatures = true
state.isTeamPlan = true
state.billingStatus = 'paid'
state.subscriptionStatus = 'active'
state.subscription = {
hasFunds: true,
isCancelled: false,
Expand Down Expand Up @@ -571,6 +599,85 @@ describe('BillingStatusBanner', () => {
expect(screen.queryByRole('status')).not.toBeInTheDocument()
})

describe('plan ended', () => {
function endedPlan(tier: SubscriptionInfo['tier'] = 'PRO') {
state.subscriptionStatus = 'ended'
state.billingStatus = 'inactive'
state.canAccessSubscriptionFeatures = false
state.subscription = {
hasFunds: false,
isCancelled: true,
endDate: '2026-09-12T12:00:00Z',
scheduledChange: null,
tier
}
}

it('lets a team owner resubscribe through the pricing table', async () => {
endedPlan()
renderBanner()

expect(screen.getByRole('status')).toHaveTextContent(
'Your team plan ended on September 12, 2026'
)
await userEvent.click(screen.getByRole('button', { name: 'Resubscribe' }))
expect(state.showSubscriptionDialog).toHaveBeenCalledWith(
expect.objectContaining({ planMode: 'team' })
)
})

it('points a team member to the owner', () => {
endedPlan()
state.canManageSubscription = false
renderBanner()

expect(screen.getByRole('status')).toHaveTextContent(
'Ask your workspace owner to resubscribe.'
)
expect(
screen.queryByRole('button', { name: 'Resubscribe' })
).not.toBeInTheDocument()
})

it('sends an Enterprise owner to sales', async () => {
endedPlan('ENTERPRISE')
state.isTeamPlan = false
const open = vi.spyOn(window, 'open').mockReturnValue(null)
renderBanner()

expect(screen.getByRole('status')).toHaveTextContent(
'Your Enterprise plan ended on September 12, 2026'
)
await userEvent.click(
screen.getByRole('button', { name: 'Contact sales' })
)
expect(open).toHaveBeenCalledWith(
'https://comfy.org/cloud/enterprise/',
'_blank',
'noopener,noreferrer'
)
open.mockRestore()
})

it('dismisses for the session', async () => {
endedPlan()
renderBanner()

await userEvent.click(screen.getByRole('button', { name: 'Dismiss' }))
expect(screen.queryByRole('status')).not.toBeInTheDocument()
})

it('shows even when billing control is rolled back', () => {
endedPlan()
vi.mocked(useFeatureFlags().flags).billingControlEnabled = false
renderBanner()

expect(screen.getByRole('status')).toHaveTextContent(
'Your team plan ended on'
)
})
})

describe('enterprise ending notice', () => {
const NOW = new Date('2026-09-03T12:00:00Z')
const DAY = 24 * 60 * 60 * 1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
>
{{ $t('workspacePanel.billingStatus.ending.reactivate') }}
</Button>
<Button
v-else-if="banner.action === 'resubscribe'"
variant="secondary"
size="lg"
@click="handleResubscribePlan"
>
{{ $t('workspacePanel.members.resubscribe') }}
</Button>
<Button
v-else-if="banner.action === 'contactSales'"
variant="secondary"
Expand Down Expand Up @@ -87,8 +95,10 @@ import { useI18n } from 'vue-i18n'
import Button from '@/components/ui/button/Button.vue'
import { useBillingContext } from '@/composables/billing/useBillingContext'
import { ENTERPRISE_URL } from '@/platform/cloud/subscription/constants/tierPricing'
import { useSubscriptionDialog } from '@/platform/cloud/subscription/composables/useSubscriptionDialog'
import { useBillingBanner } from '@/platform/workspace/composables/useBillingBanner'
import { useBillingCapabilities } from '@/platform/workspace/composables/useBillingCapabilities'
import { usePlanEnded } from '@/platform/workspace/composables/usePlanEnded'
import { useResubscribe } from '@/platform/workspace/composables/useResubscribe'
import { useScheduledPlanChange } from '@/platform/workspace/composables/useScheduledPlanChange'
import { useWorkspaceUI } from '@/platform/workspace/composables/useWorkspaceUI'
Expand All @@ -97,6 +107,7 @@ import { useDialogService } from '@/services/dialogService'
type BannerAction =
| 'addCredits'
| 'reactivate'
| 'resubscribe'
| 'contactSales'
| 'updatePayment'

Expand All @@ -113,6 +124,9 @@ const {
isDisplayable: canShowScheduledChange
} = useScheduledPlanChange()
const dialogService = useDialogService()
const subscriptionDialog = useSubscriptionDialog()
const { isSalesManagedPlan, isEnterprisePlan: isEndedEnterprisePlan } =
usePlanEnded()

const canManage = computed(() => permissions.value.canManageSubscription)
// Strictly ENTERPRISE: an unrecognized tier must not borrow Enterprise copy
Expand Down Expand Up @@ -163,6 +177,49 @@ const paymentFailedView = (): BannerView => ({
payInvoiceUrl: safeInvoiceUrl(renewalInvoice.value?.hosted_invoice_url)
})

// Sales-managed plans (Enterprise, and unrecognized tiers, which fail closed
// to sales) return through sales; only a strict ENTERPRISE tier is named.
function planEndedCopy(): {
title: string
ownerBody: string
memberBody: string
} {
const date = planEndDate.value
if (!isSalesManagedPlan.value) {
return {
title: date
? t(`${bs}.planEnded.teamTitle`, { date })
: t('workspacePanel.members.endedTeamTitle'),
ownerBody: t(`${bs}.planEnded.teamBody`),
memberBody: t(`${bs}.planEnded.teamMemberBody`)
}
}
const named = isEndedEnterprisePlan.value
return {
title: date
? t(`${bs}.planEnded.${named ? 'enterpriseTitle' : 'planTitle'}`, {
date
})
: t(
`workspacePanel.members.${named ? 'endedEnterpriseTitle' : 'endedPlanTitle'}`
),
ownerBody: t(`${bs}.planEnded.${named ? 'enterpriseBody' : 'salesBody'}`),
memberBody: t(`${bs}.planEnded.salesMemberBody`)
}
}

const planEndedView = (): BannerView => {
const copy = planEndedCopy()
const ownerAction = isSalesManagedPlan.value ? 'contactSales' : 'resubscribe'
return {
muted: true,
title: copy.title,
body: canManage.value ? copy.ownerBody : copy.memberBody,
action: canManage.value ? ownerAction : null,
dismissible: true
}
}

const outOfCreditsBody = (key: 'body' | 'memberBody'): string =>
cycleResetDate.value
? t(`${bs}.outOfCredits.${key}`, { date: cycleResetDate.value })
Expand Down Expand Up @@ -234,6 +291,8 @@ const banner = computed<BannerView | null>(() => {
return pausedView()
case 'paymentFailed':
return paymentFailedView()
case 'planEnded':
return planEndedView()
case 'outOfCredits':
return outOfCreditsView()
case 'ending':
Expand All @@ -248,6 +307,12 @@ const banner = computed<BannerView | null>(() => {
function handleAddCredits() {
void dialogService.showTopUpCreditsDialog()
}
function handleResubscribePlan() {
subscriptionDialog.show({
planMode: 'team',
reason: 'settings_billing_panel'
})
}
function handleContactSales() {
window.open(ENTERPRISE_URL, '_blank', 'noopener,noreferrer')
}
Expand Down
Loading
Loading