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
18 changes: 10 additions & 8 deletions src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -3339,22 +3339,24 @@
},
"outOfCredits": {
"title": "Out of credits",
"body": "Your team has used all its credits. Add more credits to continue generating or wait until credits refill on {date}.",
"bodyNoDate": "Your team has used all its credits. Add more credits to continue generating.",
"memberBody": "Your team has used all its credits. Your workspace admins need to add more credits to continue generating.",
"body": "Your team has used all its credits. Add more credits or wait until credits refill on {date}.",
"bodyNoDate": "Your team has used all its credits. Add more credits.",
"memberBody": "Your team has used all its credits. Ask your workspace owner to add more credits or wait until credits refill on {date}.",
"memberBodyNoDate": "Your team has used all its credits. Ask your workspace owner to add more credits.",
"addCredits": "Add credits",
"dismiss": "Dismiss",
"upgradeBody": "Upgrade your plan to add credits and continue generating."
"dismiss": "Dismiss"
},
"ending": {
"title": "Your team plan ends on {date}",
"body": "Members keep full access until then. Resume your subscription to keep your shared credits and seats.",
"body": "Members keep full access until then. Resume your plan to keep your team's shared credits.",
"memberBody": "You can run workflows until then.",
"enterpriseTitle": "Your Enterprise plan ends on {date}",
"enterpriseBody": "Members keep full access until then. Reach out to our sales team to extend.",
"reactivate": "Resume subscription"
"reactivate": "Resume plan",
"contactSales": "Contact sales"
},
"planChange": {
"title": "Your plan changes to {plan} on {date}",
"title": "Your plan changes to {plan} on {date}.",
"body": "Your current plan stays active until then."
},
"updatePayment": "Update payment",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,28 +162,27 @@ export const OutOfCreditsMember: Story = story(
{ canTopUp: false }
)

