[feat] Add missing nodes warning UI to queue button and breadcrumb (#6674)

This commit is contained in:
Jin Yi
2025-11-20 04:23:24 +09:00
committed by GitHub
parent ada0993572
commit a521066b25
5 changed files with 92 additions and 32 deletions

View File

@@ -9,12 +9,12 @@ import { useMissingNodes } from '@/workbench/extensions/manager/composables/node
import { useWorkflowPacks } from '@/workbench/extensions/manager/composables/nodePack/useWorkflowPacks'
import { useComfyManagerStore } from '@/workbench/extensions/manager/stores/comfyManagerStore'
// Mock Vue's onMounted to execute immediately for testing
vi.mock('vue', async () => {
const actual = await vi.importActual<typeof import('vue')>('vue')
vi.mock('@vueuse/core', async () => {
const actual =
await vi.importActual<typeof import('@vueuse/core')>('@vueuse/core')
return {
...actual,
onMounted: (cb: () => void) => cb()
createSharedComposable: <Fn extends (...args: any[]) => any>(fn: Fn) => fn
}
})
@@ -34,6 +34,12 @@ vi.mock('@/stores/nodeDefStore', () => ({
useNodeDefStore: vi.fn()
}))
vi.mock('@/platform/workflow/management/stores/workflowStore', () => ({
useWorkflowStore: vi.fn(() => ({
activeWorkflow: null
}))
}))
vi.mock('@/scripts/app', () => ({
app: {
graph: {
@@ -176,13 +182,13 @@ describe('useMissingNodes', () => {
})
describe('automatic data fetching', () => {
it('fetches workflow packs automatically when none exist', async () => {
it('fetches workflow packs automatically on initialization via watch with immediate:true', async () => {
useMissingNodes()
expect(mockStartFetchWorkflowPacks).toHaveBeenCalledOnce()
})
it('does not fetch when packs already exist', async () => {
it('fetches even when packs already exist (watch always fires with immediate:true)', async () => {
mockUseWorkflowPacks.mockReturnValue({
workflowPacks: ref(mockWorkflowPacks),
isLoading: ref(false),
@@ -194,10 +200,10 @@ describe('useMissingNodes', () => {
useMissingNodes()
expect(mockStartFetchWorkflowPacks).not.toHaveBeenCalled()
expect(mockStartFetchWorkflowPacks).toHaveBeenCalledOnce()
})
it('does not fetch when already loading', async () => {
it('fetches even when already loading (watch fires regardless of loading state)', async () => {
mockUseWorkflowPacks.mockReturnValue({
workflowPacks: ref([]),
isLoading: ref(true),
@@ -209,7 +215,7 @@ describe('useMissingNodes', () => {
useMissingNodes()
expect(mockStartFetchWorkflowPacks).not.toHaveBeenCalled()
expect(mockStartFetchWorkflowPacks).toHaveBeenCalledOnce()
})
})