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

            Line data    Source code
       1              : import type { SubscriptionDialogOptions } from '@/platform/billing/composables/types'
       2              : import { useBillingContext } from '@/platform/billing/composables/useBillingContext'
       3              : import { useBillingDialogsAccess } from '@/platform/billing/subscription/composables/billingDialogsAccess'
       4              : import { useSubscriptionDialogAccess } from '@/platform/billing/subscription/composables/subscriptionDialogAccess'
       5              : 
       6              : /**
       7              :  * Opens the paywall for the active billing rail: workspace billing shows the
       8              :  * pricing dialog directly, legacy billing goes through the
       9              :  * `subscription_required` gate of `showSubscriptionRequiredDialog`. While the
      10              :  * workspace type is still loading it waits for it, and drops the click if
      11              :  * the type never loads or the workspace changes meanwhile.
      12              :  */
      13         4438 : export function useSubscriptionPaywall() {
      14         4438 :   const { type, whenRoutingKnown } = useBillingContext()
      15         4438 :   const { showSubscriptionRequiredDialog } = useBillingDialogsAccess()
      16         4438 :   const subscriptionDialog = useSubscriptionDialogAccess()
      17              : 
      18            0 :   function showForRail(options?: SubscriptionDialogOptions): void {
      19            0 :     if (type.value === 'workspace') void subscriptionDialog.show(options)
      20            0 :     else void showSubscriptionRequiredDialog(options)
      21              :   }
      22              : 
      23            0 :   function showSubscriptionDialog(options?: SubscriptionDialogOptions): void {
      24            0 :     if (type.value !== 'unknown') return showForRail(options)
      25            0 :     void whenRoutingKnown().then((known) => {
      26            0 :       if (known) showForRail(options)
      27              :     })
      28              :   }
      29              : 
      30         4438 :   return { showSubscriptionDialog }
      31              : }
        

Generated by: LCOV version 2.0-1