LCOV - code coverage report
Current view: top level - packages/account-ui/src/billing/tab - BillingCreditsCard.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 5 5
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1            5 : <template>
       2              :   <DefineAddCredits>
       3              :     <slot
       4              :       name="addCreditsAction"
       5              :       :availability="addCredits"
       6              :       :label="copy.addCredits"
       7              :       :reason="addCreditsReason"
       8              :       :variant="addCreditsVariant"
       9              :     >
      10              :       <AddCreditsAction
      11              :         :availability="addCredits"
      12              :         :reason="addCreditsReason"
      13              :         :variant="addCreditsVariant"
      14              :         size="md"
      15              :         :class="
      16              :           cn(
      17              :             'flex max-w-56 shrink-0 flex-col items-end gap-1',
      18              :             classes?.addCredits
      19              :           )
      20              :         "
      21              :         reason-class="text-right text-xs"
      22              :         @click="emit('addCredits')"
      23              :       >
      24              :         {{ copy.addCredits }}
      25              :       </AddCreditsAction>
      26              :     </slot>
      27              :   </DefineAddCredits>
      28              :   <TooltipProvider>
      29              :     <section
      30              :       :class="cn('flex flex-col gap-3', classes?.root)"
      31              :       data-testid="billing-credits-card"
      32              :     >
      33              :       <h3
      34              :         :class="
      35              :           cn(
      36              :             'm-0 flex items-center gap-1.5 text-base font-medium text-foreground',
      37              :             classes?.title
      38              :           )
      39              :         "
      40              :       >
      41              :         {{ copy.title }}
      42              :         <BillingInfoTip :text="copy.rateTooltip" :label="copy.rateInfo" />
      43              :       </h3>
      44              : 
      45              :       <div
      46              :         :class="
      47              :           cn('flex flex-col rounded-xl border border-border', classes?.surface)
      48              :         "
      49              :         data-testid="billing-credits-surface"
      50              :       >
      51              :         <div
      52              :           :class="
      53              :             cn(
      54              :               'flex items-start justify-between gap-4 px-5 py-4',
      55              :               classes?.balance
      56              :             )
      57              :           "
      58              :         >
      59              :           <BillingCreditsBalance
      60              :             :state
      61              :             :plan-credit-note="planCreditNote"
      62              :             :copy
      63              :             :locale
      64              :             :classes="{ available: classes?.available, note: classes?.note }"
      65              :             @retry="emit('retry')"
      66              :           >
      67              :             <template v-if="$slots.retry" #retry="{ label }">
      68              :               <slot name="retry" :label />
      69              :             </template>
      70              :           </BillingCreditsBalance>
      71              :           <ReuseAddCredits v-if="state.kind === 'noPlan' && showAddCredits" />
      72              :         </div>
      73              : 
      74              :         <div v-if="state.kind === 'plan'" class="flex border-t border-border">
      75              :           <BillingCreditsPlanCell
      76              :             :plan="state"
      77              :             :copy
      78              :             :locale
      79              :             :classes="{ root: classes?.planCell, meter: classes?.planMeter }"
      80              :           />
      81              :           <BillingCreditsTopUpCell
      82              :             :top-up-cents="state.topUpCents"
      83              :             :top-up-in-use="state.topUpInUse"
      84              :             :copy
      85              :             :locale
      86              :             :root-class="classes?.topUpCell"
      87              :           >
      88              :             <ReuseAddCredits v-if="showAddCredits" />
      89              :           </BillingCreditsTopUpCell>
      90              :         </div>
      91              :       </div>
      92              :     </section>
      93              :   </TooltipProvider>
      94              : </template>
      95              : 
      96              : <script setup lang="ts">
      97              : import { createReusableTemplate } from '@vueuse/core'
      98              : import { computed } from 'vue'
      99              : 
     100              : import type {
     101              :   AddCreditsAvailability,
     102              :   CreditsCardState
     103              : } from '@comfyorg/account-core/billing'
     104              : import TooltipProvider from '@comfyorg/design-system/tooltip/TooltipProvider'
     105              : import { cn } from '@comfyorg/tailwind-utils'
     106              : 
     107              : import BillingInfoTip from './BillingInfoTip.vue'
     108              : import AddCreditsAction from './AddCreditsAction.vue'
     109              : import BillingCreditsBalance from './BillingCreditsBalance.vue'
     110              : import BillingCreditsPlanCell from './BillingCreditsPlanCell.vue'
     111              : import BillingCreditsTopUpCell from './BillingCreditsTopUpCell.vue'
     112              : import type { CreditsCardCopy } from './creditsCardCopy'
     113              : 
     114              : type CreditsCardPart =
     115              :   | 'root'
     116              :   | 'title'
     117              :   | 'surface'
     118              :   | 'balance'
     119              :   | 'available'
     120              :   | 'note'
     121              :   | 'addCredits'
     122              :   | 'planCell'
     123              :   | 'planMeter'
     124              :   | 'topUpCell'
     125              : 
     126              : const {
     127              :   state,
     128              :   addCredits,
     129              :   planCreditNote,
     130              :   copy,
     131              :   locale,
     132              :   addCreditsVariant = 'secondary',
     133              :   classes
     134              : } = defineProps<{
     135              :   state: CreditsCardState
     136              :   addCredits: AddCreditsAvailability
     137              :   planCreditNote: string | null
     138              :   copy: CreditsCardCopy
     139              :   locale: string
     140              :   addCreditsVariant?: 'secondary' | 'inverted'
     141              :   classes?: Partial<Record<CreditsCardPart, string>>
     142              : }>()
     143              : 
     144            5 : const emit = defineEmits<{ retry: []; addCredits: [] }>()
     145              : 
     146            5 : const [DefineAddCredits, ReuseAddCredits] = createReusableTemplate()
     147              : 
     148            5 : const showAddCredits = computed(() => addCredits.kind !== 'hidden')
     149              : 
     150            5 : const addCreditsReason = computed(() =>
     151              :   addCredits.kind === 'disabled'
     152              :     ? copy.addCreditsReason(addCredits.reasonKey)
     153              :     : null
     154              : )
     155              : </script>
        

Generated by: LCOV version 2.0-1