diff --git a/src/locales/en/main.json b/src/locales/en/main.json index b31540729c9..a73c34c18e1 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -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", diff --git a/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.stories.ts b/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.stories.ts index b4c8dd2ccd7..a653dbe0b9a 100644 --- a/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.stories.ts +++ b/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.stories.ts @@ -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( @@ -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 = { + 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) diff --git a/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.test.ts b/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.test.ts index b26624972c0..86eedfd67e7 100644 --- a/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.test.ts +++ b/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.test.ts @@ -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', @@ -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, @@ -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' }) @@ -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() }) @@ -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) }) @@ -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, @@ -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() }) @@ -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() }) @@ -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() @@ -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() + }) }) }) diff --git a/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.vue b/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.vue index 9e285784c4e..8a9e81e104e 100644 --- a/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.vue +++ b/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.vue @@ -38,11 +38,7 @@ size="lg" @click="handleAddCredits" > - {{ - canTopUp - ? $t('workspacePanel.billingStatus.outOfCredits.addCredits') - : $t('subscription.upgradeToAddCredits') - }} + {{ $t('workspacePanel.billingStatus.outOfCredits.addCredits') }} +