LCOV - code coverage report
Current view: top level - src/platform/openOnCloud/stores - cloudWorkflowCheckStore.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 56.5 % 23 13
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { useEventListener } from '@vueuse/core'
       2              : import { defineStore } from 'pinia'
       3              : import { shallowRef, watch } from 'vue'
       4              : 
       5              : import { api } from '@/scripts/api'
       6              : import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
       7              : import { useCurrentUser } from '@/composables/auth/useCurrentUser'
       8              : import { checkCloudCompatibility } from '@/platform/openOnCloud/cloudCompatibilityApi'
       9              : import type {
      10              :   CloudWorkflowCheckEvent,
      11              :   CloudWorkflowCheckState
      12              : } from '@/platform/openOnCloud/cloudWorkflowCheck'
      13              : import { reduceCloudWorkflowCheck } from '@/platform/openOnCloud/cloudWorkflowCheck'
      14              : 
      15         2355 : export const useCloudWorkflowCheckStore = defineStore(
      16              :   'cloudWorkflowCheck',
      17              :   () => {
      18            1 :     const { isLoggedIn } = useCurrentUser()
      19            1 :     const state = shallowRef<CloudWorkflowCheckState>({ phase: 'idle' })
      20            1 :     let lastRun = 0
      21              : 
      22            1 :     function dispatch(event: CloudWorkflowCheckEvent) {
      23            1 :       state.value = reduceCloudWorkflowCheck(state.value, event)
      24              :     }
      25              : 
      26            0 :     async function check(): Promise<void> {
      27            0 :       const run = ++lastRun
      28            0 :       dispatch({ type: 'started', run })
      29            0 :       const result = await checkCloudCompatibility()
      30            0 :       if (result?.kind === 'unreadableModelLoader') {
      31            0 :         dispatch({ type: 'failed', run, nodeType: result.nodeType })
      32            0 :       } else if (result) {
      33            0 :         dispatch({ type: 'answered', run, verdict: result })
      34              :       } else {
      35            0 :         dispatch({ type: 'failed', run })
      36              :       }
      37              :     }
      38              : 
      39            1 :     function invalidate() {
      40            1 :       dispatch({ type: 'invalidated' })
      41              :     }
      42              : 
      43            1 :     const workflowStore = useWorkflowStore()
      44            1 :     useEventListener(api, 'graphChanged', invalidate)
      45            1 :     watch(() => workflowStore.activeWorkflow, invalidate, { flush: 'sync' })
      46              : 
      47            1 :     watch(isLoggedIn, () => {
      48            0 :       if (state.value.phase !== 'idle') void check()
      49              :     })
      50              : 
      51            1 :     return { state, check }
      52              :   }
      53              : )
        

Generated by: LCOV version 2.0-1