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

            Line data    Source code
       1              : <template>
       2              :   <div :class="cn('flex min-h-0 flex-col gap-4 overflow-y-auto p-4', ui.body)">
       3              :     <slot name="description" />
       4              :     <RadioGroupRoot
       5              :       :model-value="selectedPreset"
       6              :       :disabled="view.locked"
       7              :       orientation="horizontal"
       8              :       :class="cn('grid grid-cols-4 gap-2', ui.presets)"
       9              :       :aria-label="translate('title')"
      10              :       @update:model-value="pickPreset"
      11              :     >
      12           76 :       <RadioGroupItem
      13              :         v-for="cents in ADD_CREDITS_PRESETS_CENTS"
      14              :         :key="cents"
      15              :         :value="String(cents)"
      16              :         :class="
      17              :           cn(
      18              :             buttonVariants({ variant: 'secondary', size: 'lg' }),
      19              :             'border border-solid border-transparent text-base data-[state=checked]:border-foreground',
      20              :             ui.preset
      21              :           )
      22              :         "
      23              :       >
      24              :         {{ format.dollars(cents) }}
      25              :       </RadioGroupItem>
      26              :     </RadioGroupRoot>
      27              : 
      28              :     <p
      29              :       v-if="negativeBalanceCredits !== undefined"
      30              :       :class="cn('m-0 text-muted-foreground', ui.line)"
      31              :       data-testid="add-credits-negative-balance"
      32              :     >
      33              :       {{
      34              :         translate('negativeBalance', {
      35              :           credits: format.count(negativeBalanceCredits)
      36              :         })
      37              :       }}
      38              :     </p>
      39              :     <p
      40              :       v-if="planLine"
      41              :       :class="cn('m-0 text-muted-foreground', ui.line)"
      42              :       data-testid="add-credits-plan-line"
      43              :     >
      44              :       {{ translate(`planLine.${planLine}`) }}
      45              :     </p>
      46              : 
      47              :     <AddCreditsAmountField
      48              :       :input="customInput"
      49              :       :error="amountError"
      50              :       :locked="view.locked"
      51              :       :label="translate('customAmountLabel')"
      52              :       prefix="$"
      53              :       reserve-note
      54              :       input-test-id="add-credits-amount-input"
      55              :       note-test-id="add-credits-amount-error"
      56              :       :ui
      57              :       @type="emit('type', $event)"
      58              :     />
      59              : 
      60              :     <slot name="autoTopUp" />
      61              : 
      62              :     <slot
      63              :       name="notice"
      64              :       :notice="view.notice"
      65              :       :title="noticeCopy?.title"
      66              :       :body="noticeCopy?.body"
      67              :     >
      68              :       <AddCreditsNotice
      69              :         v-if="noticeCopy"
      70              :         :copy="noticeCopy"
      71              :         :kind="noticeKindOf(view.notice)"
      72              :         :support-url
      73              :         :support-label="translate('messageSupport')"
      74              :         :notice-class="ui.notice"
      75              :       />
      76              :     </slot>
      77              :     <slot v-if="!view.notice" name="extra" />
      78              :   </div>
      79              : 
      80              :   <AddCreditsAmountFooter
      81              :     :view
      82              :     :footer
      83              :     :support-url
      84              :     :translate
      85              :     :ui
      86              :     @continue="emit('continue')"
      87              :   />
      88              : </template>
      89              : 
      90              : <script setup lang="ts">
      91              : import { computed } from 'vue'
      92              : import { RadioGroupItem, RadioGroupRoot } from 'reka-ui'
      93              : 
      94              : import type {
      95              :   AddCreditsAmountView,
      96              :   AddCreditsBounds,
      97              :   AddCreditsPlanLine,
      98              :   AddCreditsTranslate
      99              : } from '@comfyorg/account-core/billing'
     100              : import { ADD_CREDITS_PRESETS_CENTS } from '@comfyorg/account-core/billing'
     101              : import { buttonVariants } from '@comfyorg/design-system/button.variants'
     102              : import { cn } from '@comfyorg/tailwind-utils'
     103              : 
     104              : import AddCreditsAmountField from './AddCreditsAmountField.vue'
     105              : import AddCreditsAmountFooter from './AddCreditsAmountFooter.vue'
     106              : import AddCreditsNotice from './AddCreditsNotice.vue'
     107              : import type { AddCreditsFormat, AddCreditsUi } from './addCreditsPresentation'
     108              : import {
     109              :   amountErrorFor,
     110              :   footerCopyFor,
     111              :   noticeCopyFor,
     112              :   noticeKindOf
     113              : } from './addCreditsPresentation'
     114              : import type { AddCreditsQuote } from './useAddCreditsDialog'
     115              : 
     116              : const {
     117              :   view,
     118              :   quote,
     119              :   bounds,
     120              :   negativeBalanceCredits,
     121              :   planLine,
     122              :   supportUrl,
     123              :   translate,
     124              :   format,
     125              :   ui
     126              : } = defineProps<{
     127              :   view: AddCreditsAmountView
     128              :   quote: AddCreditsQuote | undefined
     129              :   bounds: AddCreditsBounds
     130              :   negativeBalanceCredits?: number
     131              :   planLine?: AddCreditsPlanLine
     132              :   supportUrl: string
     133              :   translate: AddCreditsTranslate
     134              :   format: AddCreditsFormat
     135              :   ui: AddCreditsUi
     136              : }>()
     137              : 
     138            4 : const emit = defineEmits<{
     139              :   preset: [cents: number]
     140              :   type: [input: string]
     141              :   continue: []
     142              : }>()
     143              : 
     144            4 : const context = computed(() => ({ translate, format }))
     145            4 : const selectedPreset = computed(() =>
     146              :   view.amount.kind === 'preset' ? String(view.amount.cents) : undefined
     147              : )
     148            4 : const customInput = computed(() =>
     149              :   view.amount.kind === 'custom' ? view.amount.input : ''
     150              : )
     151            4 : const amountError = computed(() => amountErrorFor(view, bounds, context.value))
     152            4 : const noticeCopy = computed(() => noticeCopyFor(view.notice, context.value))
     153            4 : const footer = computed(() => footerCopyFor(view, quote, context.value))
     154              : 
     155            1 : function pickPreset(value: unknown) {
     156            1 :   if (typeof value === 'string') emit('preset', Number(value))
     157              : }
     158              : </script>
        

Generated by: LCOV version 2.0-1