From 570933aee9748e4e8f65bb2aed10541dbe59e8a6 Mon Sep 17 00:00:00 2001 From: Wei Hai Date: Mon, 3 Aug 2026 09:50:42 -0700 Subject: [PATCH 1/2] fix(workspace): let ended subscriptions resubscribe to the same plan An ended subscription keeps reporting its plan slug and tier, and the pricing table only treated a cancel-scheduled plan as re-buyable, so the plan the user just lost rendered as a disabled "Current Plan" and the other tiers read "Change to" instead of "Subscribe to". Treat subscription_status 'ended' as holding no current plan, for both the personal tier cards and the team credit stop. --- .../components/UnifiedPricingTable.test.ts | 42 +++++++++++++++++++ .../components/UnifiedPricingTable.vue | 14 ++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/platform/workspace/components/UnifiedPricingTable.test.ts b/src/platform/workspace/components/UnifiedPricingTable.test.ts index 1513dabe832..f7427d1c0cd 100644 --- a/src/platform/workspace/components/UnifiedPricingTable.test.ts +++ b/src/platform/workspace/components/UnifiedPricingTable.test.ts @@ -21,6 +21,7 @@ interface MockTeamStop { } const mockSubscription = ref(null) +const mockSubscriptionStatus = ref(null) const mockCurrentPlanSlug = ref(null) const mockCurrentTeamCreditStop = ref(null) const mockTeamFlag = ref(false) @@ -35,6 +36,7 @@ vi.mock('@/composables/billing/useBillingContext', () => ({ fetchPlans: vi.fn(), isTeamPlan: computed(() => mockIsTeamPlan.value), subscription: computed(() => mockSubscription.value), + subscriptionStatus: computed(() => mockSubscriptionStatus.value), currentTeamCreditStop: computed(() => mockCurrentTeamCreditStop.value) }) })) @@ -83,6 +85,7 @@ function renderComponent(props: Record = {}) { describe('UnifiedPricingTable plan CTA labels', () => { beforeEach(() => { mockSubscription.value = null + mockSubscriptionStatus.value = null mockCurrentPlanSlug.value = null mockCurrentTeamCreditStop.value = null mockTeamFlag.value = false @@ -121,6 +124,24 @@ describe('UnifiedPricingTable plan CTA labels', () => { ).toBeTruthy() }) + it('offers a fresh subscribe on the plan an ended subscription used to hold', () => { + // An ended subscription still reports its tier and plan slug. + mockSubscription.value = { + tier: 'CREATOR', + duration: 'ANNUAL', + isCancelled: false + } + mockSubscriptionStatus.value = 'ended' + + renderComponent() + + expect( + screen.getByRole('button', { name: 'Subscribe to Creator Yearly' }) + ).toBeEnabled() + expect(screen.queryByRole('button', { name: 'Current Plan' })).toBeNull() + expect(screen.queryByRole('button', { name: /^Change to/ })).toBeNull() + }) + it('keeps personal tier cards actionable for the original owner of a team plan', () => { mockSubscription.value = { tier: 'TEAM', duration: 'ANNUAL' } mockCurrentTeamCreditStop.value = { @@ -166,6 +187,7 @@ describe('UnifiedPricingTable team plan CTA', () => { beforeEach(() => { mockSubscription.value = null + mockSubscriptionStatus.value = null mockCurrentPlanSlug.value = null mockCurrentTeamCreditStop.value = null mockTeamFlag.value = true @@ -266,6 +288,26 @@ describe('UnifiedPricingTable team plan CTA', () => { expect(emitted().resubscribe).toBeFalsy() }) + it('prompts a fresh subscribe for an ended team subscription', async () => { + const user = userEvent.setup() + mockSubscription.value = { + tier: 'TEAM', + duration: 'ANNUAL', + isCancelled: false + } + mockSubscriptionStatus.value = 'ended' + mockCurrentTeamCreditStop.value = TEAM_STOP + + const { emitted } = renderComponent({ initialPlanMode: 'team' }) + + const cta = screen.getByRole('button', { name: 'Subscribe to Team Yearly' }) + expect(cta).toBeEnabled() + await user.click(cta) + const [teamPayload] = emitted().subscribeTeam![0] as [{ isChange: boolean }] + expect(teamPayload).toMatchObject({ isChange: false }) + expect(emitted().resubscribe).toBeFalsy() + }) + it('prompts a fresh subscribe when on no team plan', () => { renderComponent({ initialPlanMode: 'team' }) diff --git a/src/platform/workspace/components/UnifiedPricingTable.vue b/src/platform/workspace/components/UnifiedPricingTable.vue index 408cb5b4205..2855414c764 100644 --- a/src/platform/workspace/components/UnifiedPricingTable.vue +++ b/src/platform/workspace/components/UnifiedPricingTable.vue @@ -615,6 +615,7 @@ const { fetchPlans, isTeamPlan, subscription, + subscriptionStatus, currentTeamCreditStop } = useBillingContext() @@ -640,6 +641,10 @@ const { teamCreditStops } = useBillingPlans() const isCancelled = computed(() => subscription.value?.isCancelled ?? false) +// An ended subscription still reports its plan slug and tier, so the plan it +// held must not read as current — it is buyable again. +const isEnded = computed(() => subscriptionStatus.value === 'ended') + const currentBillingCycle = ref('yearly') // Team credit stops: backend-sourced when the API supplies them, otherwise the @@ -676,7 +681,9 @@ const teamVideoEstimate = computed(() => // The team's currently-subscribed stop (null when on no team plan). Matched to // the slider stops by list price so the current stop can be disabled. -const isTeamSubscribed = computed(() => currentTeamCreditStop.value !== null) +const isTeamSubscribed = computed( + () => currentTeamCreditStop.value !== null && !isEnded.value +) // `teamUsd` is seeded at mount from the fallback default; when the API stops // resolve afterwards with different breakpoints that seed can match no stop, @@ -780,7 +787,9 @@ function getPriceFromApi(tier: PricingTierConfig): number | null { } const currentTierKey = computed(() => - subscription.value?.tier ? TIER_TO_KEY[subscription.value.tier] : null + subscription.value?.tier && !isEnded.value + ? TIER_TO_KEY[subscription.value.tier] + : null ) const isYearlySubscription = computed( @@ -788,6 +797,7 @@ const isYearlySubscription = computed( ) const isCurrentPlan = (tierKey: CheckoutTierKey): boolean => { + if (isEnded.value) return false if (currentPlanSlug.value) { const plan = getApiPlanForTier(tierKey, currentBillingCycle.value) return plan?.slug === currentPlanSlug.value From 39eef703e454e31270f379fcb9d743125961cc6f Mon Sep 17 00:00:00 2001 From: Wei Hai Date: Mon, 3 Aug 2026 10:02:07 -0700 Subject: [PATCH 2/2] fix(workspace): guard team resubscribe on an active subscription Address review: type the mocked subscription status with the production lifecycle union, assert the emitted subscribe payload rather than only the CTA label, and require isTeamSubscribed before emitting resubscribe now that the credit stop can outlive the subscription. --- .../components/UnifiedPricingTable.test.ts | 25 ++++++++++++++----- .../components/UnifiedPricingTable.vue | 9 +++++-- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/platform/workspace/components/UnifiedPricingTable.test.ts b/src/platform/workspace/components/UnifiedPricingTable.test.ts index f7427d1c0cd..345dc1d1aaa 100644 --- a/src/platform/workspace/components/UnifiedPricingTable.test.ts +++ b/src/platform/workspace/components/UnifiedPricingTable.test.ts @@ -6,6 +6,7 @@ import { createI18n } from 'vue-i18n' import Button from '@/components/ui/button/Button.vue' import enMessages from '@/locales/en/main.json' +import type { BillingSubscriptionStatus } from '@/platform/workspace/api/workspaceApi' import UnifiedPricingTable from '@/platform/workspace/components/UnifiedPricingTable.vue' interface MockSubscription { @@ -21,7 +22,7 @@ interface MockTeamStop { } const mockSubscription = ref(null) -const mockSubscriptionStatus = ref(null) +const mockSubscriptionStatus = ref(null) const mockCurrentPlanSlug = ref(null) const mockCurrentTeamCreditStop = ref(null) const mockTeamFlag = ref(false) @@ -124,7 +125,8 @@ describe('UnifiedPricingTable plan CTA labels', () => { ).toBeTruthy() }) - it('offers a fresh subscribe on the plan an ended subscription used to hold', () => { + it('offers a fresh subscribe on the plan an ended subscription used to hold', async () => { + const user = userEvent.setup() // An ended subscription still reports its tier and plan slug. mockSubscription.value = { tier: 'CREATOR', @@ -133,13 +135,24 @@ describe('UnifiedPricingTable plan CTA labels', () => { } mockSubscriptionStatus.value = 'ended' - renderComponent() + const { emitted } = renderComponent() - expect( - screen.getByRole('button', { name: 'Subscribe to Creator Yearly' }) - ).toBeEnabled() expect(screen.queryByRole('button', { name: 'Current Plan' })).toBeNull() expect(screen.queryByRole('button', { name: /^Change to/ })).toBeNull() + + const cta = screen.getByRole('button', { + name: 'Subscribe to Creator Yearly' + }) + expect(cta).toBeEnabled() + await user.click(cta) + const [payload] = emitted().subscribe![0] as [ + { tierKey: string; billingCycle: string } + ] + expect(payload).toMatchObject({ + tierKey: 'creator', + billingCycle: 'yearly' + }) + expect(emitted().resubscribe).toBeFalsy() }) it('keeps personal tier cards actionable for the original owner of a team plan', () => { diff --git a/src/platform/workspace/components/UnifiedPricingTable.vue b/src/platform/workspace/components/UnifiedPricingTable.vue index 2855414c764..79f53a15bae 100644 --- a/src/platform/workspace/components/UnifiedPricingTable.vue +++ b/src/platform/workspace/components/UnifiedPricingTable.vue @@ -891,8 +891,13 @@ function handleSubscribe(tierKey: CheckoutTierKey) { function handleSubscribeTeam() { if (isTeamButtonDisabled.value) return // Re-subscribe only when keeping the exact current plan; any other stop or - // cycle is a change. - if (isCancelled.value && isTeamCurrentPlanSelected.value) { + // cycle is a change. An ended subscription still reports its credit stop, so + // the stop alone is no proof there is a subscription left to resume. + if ( + isTeamSubscribed.value && + isCancelled.value && + isTeamCurrentPlanSelected.value + ) { emit('resubscribe') return }