LCOV - code coverage report
Current view: top level - src/platform/billing/composables - useScheduledPlanChange.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 57.9 % 19 11
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { computed } from 'vue'
       2              : import { useI18n } from 'vue-i18n'
       3              : 
       4              : import { useBillingContext } from '@/platform/billing/composables/useBillingContext'
       5              : import {
       6              :   isEnterprisePlanSlug,
       7              :   isUnknownTier
       8              : } from '@/platform/billing/subscription/constants/tierPricing'
       9              : import {
      10              :   formatSubscriptionDate,
      11              :   resolveSubscriptionTierKey
      12              : } from '@/platform/billing/components/subscriptionPanelWorkspace.logic'
      13              : 
      14           16 : export function useScheduledPlanChange() {
      15           16 :   const { t, locale } = useI18n()
      16           16 :   const { subscription, plans } = useBillingContext()
      17              : 
      18           16 :   const scheduledChange = computed(
      19              :     () => subscription.value?.scheduledChange ?? null
      20              :   )
      21              : 
      22           16 :   const formattedDate = computed(() =>
      23              :     formatSubscriptionDate(scheduledChange.value?.effective_at, locale.value)
      24              :   )
      25              : 
      26           16 :   const planName = computed(() => {
      27           10 :     const slug = scheduledChange.value?.plan_slug
      28           10 :     if (isEnterprisePlanSlug(slug)) {
      29            0 :       return t('subscription.tiers.enterprise.name')
      30              :     }
      31              : 
      32           10 :     const plan = plans.value.find(({ slug: planSlug }) => planSlug === slug)
      33           10 :     if (!plan) return ''
      34            0 :     if (plan.tier === 'ENTERPRISE') {
      35            0 :       return t('subscription.tiers.enterprise.name')
      36              :     }
      37            0 :     if (plan.slug.startsWith('team')) {
      38            0 :       return t('subscription.teamPlanName')
      39              :     }
      40            0 :     if (isUnknownTier(plan.tier)) {
      41            0 :       return t('subscription.unknownTierName')
      42              :     }
      43            0 :     return t(`subscription.tiers.${resolveSubscriptionTierKey(plan.tier)}.name`)
      44              :   })
      45              : 
      46              :   const isDisplayable = computed(
      47              :     () => Boolean(planName.value) && Boolean(formattedDate.value)
      48              :   )
      49              : 
      50           16 :   return { scheduledChange, planName, formattedDate, isDisplayable }
      51              : }
        

Generated by: LCOV version 2.0-1