/** No top-up entitlement but self-serve upgrade is open: upgrade copy, not contact-admin. */
export const OutOfCreditsSelfServe: Story = story(
/** Cancelled but still active until the period end. Informational. */
export const EndingOwner: Story = story(
{
subscription: exhausted,
subscription: cancelled,
canAccessSubscriptionFeatures: true,
billingStatus: 'paid',
subscriptionStatus: 'active',
renewalDate: RENEWAL_DATE
subscriptionStatus: 'canceled'
},
owner,
{ canTopUp: false, canSubscribeSelfServe: true }
owner
)

/** Cancelled but still active until the period end. Informational. */
export const EndingOwner: Story = story(
/** Members see the end date without an action. */
export const EndingMember: Story = story(
{
subscription: cancelled,
canAccessSubscriptionFeatures: true,
billingStatus: 'paid',
subscriptionStatus: 'canceled'
},
owner
member,
{ canTopUp: false }
)

export const EndingPromotedOwner: Story = story(
Expand Down Expand Up @@ -217,17 +216,18 @@ export const PlanChangeOwner: Story = story(
const TEN_DAYS_MS = 10 * 24 * 60 * 60 * 1000

/** An Enterprise end date stays quiet until it is two weeks out. */
export const EndingEnterpriseOwner: Story = story(
{
subscription: {
...cancelled,
tier: 'ENTERPRISE',
endDate: new Date(Date.now() + TEN_DAYS_MS).toISOString()
},
isTeamPlan: false,
canAccessSubscriptionFeatures: true,
billingStatus: 'paid',
subscriptionStatus: 'canceled'
const enterpriseEnding: Partial<BillingContextMockState> = {
subscription: {
...cancelled,
tier: 'ENTERPRISE',
endDate: new Date(Date.now() + TEN_DAYS_MS).toISOString()
},
owner
)
isTeamPlan: false,
canAccessSubscriptionFeatures: true,
billingStatus: 'paid',
subscriptionStatus: 'canceled'
}

export const EndingEnterpriseOwner: Story = story(enterpriseEnding, owner)

export const EndingEnterpriseMember: Story = story(enterpriseEnding, member)
Original file line number Diff line number Diff line change
Expand Up @@ -113,26 +113,27 @@ const i18n = createI18n({
},
outOfCredits: {
title: 'Out of credits',
body: 'Your team has used all its credits. Add more credits to continue generating or wait until credits refill on {date}.',
bodyNoDate:
'Your team has used all its credits. Add more credits to continue generating.',
upgradeBody:
'Upgrade your plan to add credits and continue generating.',
body: 'Your team has used all its credits. Add more credits or wait until credits refill on {date}.',
bodyNoDate: 'Your team has used all its credits. Add more credits.',
memberBody:
'Your team has used all its credits. Your workspace admins need to add more credits to continue generating.',
'Your team has used all its credits. Ask your workspace owner to add more credits or wait until credits refill on {date}.',
memberBodyNoDate:
'Your team has used all its credits. Ask your workspace owner to add more credits.',
addCredits: 'Add credits',
dismiss: 'Dismiss'
},
ending: {
title: 'Your team plan ends on {date}',
body: 'Members keep full access until then. Resume your subscription to keep your shared credits and seats.',
body: "Members keep full access until then. Resume your plan to keep your team's shared credits.",
memberBody: 'You can run workflows until then.',
enterpriseTitle: 'Your Enterprise plan ends on {date}',
enterpriseBody:
'Members keep full access until then. Reach out to our sales team to extend.',
reactivate: 'Resume subscription'
reactivate: 'Resume plan',
contactSales: 'Contact sales'
},
planChange: {
title: 'Your plan changes to {plan} on {date}',
title: 'Your plan changes to {plan} on {date}.',
body: 'Your current plan stays active until then.'
},
updatePayment: 'Update payment',
Expand Down Expand Up @@ -248,25 +249,17 @@ describe('BillingStatusBanner', () => {
expect(useDialogService().showTopUpCreditsDialog).toHaveBeenCalledTimes(1)
})

it('offers an upgrade when self-serve subscription is available', () => {
it('shows no out-of-credits banner to an owner who cannot buy credits', () => {
exhausted()
useBillingCapabilities().canTopUp = computed(() => false)
useBillingCapabilities().canSubscribeSelfServe = computed(() => true)

renderBanner()

expect(
screen.getByRole('button', { name: 'Upgrade to add credits' })
).toBeVisible()
expect(screen.getByRole('status')).toHaveTextContent(
'Upgrade your plan to add credits and continue generating.'
)
expect(screen.getByRole('status')).not.toHaveTextContent(
'Your workspace admins need to add more credits'
)
expect(screen.queryByRole('status')).not.toBeInTheDocument()
})

it('shows out-of-credits contact-admin copy without an Add credits action for members', () => {
it('points members to the owner without an Add credits action', () => {
state.subscription = {
hasFunds: false,
isCancelled: false,
Expand All @@ -278,7 +271,7 @@ describe('BillingStatusBanner', () => {
renderBanner()

expect(screen.getByRole('status')).toHaveTextContent(
'Your workspace admins need to add more credits'
'Ask your workspace owner to add more credits'
)
expect(
screen.queryByRole('button', { name: 'Add credits' })
Expand Down Expand Up @@ -428,15 +421,20 @@ describe('BillingStatusBanner', () => {
expect(state.manageSubscription).toHaveBeenCalledTimes(1)
})

it('does not expose payment controls to members', () => {
it('points members to the owner on a failed renewal, without payment controls', () => {
paymentFailedState()
state.canManageSubscription = false
state.renewalInvoice = {
hosted_invoice_url: 'https://invoice.stripe.com/i/acct_1/test_123',
amount_due: 5000,
currency: 'usd'
}
renderBanner()

expect(screen.queryByRole('status')).not.toBeInTheDocument()
expect(
screen.queryByRole('button', { name: 'Update payment' })
).not.toBeInTheDocument()
expect(screen.getByRole('status')).toHaveTextContent(
"Ask your workspace owner to restore the workspace's subscription."
)
expect(screen.queryByRole('button')).not.toBeInTheDocument()
expect(state.manageSubscription).not.toHaveBeenCalled()
})

Expand Down Expand Up @@ -466,9 +464,7 @@ describe('BillingStatusBanner', () => {
expect(screen.getByRole('status')).toHaveTextContent(
'Your team plan ends on'
)
await userEvent.click(
screen.getByRole('button', { name: 'Resume subscription' })
)
await userEvent.click(screen.getByRole('button', { name: 'Resume plan' }))
expect(state.handleResubscribe).toHaveBeenCalledTimes(1)
})

Expand All @@ -486,13 +482,11 @@ describe('BillingStatusBanner', () => {
}
renderBanner()

await userEvent.click(
screen.getByRole('button', { name: 'Resume subscription' })
)
await userEvent.click(screen.getByRole('button', { name: 'Resume plan' }))
expect(state.handleResubscribe).toHaveBeenCalledTimes(1)
})

it('does not expose reactivation controls to a member', () => {
it('shows members the ending notice without a Resume plan action', () => {
state.subscription = {
hasFunds: true,
isCancelled: true,
Expand All @@ -504,9 +498,11 @@ describe('BillingStatusBanner', () => {
useBillingCapabilities().canReactivate = computed(() => false)
renderBanner()

expect(screen.queryByRole('status')).not.toBeInTheDocument()
expect(screen.getByRole('status')).toHaveTextContent(
'You can run workflows until then.'
)
expect(
screen.queryByRole('button', { name: 'Resume subscription' })
screen.queryByRole('button', { name: 'Resume plan' })
).not.toBeInTheDocument()
})

Expand All @@ -526,7 +522,7 @@ describe('BillingStatusBanner', () => {
'Your team plan ends on'
)
expect(
screen.queryByRole('button', { name: 'Resume subscription' })
screen.queryByRole('button', { name: 'Resume plan' })
).not.toBeInTheDocument()
})

Expand All @@ -535,10 +531,32 @@ describe('BillingStatusBanner', () => {
renderBanner()

expect(screen.getByRole('status')).toHaveTextContent(
'Your plan changes to Pro on Oct 1, 2026'
'Your plan changes to Pro on October 1, 2026.'
)
})

it('still renders the ending banner when the end date is malformed', () => {
state.subscription = {
hasFunds: true,
isCancelled: true,
endDate: 'not-a-date',
scheduledChange: null
}
renderBanner()

expect(screen.getByRole('status')).toHaveTextContent(
'Members keep full access until then.'
)
})

it('dismisses a scheduled change banner', async () => {
scheduledFor('pro-annual')
renderBanner()

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

it('quotes no price for a scheduled change', () => {
scheduledFor('pro-annual')
renderBanner()
Expand Down Expand Up @@ -594,8 +612,36 @@ describe('BillingStatusBanner', () => {
'Reach out to our sales team to extend'
)
expect(
screen.queryByRole('button', { name: 'Resume subscription' })
screen.queryByRole('button', { name: 'Resume plan' })
).not.toBeInTheDocument()
})

it('sends owners to sales', async () => {
enterpriseEndingIn(10)
const open = vi.spyOn(window, 'open').mockReturnValue(null)
renderBanner()

await userEvent.click(
screen.getByRole('button', { name: 'Contact sales' })
)

expect(open).toHaveBeenCalledWith(
'https://comfy.org/cloud/enterprise/',
'_blank',
'noopener,noreferrer'
)
open.mockRestore()
})

it('tells members they can run until the end date, with no action', () => {
enterpriseEndingIn(10)
state.canManageSubscription = false
renderBanner()

expect(screen.getByRole('status')).toHaveTextContent(
'You can run workflows until then.'
)
expect(screen.queryByRole('button')).not.toBeInTheDocument()
})
})
})
Loading
Loading