From 57fb252d9b473d9f27b6dfe4425cbaf30abd6c5a Mon Sep 17 00:00:00 2001 From: comfydesigner Date: Wed, 2 Sep 2026 17:02:38 -0700 Subject: [PATCH 1/4] fix(billing): only one subscribe CTA at a time --- .../topbar/TopbarSubscribeButton.test.ts | 35 ++++++++++++++++--- .../topbar/TopbarSubscribeButton.vue | 4 +-- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/components/topbar/TopbarSubscribeButton.test.ts b/src/components/topbar/TopbarSubscribeButton.test.ts index 36d172a7421..68c8d8c5038 100644 --- a/src/components/topbar/TopbarSubscribeButton.test.ts +++ b/src/components/topbar/TopbarSubscribeButton.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, it, vi } from 'vitest' +import { beforeEach, describe, expect, it, vi } from 'vitest' import { createI18n } from 'vue-i18n' import { render, screen } from '@testing-library/vue' @@ -26,12 +26,23 @@ vi.mock( }) ) -vi.mock('@/composables/billing/useBillingContext', () => ({ - useBillingContext: vi.fn(() => ({ - isFreeTier: { value: true } - })) +const mockBilling = vi.hoisted(() => ({ + isFreeTier: true, + showsSubscribeToRunPrompt: false })) +vi.mock('@/composables/billing/useBillingContext', async () => { + const { computed } = await import('vue') + return { + useBillingContext: vi.fn(() => ({ + isFreeTier: computed(() => mockBilling.isFreeTier), + showsSubscribeToRunPrompt: computed( + () => mockBilling.showsSubscribeToRunPrompt + ) + })) + } +}) + vi.mock('pinia') vi.mock('firebase/app', () => ({ @@ -62,12 +73,26 @@ function renderComponent() { } describe('TopbarSubscribeButton', () => { + beforeEach(() => { + mockBilling.isFreeTier = true + mockBilling.showsSubscribeToRunPrompt = false + }) + it('renders on cloud when isFreeTier is true', () => { mockIsCloud.value = true renderComponent() expect(screen.getByTestId('topbar-subscribe-button')).toBeInTheDocument() }) + it('yields when the Run slot is already prompting to subscribe', () => { + mockIsCloud.value = true + mockBilling.showsSubscribeToRunPrompt = true + renderComponent() + expect( + screen.queryByTestId('topbar-subscribe-button') + ).not.toBeInTheDocument() + }) + it('hides on non-cloud distribution', () => { mockIsCloud.value = false renderComponent() diff --git a/src/components/topbar/TopbarSubscribeButton.vue b/src/components/topbar/TopbarSubscribeButton.vue index 634d01fb4ab..f3736fc031c 100644 --- a/src/components/topbar/TopbarSubscribeButton.vue +++ b/src/components/topbar/TopbarSubscribeButton.vue @@ -1,6 +1,6 @@