diff --git a/src/locales/en/main.json b/src/locales/en/main.json index 85a40305722..b99bb1498bc 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -3632,10 +3632,12 @@ "credits": { "addCredits": "Add credits", "available": "Available", + "availableUntil": "Available until {date}", "inUse": "In use now", "overdrawn": "Your runs used {count} more credit than you had. | Your runs used {count} more credits than you had.", "plan": "Plan", "planOfPool": "{remaining} of {total}", + "planUsed": "{percent}% used", "planTooltip": "Credits included with your plan. They refill each billing period.", "rateInfo": "About credits", "rateTooltip": "Credits pay for runs. {credits} credits = $1.", @@ -3644,6 +3646,10 @@ "topUpTooltip": "Credits you added. They're used once plan credits run out.", "unavailable": "Couldn't load your balance." }, + "footer": { + "messageSupport": "Message support", + "partnerNodesPricing": "Partner Nodes pricing" + }, "handoff": { "member": { "action": "View usage", @@ -3651,7 +3657,9 @@ }, "owner": { "action": "Open billing", - "label": "Payment methods, invoices, and usage" + "label": "Payment methods, invoices, and usage", + "line": "Manage everything else about billing on {platform}", + "platform": "platform.comfy.org" } }, "loadError": "We couldn't load your plan.", diff --git a/src/platform/billing/components/billingTab/BillingCreditsCard.test.ts b/src/platform/billing/components/billingTab/BillingCreditsCard.test.ts index 9f8e6d75302..6707533aabd 100644 --- a/src/platform/billing/components/billingTab/BillingCreditsCard.test.ts +++ b/src/platform/billing/components/billingTab/BillingCreditsCard.test.ts @@ -30,7 +30,8 @@ const activeFacts: CreditsCardFacts = { planKind: 'active', billingStatus: 'paid', planPoolCredits: 1000, - renewalDate: null + renewalDate: null, + endDate: null } const SUBSCRIBE_NOTE = @@ -108,7 +109,7 @@ describe('BillingCreditsCard', () => { case: 'a paused plan keeps the real balance and empties the plan line', facts: { billingStatus: 'paused', planKind: 'paused' }, available: '1,477', - plan: '0 of 1,000 Refills when the payment goes through', + plan: '0 of 1,000', topUp: '633', inUse: false, addCredits: true, @@ -223,15 +224,86 @@ describe('BillingCreditsCard', () => { ) }) - it('ends the plan line with the renewal date', () => { - renderCard({ - ...activeFacts, - renewalDate: '2026-10-01T00:00:00Z' - }) + it.for<{ + case: string + facts: Partial + amount: string + date: string + used: string | null + meter: string | null + }>([ + { + case: 'an active plan refills on its renewal date', + facts: { renewalDate: '2026-10-01T00:00:00Z' }, + amount: '844 of 1,000', + date: 'Refills October 1, 2026', + used: '16% used', + meter: '16' + }, + { + case: 'an ending plan is available until its end date', + facts: { + planKind: 'ending', + renewalDate: '2026-10-01T00:00:00Z', + endDate: '2026-12-31T12:00:00Z' + }, + amount: '844 of 1,000', + date: 'Available until December 31, 2026', + used: '16% used', + meter: '16' + }, + { + case: 'a plan with no known total shows no meter', + facts: { planPoolCredits: null, renewalDate: '2026-10-01T00:00:00Z' }, + amount: '844', + date: 'Refills October 1, 2026', + used: null, + meter: null + }, + { + case: 'a paused plan keeps the pool but shows no usage', + facts: { + billingStatus: 'paused', + planKind: 'paused', + renewalDate: '2026-10-01T00:00:00Z' + }, + amount: '0 of 1,000', + date: 'Refills when the payment goes through', + used: null, + meter: null + }, + { + case: 'used-up plan credits fill the meter', + facts: { balance: balanceOf({ effective: 300, plan: 0, topUp: 300 }) }, + amount: '0 of 1,000', + date: '', + used: '100% used', + meter: '100' + } + ])('splits the plan cell for $case', (row) => { + renderCard({ ...activeFacts, ...row.facts }) expect(screen.getByTestId('billing-credits-plan').textContent.trim()).toBe( - '844 of 1,000 Refills October 1, 2026' + row.amount ) + expect( + screen.queryByTestId('billing-credits-plan-date')?.textContent.trim() ?? + '' + ).toBe(row.date) + expect( + screen.queryByTestId('billing-credits-plan-used')?.textContent.trim() ?? + null + ).toBe(row.used) + expect( + screen.queryByRole('meter')?.getAttribute('aria-valuenow') ?? null + ).toBe(row.meter) + }) + + it('shows nothing under the amount without a date or a total', () => { + renderCard({ ...activeFacts, planPoolCredits: null }) + + expect(screen.queryByTestId('billing-credits-plan-date')).toBeNull() + expect(screen.queryByRole('meter')).toBeNull() }) it('waits for the payment instead of a renewal date on a paused plan', () => { @@ -242,9 +314,10 @@ describe('BillingCreditsCard', () => { renewalDate: '2026-11-23T00:00:00Z' }) - expect(screen.getByTestId('billing-credits-plan').textContent.trim()).toBe( - '0 of 1,000 Refills when the payment goes through' - ) + expect( + screen.getByTestId('billing-credits-plan-date').textContent.trim() + ).toBe('Refills when the payment goes through') + expect(screen.queryByRole('meter')).toBeNull() }) it('puts the credits title above a 12px card', () => { @@ -263,9 +336,7 @@ describe('BillingCreditsCard', () => { 'text-2xl', 'font-medium' ) - expect(screen.getByTestId('billing-credits-plan')).toHaveClass( - 'font-semibold' - ) + expect(screen.getByText('844')).toHaveClass('font-semibold') }) it('asks for the balance again from Try again', async () => { diff --git a/src/platform/billing/components/billingTab/BillingCreditsCard.vue b/src/platform/billing/components/billingTab/BillingCreditsCard.vue index 8cf862b9ebe..42dd295128e 100644 --- a/src/platform/billing/components/billingTab/BillingCreditsCard.vue +++ b/src/platform/billing/components/billingTab/BillingCreditsCard.vue @@ -82,25 +82,7 @@
-
- - {{ $t('workspacePanel.billingTab.credits.plan') }} -