From 4397be2ab4a167ed5865631923536a778a18e2b0 Mon Sep 17 00:00:00 2001 From: dante01yoon Date: Fri, 30 Oct 2026 17:21:02 -0400 Subject: [PATCH 1/4] feat(billing): link the Add credits dialog to auto top-up settings Adds "Auto top-up settings" next to "View pricing details" in both Add credits dialogs. It opens the billing site's auto top-up section and shows only where auto top-up is served for the account and the viewer can manage it, the same rule as the Billing tab card, on Cloud and local. --- src/locales/en/main.json | 1 + .../components/TopUpAutoTopUpLink.test.ts | 79 +++++++++++++++++++ .../billing/components/TopUpAutoTopUpLink.vue | 25 ++++++ .../TopUpCreditsDialogContentLegacy.vue | 4 +- .../TopUpCreditsDialogContentWorkspace.vue | 4 +- 5 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 src/platform/billing/components/TopUpAutoTopUpLink.test.ts create mode 100644 src/platform/billing/components/TopUpAutoTopUpLink.vue diff --git a/src/locales/en/main.json b/src/locales/en/main.json index b58e3424435..d50b0517b88 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -3042,6 +3042,7 @@ "verifyTitle": "Verify your payment", "startOver": "Start over", "viewPricing": "View pricing details", + "autoTopUpSettings": "Auto top-up settings", "youPay": "Amount (USD)", "youGet": "Credits", "buyCredits": "Continue to payment", diff --git a/src/platform/billing/components/TopUpAutoTopUpLink.test.ts b/src/platform/billing/components/TopUpAutoTopUpLink.test.ts new file mode 100644 index 00000000000..cad78cf5543 --- /dev/null +++ b/src/platform/billing/components/TopUpAutoTopUpLink.test.ts @@ -0,0 +1,79 @@ +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 enMessages from '@/locales/en/main.json' +import { useTelemetry } from '@comfyorg/telemetry' +import { + autoTopUpEnabledFact, + canManageAutoTopUpFact +} from '@/platform/billing/composables/__mocks__/useBillingCapabilities' +import { useBillingCapabilities } from '@/platform/billing/composables/useBillingCapabilities' + +import TopUpAutoTopUpLink from './TopUpAutoTopUpLink.vue' + +vi.mock(import('@/platform/billing/composables/useBillingCapabilities')) +vi.mock(import('@comfyorg/telemetry')) +vi.mock(import('@/platform/workspace/utils/platformLink'), () => ({ + platformLink: (path: string, correlationId?: string) => + `https://platform.test${path}?correlation_id=${correlationId}` +})) + +function renderLink({ enabled, owner }: { enabled: boolean; owner: boolean }) { + useBillingCapabilities().autoTopUpEnabled = autoTopUpEnabledFact(enabled) + useBillingCapabilities().canManageAutoTopUp = canManageAutoTopUpFact(owner) + render(TopUpAutoTopUpLink, { + global: { + plugins: [ + createI18n({ + legacy: false, + locale: 'en', + messages: { en: enMessages } + }) + ] + } + }) +} + +describe('TopUpAutoTopUpLink', () => { + it('links an owner with auto top-up served to the billing site', () => { + renderLink({ enabled: true, owner: true }) + + expect( + screen.getByRole('link', { name: 'Auto top-up settings' }) + ).toHaveAttribute( + 'href', + expect.stringContaining('https://platform.test/profile/billing') + ) + }) + + it.for([ + { name: 'auto top-up is not served', enabled: false, owner: true }, + { name: 'the viewer cannot manage it', enabled: true, owner: false } + ])('shows nothing when $name', ({ enabled, owner }) => { + renderLink({ enabled, owner }) + + expect( + screen.queryByRole('link', { name: 'Auto top-up settings' }) + ).toBeNull() + }) + + it('reports the hand-off to the billing site', async () => { + const trackBillingEvent = vi.fn() + vi.mocked(useTelemetry).mockReturnValue({ trackBillingEvent } as never) + renderLink({ enabled: true, owner: true }) + + await userEvent.click( + screen.getByRole('link', { name: 'Auto top-up settings' }) + ) + + expect(trackBillingEvent).toHaveBeenCalledWith( + expect.objectContaining({ + operation: 'platform_handoff', + target: 'auto_top_up', + action: 'manage' + }) + ) + }) +}) diff --git a/src/platform/billing/components/TopUpAutoTopUpLink.vue b/src/platform/billing/components/TopUpAutoTopUpLink.vue new file mode 100644 index 00000000000..4f2af279231 --- /dev/null +++ b/src/platform/billing/components/TopUpAutoTopUpLink.vue @@ -0,0 +1,25 @@ + + + diff --git a/src/platform/billing/components/TopUpCreditsDialogContentLegacy.vue b/src/platform/billing/components/TopUpCreditsDialogContentLegacy.vue index 4d2922cbdc8..e02da913d78 100644 --- a/src/platform/billing/components/TopUpCreditsDialogContentLegacy.vue +++ b/src/platform/billing/components/TopUpCreditsDialogContentLegacy.vue @@ -77,7 +77,7 @@ > {{ $t('credits.topUp.buyCredits') }} -
+
+
@@ -101,6 +102,7 @@ import { creditsToUsd, usdToCredits } from '@/base/credits/comfyCredits' import Button from '@comfyorg/design-system/button/Button' import DialogTitle from '@comfyorg/design-system/dialog/DialogTitle' import TopUpAmountFields from './TopUpAmountFields.vue' +import TopUpAutoTopUpLink from './TopUpAutoTopUpLink.vue' import { useToast } from '@/components/ui/toast/toastStore' import { useAuthActions } from '@/composables/auth/useAuthActions' import { useBillingContext } from '@/platform/billing/composables/useBillingContext' diff --git a/src/platform/billing/components/TopUpCreditsDialogContentWorkspace.vue b/src/platform/billing/components/TopUpCreditsDialogContentWorkspace.vue index 4397693c7a0..0046e5bb6b0 100644 --- a/src/platform/billing/components/TopUpCreditsDialogContentWorkspace.vue +++ b/src/platform/billing/components/TopUpCreditsDialogContentWorkspace.vue @@ -345,7 +345,7 @@
+
@@ -381,6 +382,7 @@ import { import Button from '@comfyorg/design-system/button/Button' import DialogTitle from '@comfyorg/design-system/dialog/DialogTitle' import TopUpAmountFields from './TopUpAmountFields.vue' +import TopUpAutoTopUpLink from './TopUpAutoTopUpLink.vue' import { watchForTopupBalanceUpdate } from '@/platform/billing/composables/topupBalanceRefresh' import { useTopUpPlanCreditCopy } from '@/platform/billing/composables/useTopUpPlanCreditCopy' import { useBillingContext } from '@/platform/billing/composables/useBillingContext' From f2af610513ff88e0a505dac32246a28692367318 Mon Sep 17 00:00:00 2001 From: dante01yoon Date: Fri, 30 Oct 2026 18:44:55 -0400 Subject: [PATCH 2/4] feat(billing): auto top-up card in the Add credits dialog, per the 1.60 design Replaces the footer link with the card from Alex's 1.60 screenshot: "Auto top-up / Refills credits when your balance runs low." with a "Set up" button to the billing site, above the Add credits button. --- src/locales/en/main.json | 6 ++- ...ink.test.ts => TopUpAutoTopUpCard.test.ts} | 24 +++++------ .../billing/components/TopUpAutoTopUpCard.vue | 42 +++++++++++++++++++ .../billing/components/TopUpAutoTopUpLink.vue | 25 ----------- .../TopUpCreditsDialogContentLegacy.vue | 26 ++++++------ .../TopUpCreditsDialogContentWorkspace.vue | 6 +-- 6 files changed, 75 insertions(+), 54 deletions(-) rename src/platform/billing/components/{TopUpAutoTopUpLink.test.ts => TopUpAutoTopUpCard.test.ts} (78%) create mode 100644 src/platform/billing/components/TopUpAutoTopUpCard.vue delete mode 100644 src/platform/billing/components/TopUpAutoTopUpLink.vue diff --git a/src/locales/en/main.json b/src/locales/en/main.json index d50b0517b88..654ea42986d 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -3042,7 +3042,11 @@ "verifyTitle": "Verify your payment", "startOver": "Start over", "viewPricing": "View pricing details", - "autoTopUpSettings": "Auto top-up settings", + "autoTopUp": { + "title": "Auto top-up", + "body": "Refills credits when your balance runs low.", + "setUp": "Set up" + }, "youPay": "Amount (USD)", "youGet": "Credits", "buyCredits": "Continue to payment", diff --git a/src/platform/billing/components/TopUpAutoTopUpLink.test.ts b/src/platform/billing/components/TopUpAutoTopUpCard.test.ts similarity index 78% rename from src/platform/billing/components/TopUpAutoTopUpLink.test.ts rename to src/platform/billing/components/TopUpAutoTopUpCard.test.ts index cad78cf5543..2ce20bcfb27 100644 --- a/src/platform/billing/components/TopUpAutoTopUpLink.test.ts +++ b/src/platform/billing/components/TopUpAutoTopUpCard.test.ts @@ -11,7 +11,7 @@ import { } from '@/platform/billing/composables/__mocks__/useBillingCapabilities' import { useBillingCapabilities } from '@/platform/billing/composables/useBillingCapabilities' -import TopUpAutoTopUpLink from './TopUpAutoTopUpLink.vue' +import TopUpAutoTopUpCard from './TopUpAutoTopUpCard.vue' vi.mock(import('@/platform/billing/composables/useBillingCapabilities')) vi.mock(import('@comfyorg/telemetry')) @@ -23,7 +23,7 @@ vi.mock(import('@/platform/workspace/utils/platformLink'), () => ({ function renderLink({ enabled, owner }: { enabled: boolean; owner: boolean }) { useBillingCapabilities().autoTopUpEnabled = autoTopUpEnabledFact(enabled) useBillingCapabilities().canManageAutoTopUp = canManageAutoTopUpFact(owner) - render(TopUpAutoTopUpLink, { + render(TopUpAutoTopUpCard, { global: { plugins: [ createI18n({ @@ -36,13 +36,15 @@ function renderLink({ enabled, owner }: { enabled: boolean; owner: boolean }) { }) } -describe('TopUpAutoTopUpLink', () => { - it('links an owner with auto top-up served to the billing site', () => { +describe('TopUpAutoTopUpCard', () => { + it('offers an owner with auto top-up served to set it up on the billing site', () => { renderLink({ enabled: true, owner: true }) expect( - screen.getByRole('link', { name: 'Auto top-up settings' }) - ).toHaveAttribute( + screen.getByText('Refills credits when your balance runs low.') + ).toBeInTheDocument() + + expect(screen.getByRole('link', { name: 'Set up' })).toHaveAttribute( 'href', expect.stringContaining('https://platform.test/profile/billing') ) @@ -54,9 +56,7 @@ describe('TopUpAutoTopUpLink', () => { ])('shows nothing when $name', ({ enabled, owner }) => { renderLink({ enabled, owner }) - expect( - screen.queryByRole('link', { name: 'Auto top-up settings' }) - ).toBeNull() + expect(screen.queryByRole('link', { name: 'Set up' })).toBeNull() }) it('reports the hand-off to the billing site', async () => { @@ -64,15 +64,13 @@ describe('TopUpAutoTopUpLink', () => { vi.mocked(useTelemetry).mockReturnValue({ trackBillingEvent } as never) renderLink({ enabled: true, owner: true }) - await userEvent.click( - screen.getByRole('link', { name: 'Auto top-up settings' }) - ) + await userEvent.click(screen.getByRole('link', { name: 'Set up' })) expect(trackBillingEvent).toHaveBeenCalledWith( expect.objectContaining({ operation: 'platform_handoff', target: 'auto_top_up', - action: 'manage' + action: 'turn_on' }) ) }) diff --git a/src/platform/billing/components/TopUpAutoTopUpCard.vue b/src/platform/billing/components/TopUpAutoTopUpCard.vue new file mode 100644 index 00000000000..54947a60799 --- /dev/null +++ b/src/platform/billing/components/TopUpAutoTopUpCard.vue @@ -0,0 +1,42 @@ + + + diff --git a/src/platform/billing/components/TopUpAutoTopUpLink.vue b/src/platform/billing/components/TopUpAutoTopUpLink.vue deleted file mode 100644 index 4f2af279231..00000000000 --- a/src/platform/billing/components/TopUpAutoTopUpLink.vue +++ /dev/null @@ -1,25 +0,0 @@ - - - diff --git a/src/platform/billing/components/TopUpCreditsDialogContentLegacy.vue b/src/platform/billing/components/TopUpCreditsDialogContentLegacy.vue index e02da913d78..4d6ff0f699f 100644 --- a/src/platform/billing/components/TopUpCreditsDialogContentLegacy.vue +++ b/src/platform/billing/components/TopUpCreditsDialogContentLegacy.vue @@ -68,16 +68,19 @@

- -
+
+ + +
+
-
@@ -102,7 +104,7 @@ import { creditsToUsd, usdToCredits } from '@/base/credits/comfyCredits' import Button from '@comfyorg/design-system/button/Button' import DialogTitle from '@comfyorg/design-system/dialog/DialogTitle' import TopUpAmountFields from './TopUpAmountFields.vue' -import TopUpAutoTopUpLink from './TopUpAutoTopUpLink.vue' +import TopUpAutoTopUpCard from './TopUpAutoTopUpCard.vue' import { useToast } from '@/components/ui/toast/toastStore' import { useAuthActions } from '@/composables/auth/useAuthActions' import { useBillingContext } from '@/platform/billing/composables/useBillingContext' diff --git a/src/platform/billing/components/TopUpCreditsDialogContentWorkspace.vue b/src/platform/billing/components/TopUpCreditsDialogContentWorkspace.vue index 0046e5bb6b0..b9563649989 100644 --- a/src/platform/billing/components/TopUpCreditsDialogContentWorkspace.vue +++ b/src/platform/billing/components/TopUpCreditsDialogContentWorkspace.vue @@ -295,6 +295,7 @@ {{ $t('credits.topUp.paymentProcessingBody') }}

+