LCOV - code coverage report
Current view: top level - src/platform/billing - topUpPlanCreditLine.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 22.2 % 9 2
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import type { SubscriptionState } from '@comfyorg/ingest-types'
       2              : 
       3              : export type TopUpPlanCreditLine =
       4              :   | 'planRequiredFreeRuns'
       5              :   | 'planRequiredSubscribe'
       6              :   | 'planRequiredResubscribe'
       7              : 
       8              : /** Add credits line on Cloud for a served `subscription_state` that has no plan. */
       9           15 : export function topUpPlanCreditLine(facts: {
      10              :   isCloud: boolean
      11              :   isBillingInitialized: boolean
      12              :   canTopUp: boolean
      13              :   subscriptionState: SubscriptionState | null
      14              :   freeRunsRemaining: number
      15              : }): TopUpPlanCreditLine | null {
      16           15 :   if (!facts.isCloud) return null
      17            0 :   if (!facts.isBillingInitialized) return null
      18            0 :   if (!facts.canTopUp) return null
      19            0 :   if (facts.subscriptionState === 'never_subscribed') {
      20            0 :     if (facts.freeRunsRemaining > 0) return 'planRequiredFreeRuns'
      21            0 :     return 'planRequiredSubscribe'
      22              :   }
      23            0 :   if (facts.subscriptionState === 'ended') return 'planRequiredResubscribe'
      24            0 :   return null
      25              : }
        

Generated by: LCOV version 2.0-1