diff --git a/src/locales/en/main.json b/src/locales/en/main.json index 3548414fb75..f278294f8bf 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -2661,11 +2661,18 @@ "settingsPlans": { "title": "Plans", "subtitle": "Plans run on Comfy Cloud and their credits work on this install too.", + "personal": "Personal", + "teams": "Teams", "billedYearlyToggle": "Billed yearly", "creditsAYear": "{credits} credits a year", "creditsAMonth": "{credits} credits a month", "perDollar": "{credits} per dollar", - "choosePlan": "Choose {tier}" + "choosePlan": "Choose {tier}", + "noPlansAvailable": "No plans are available right now. Check back soon.", + "creditsPerMonth": "{credits} credits per month", + "comingSharedWorkflows": "Shared workflows & assets", + "comingProjects": "Projects", + "enterpriseCopy": "Need more members? Looking for more flexibility or custom features?" }, "credits": { "activity": "Activity", @@ -2882,6 +2889,7 @@ "whatsIncluded": "What's included:", "planLoadError": "We couldn't load your plan details.", "planLoadErrorRetry": "Try again", + "planLoadErrorStale": "We couldn't refresh your plan details. These prices may be out of date.", "teamPlanName": "Team", "teamPlanIncludes": "Your plan includes everything in {plan}, plus:", "inactiveTeamTitle": "Inactive team subscription", diff --git a/src/platform/cloud/subscription/constants/tierPricing.ts b/src/platform/cloud/subscription/constants/tierPricing.ts index dd9fbcf3221..35aeb3af46d 100644 --- a/src/platform/cloud/subscription/constants/tierPricing.ts +++ b/src/platform/cloud/subscription/constants/tierPricing.ts @@ -41,6 +41,14 @@ export const TIER_PRICING: Record< pro: { monthly: 100, yearly: 80, credits: 21100, videoEstimate: 1915 } } +/** + * Videos-per-credit ratio, constant across tiers. Presentation-only: the + * "~N 5s videos" estimate is derived from an API credit grant times this ratio, + * so it tracks what is sold rather than pinning a per-tier video count. + */ +export const VIDEO_PER_CREDIT = + TIER_PRICING.pro.videoEstimate / TIER_PRICING.pro.credits + interface TierFeatures { customLoRAs: boolean maxMembers: number diff --git a/src/platform/workspace/components/UnifiedPricingTable.vue b/src/platform/workspace/components/UnifiedPricingTable.vue index cf51357d4e4..9c25d83608a 100644 --- a/src/platform/workspace/components/UnifiedPricingTable.vue +++ b/src/platform/workspace/components/UnifiedPricingTable.vue @@ -417,6 +417,7 @@ import CreditSlider from '@/components/ui/credit-slider/CreditSlider.vue' import { useBillingContext } from '@/composables/billing/useBillingContext' import { TIER_PRICING, + VIDEO_PER_CREDIT, hasActivePaidPlan, toTierKey } from '@/platform/cloud/subscription/constants/tierPricing' @@ -503,11 +504,6 @@ const QUESTIONS_URL = 'https://portal.usepylon.com/comfy-org/forms/question' const ENTERPRISE_URL = 'https://www.comfy.org/enterprise' const PRICING_URL = 'https://www.comfy.org/pricing' -/** Videos-per-credit ratio is constant across tiers; reuse it for the team - * plan's template-based estimate until the BE carries a team figure. */ -const VIDEO_PER_CREDIT = - TIER_PRICING.pro.videoEstimate / TIER_PRICING.pro.credits - interface BillingCycleOption { label: string value: BillingCycle diff --git a/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.routing.test.ts b/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.routing.test.ts new file mode 100644 index 00000000000..250961b76ba --- /dev/null +++ b/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.routing.test.ts @@ -0,0 +1,302 @@ +import userEvent from '@testing-library/user-event' +import { beforeEach, describe, expect, it, vi } from 'vitest' +import { createI18n } from 'vue-i18n' + +import { ref } from 'vue' + +import { render, screen, waitFor } from '@testing-library/vue' + +import enMessages from '@/locales/en/main.json' +import { useBillingPlans } from '@/platform/cloud/subscription/composables/useBillingPlans' +import type { + BillingPlansResponse, + Plan +} from '@/platform/workspace/api/workspaceApi' + +import PlanCreditsPanelContent from './PlanCreditsPanelContent.vue' + +// The panel's real defect was a routing one: it fetched through +// useBillingContext (which lands on the legacy no-op before the workspace +// hydrates) while reading state from the useBillingPlans singleton that only +// the workspace adapter writes. These tests therefore run the REAL +// useBillingContext / useBillingRouting / useBillingPlans and mock only what +// this repo owns at its edges: the HTTP client and the workspace store's state. + +type InitState = 'uninitialized' | 'loading' | 'ready' | 'error' + +const workspace = vi.hoisted(() => ({ + initialize: vi.fn(async () => {}) +})) + +// Reactive so a bootstrap that resolves mid-test re-drives the panel exactly as +// the real store would. +const state = { + initState: ref('ready'), + error: ref(null), + active: ref<{ id: string; type: string } | null>({ + id: 'ws-1', + type: 'personal' + }) +} + +const api = vi.hoisted(() => ({ + getBillingPlans: vi.fn(), + getBillingStatus: vi.fn(async () => ({ + is_active: false, + has_funds: true, + team_credit_stop: null + })), + getBillingBalance: vi.fn(async () => ({ amount_micros: 0 })) +})) + +vi.mock('@/platform/distribution/types', () => ({ isCloud: false })) + +// Siblings of the plans section; irrelevant here and each drags in the app graph. +vi.mock('@/components/dialog/content/setting/CreditsPanel.vue', () => ({ + default: { template: '
' } +})) +vi.mock('@/components/dialog/content/setting/UsageLogsTable.vue', () => ({ + default: { template: '
', methods: { refresh: () => {} } } +})) +vi.mock( + '@/platform/cloud/subscription/components/SubscriptionFooterLinks.vue', + () => ({ default: { template: '