LCOV - code coverage report
Current view: top level - src/platform/billing/subscription/components - FreeTierQuota.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 75.0 % 12 9
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <script setup lang="ts">
       2              : import { computed } from 'vue'
       3              : import { useI18n } from 'vue-i18n'
       4              : 
       5              : import { cn } from '@comfyorg/tailwind-utils'
       6              : import { useBillingContext } from '@/platform/billing/composables/useBillingContext'
       7              : import { useSubscriptionPaywall } from '@/platform/billing/composables/useSubscriptionPaywall'
       8              : import { useFreeTierQuota } from '@/platform/billing/subscription/composables/useFreeTierQuota'
       9              : 
      10         2355 : const DOT_COLORS = ['bg-destructive', 'bg-warning', 'bg-success']
      11              : 
      12         2083 : const { isFreeTier } = useBillingContext()
      13         2083 : const { showSubscriptionDialog } = useSubscriptionPaywall()
      14         2083 : const { t } = useI18n()
      15         2083 : const { available, hasInvalidNodes, maxAvailable, quotaEnabled } =
      16              :   useFreeTierQuota()
      17              : 
      18         2083 : const dotColor = computed(() => {
      19            0 :   const ratio = maxAvailable.value ? available.value / maxAvailable.value : 0
      20            0 :   return DOT_COLORS[
      21              :     Math.min(Math.floor(ratio * DOT_COLORS.length), DOT_COLORS.length - 1)
      22              :   ]
      23              : })
      24         2083 : const label = computed(() =>
      25              :   t('actionbar.freeTierRuns', {
      26              :     available: available.value,
      27              :     MAX_AVAILABLE: maxAvailable.value
      28              :   })
      29              : )
      30         2083 : </script>
      31              : <template>
      32              :   <div
      33         2083 :     v-if="quotaEnabled && isFreeTier"
      34              :     class="mt-2 w-full cursor-pointer border-t border-border/50 bg-background px-4 pt-2 select-none"
      35              :     data-testid="free-tier-quota"
      36              :     @click="showSubscriptionDialog({ reason: 'free_tier_quota' })"
      37              :   >
      38              :     <div
      39              :       v-if="hasInvalidNodes"
      40              :       class="flex w-full items-center justify-center gap-2"
      41              :     >
      42              :       <i class="icon-[lucide--coins] bg-credit" />
      43              :       {{ t('actionbar.freeTierPartner') }}
      44              :     </div>
      45              :     <div v-else class="flex w-full items-center justify-between">
      46              :       <div class="flex gap-2" :aria-label="label" role="img">
      47            0 :         <div
      48              :           v-for="index in maxAvailable"
      49              :           :key="index"
      50              :           :class="
      51              :             cn(
      52              :               'size-1.5 rounded-full',
      53              :               index > available ? 'bg-muted' : dotColor
      54              :             )
      55              :           "
      56              :         />
      57              :       </div>
      58              :       <div v-text="label" />
      59              :     </div>
      60              :   </div>
      61              : </template>
        

Generated by: LCOV version 2.0-1