From ab92df332f464f17c046571afdc38d7c4ac3ce4b Mon Sep 17 00:00:00 2001 From: christian-byrne Date: Sat, 29 Aug 2026 16:52:55 -0700 Subject: [PATCH 1/9] test(assets): cover ECS output projection --- src/scripts/app.nodeOutputIntegration.test.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/scripts/app.nodeOutputIntegration.test.ts diff --git a/src/scripts/app.nodeOutputIntegration.test.ts b/src/scripts/app.nodeOutputIntegration.test.ts new file mode 100644 index 00000000000..68ad5e7bc32 --- /dev/null +++ b/src/scripts/app.nodeOutputIntegration.test.ts @@ -0,0 +1,56 @@ +import { describe, expect, it, vi } from 'vitest' + +import { LGraph, LGraphNode } from '@/lib/litegraph/src/litegraph' +import type { ExecutedWsMessage } from '@/schemas/apiSchema' +import { api } from '@/scripts/api' +import { app } from '@/scripts/app' +import { useNodeOutputStore } from '@/stores/nodeOutputStore' + +describe('execution output projection', () => { + it('projects an executed event through canonical state to node preview URLs', () => { + const graph = new LGraph() + const node = new LGraphNode('Preview Image') + const onExecuted = vi.fn() + node.onExecuted = onExecuted + graph.add(node) + + Reflect.set(app, 'rootGraphInternal', graph) + app.vueAppReady = false + app.nodeOutputs = {} + const appWithApiHandlers = app as unknown as { + addApiUpdateHandlers: () => void + } + appWithApiHandlers.addApiUpdateHandlers() + + const output: ExecutedWsMessage['output'] = { + images: [ + { + filename: 'execution-result.png', + subfolder: 'daily outputs', + type: 'output' + } + ] + } + + api.dispatchCustomEvent('executed', { + node: node.id, + display_node: node.id, + prompt_id: 'test-prompt', + output + }) + + const store = useNodeOutputStore() + expect(store.nodeOutputs[String(node.id)]).toEqual(output) + expect(app.nodeOutputs[String(node.id)]).toEqual(output) + expect(onExecuted).toHaveBeenCalledWith(output) + + const [previewUrl] = store.getNodeImageUrls(node) ?? [] + const parsedPreviewUrl = new URL(previewUrl, window.location.origin) + expect(parsedPreviewUrl.pathname).toBe('/api/view') + expect(parsedPreviewUrl.searchParams.get('filename')).toBe( + 'execution-result.png' + ) + expect(parsedPreviewUrl.searchParams.get('subfolder')).toBe('daily outputs') + expect(parsedPreviewUrl.searchParams.get('type')).toBe('output') + }) +}) From 33eca4b650c754bc957e2a47f3de51439166048b Mon Sep 17 00:00:00 2001 From: christian-byrne Date: Sat, 29 Aug 2026 22:39:37 -0700 Subject: [PATCH 2/9] test: isolate output projection socket setup --- src/scripts/app.nodeOutputIntegration.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/scripts/app.nodeOutputIntegration.test.ts b/src/scripts/app.nodeOutputIntegration.test.ts index 68ad5e7bc32..d3d66828dcc 100644 --- a/src/scripts/app.nodeOutputIntegration.test.ts +++ b/src/scripts/app.nodeOutputIntegration.test.ts @@ -20,6 +20,7 @@ describe('execution output projection', () => { const appWithApiHandlers = app as unknown as { addApiUpdateHandlers: () => void } + vi.spyOn(api, 'init').mockImplementation(() => {}) appWithApiHandlers.addApiUpdateHandlers() const output: ExecutedWsMessage['output'] = { From 7b6141abe2046df5f736b501bc2e07f2c8e9cf53 Mon Sep 17 00:00:00 2001 From: christian-byrne Date: Mon, 31 Aug 2026 15:44:29 -0700 Subject: [PATCH 3/9] test: assert canonical output preview path Addresses https://github.com/Comfy-Org/ComfyUI_frontend/pull/16261#discussion_r3899022985 --- src/scripts/app.nodeOutputIntegration.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/scripts/app.nodeOutputIntegration.test.ts b/src/scripts/app.nodeOutputIntegration.test.ts index d3d66828dcc..b5c4b640a75 100644 --- a/src/scripts/app.nodeOutputIntegration.test.ts +++ b/src/scripts/app.nodeOutputIntegration.test.ts @@ -5,6 +5,7 @@ import type { ExecutedWsMessage } from '@/schemas/apiSchema' import { api } from '@/scripts/api' import { app } from '@/scripts/app' import { useNodeOutputStore } from '@/stores/nodeOutputStore' +import { createNodeExecutionId } from '@/types/nodeIdentification' describe('execution output projection', () => { it('projects an executed event through canonical state to node preview URLs', () => { @@ -41,11 +42,13 @@ describe('execution output projection', () => { }) const store = useNodeOutputStore() + const executionId = createNodeExecutionId([node.id]) expect(store.nodeOutputs[String(node.id)]).toEqual(output) expect(app.nodeOutputs[String(node.id)]).toEqual(output) expect(onExecuted).toHaveBeenCalledWith(output) - const [previewUrl] = store.getNodeImageUrls(node) ?? [] + const [previewUrl] = + store.getNodeImageUrlsByExecutionId(executionId, node) ?? [] const parsedPreviewUrl = new URL(previewUrl, window.location.origin) expect(parsedPreviewUrl.pathname).toBe('/api/view') expect(parsedPreviewUrl.searchParams.get('filename')).toBe( From fe2c5bce11da73368567db3e9b3821b339e9ff73 Mon Sep 17 00:00:00 2001 From: christian-byrne Date: Mon, 31 Aug 2026 15:45:45 -0700 Subject: [PATCH 4/9] test: avoid private app lifecycle wiring Addresses https://github.com/Comfy-Org/ComfyUI_frontend/pull/16261#discussion_r3899022989 --- src/scripts/app.nodeOutputIntegration.test.ts | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/scripts/app.nodeOutputIntegration.test.ts b/src/scripts/app.nodeOutputIntegration.test.ts index b5c4b640a75..7afc3dab1ac 100644 --- a/src/scripts/app.nodeOutputIntegration.test.ts +++ b/src/scripts/app.nodeOutputIntegration.test.ts @@ -1,28 +1,19 @@ -import { describe, expect, it, vi } from 'vitest' +import { describe, expect, it } from 'vitest' import { LGraph, LGraphNode } from '@/lib/litegraph/src/litegraph' import type { ExecutedWsMessage } from '@/schemas/apiSchema' -import { api } from '@/scripts/api' import { app } from '@/scripts/app' import { useNodeOutputStore } from '@/stores/nodeOutputStore' import { createNodeExecutionId } from '@/types/nodeIdentification' describe('execution output projection', () => { - it('projects an executed event through canonical state to node preview URLs', () => { + it('projects canonical output state to node preview URLs', () => { const graph = new LGraph() const node = new LGraphNode('Preview Image') - const onExecuted = vi.fn() - node.onExecuted = onExecuted graph.add(node) Reflect.set(app, 'rootGraphInternal', graph) - app.vueAppReady = false app.nodeOutputs = {} - const appWithApiHandlers = app as unknown as { - addApiUpdateHandlers: () => void - } - vi.spyOn(api, 'init').mockImplementation(() => {}) - appWithApiHandlers.addApiUpdateHandlers() const output: ExecutedWsMessage['output'] = { images: [ @@ -34,18 +25,12 @@ describe('execution output projection', () => { ] } - api.dispatchCustomEvent('executed', { - node: node.id, - display_node: node.id, - prompt_id: 'test-prompt', - output - }) - const store = useNodeOutputStore() const executionId = createNodeExecutionId([node.id]) + store.setNodeOutputsByExecutionId(executionId, output) + expect(store.nodeOutputs[String(node.id)]).toEqual(output) expect(app.nodeOutputs[String(node.id)]).toEqual(output) - expect(onExecuted).toHaveBeenCalledWith(output) const [previewUrl] = store.getNodeImageUrlsByExecutionId(executionId, node) ?? [] From d3b1d462e5b7abf6843cf80f45667562dce08c5b Mon Sep 17 00:00:00 2001 From: bymyself Date: Wed, 2 Sep 2026 03:28:32 +0000 Subject: [PATCH 5/9] test: restore app state after output projection Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/16261#discussion_r3909884715 --- src/scripts/app.nodeOutputIntegration.test.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/scripts/app.nodeOutputIntegration.test.ts b/src/scripts/app.nodeOutputIntegration.test.ts index 7afc3dab1ac..56f22b1c3f4 100644 --- a/src/scripts/app.nodeOutputIntegration.test.ts +++ b/src/scripts/app.nodeOutputIntegration.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, it } from 'vitest' +import { afterEach, beforeEach, describe, expect, it } from 'vitest' import { LGraph, LGraphNode } from '@/lib/litegraph/src/litegraph' import type { ExecutedWsMessage } from '@/schemas/apiSchema' @@ -7,6 +7,19 @@ import { useNodeOutputStore } from '@/stores/nodeOutputStore' import { createNodeExecutionId } from '@/types/nodeIdentification' describe('execution output projection', () => { + let originalRootGraph: unknown + let originalNodeOutputs: typeof app.nodeOutputs + + beforeEach(() => { + originalRootGraph = Reflect.get(app, 'rootGraphInternal') + originalNodeOutputs = { ...app.nodeOutputs } + }) + + afterEach(() => { + Reflect.set(app, 'rootGraphInternal', originalRootGraph) + app.nodeOutputs = originalNodeOutputs + }) + it('projects canonical output state to node preview URLs', () => { const graph = new LGraph() const node = new LGraphNode('Preview Image') From cb7bb035ce31c73a608904093ddee7c81e35547e Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 12 Sep 2026 05:23:57 -0700 Subject: [PATCH 6/9] test(assets): rewrite output projection as store unit test Replace the app-level integration test that mutated the nodeOutputStore singleton via module-level state with a store unit test that sets up its own fixtures and asserts the projection through the store API. --- src/scripts/app.nodeOutputIntegration.test.ts | 58 -------------- .../nodeOutputStore.outputProjection.test.ts | 80 +++++++++++++++++++ 2 files changed, 80 insertions(+), 58 deletions(-) delete mode 100644 src/scripts/app.nodeOutputIntegration.test.ts create mode 100644 src/stores/nodeOutputStore.outputProjection.test.ts diff --git a/src/scripts/app.nodeOutputIntegration.test.ts b/src/scripts/app.nodeOutputIntegration.test.ts deleted file mode 100644 index 56f22b1c3f4..00000000000 --- a/src/scripts/app.nodeOutputIntegration.test.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { afterEach, beforeEach, describe, expect, it } from 'vitest' - -import { LGraph, LGraphNode } from '@/lib/litegraph/src/litegraph' -import type { ExecutedWsMessage } from '@/schemas/apiSchema' -import { app } from '@/scripts/app' -import { useNodeOutputStore } from '@/stores/nodeOutputStore' -import { createNodeExecutionId } from '@/types/nodeIdentification' - -describe('execution output projection', () => { - let originalRootGraph: unknown - let originalNodeOutputs: typeof app.nodeOutputs - - beforeEach(() => { - originalRootGraph = Reflect.get(app, 'rootGraphInternal') - originalNodeOutputs = { ...app.nodeOutputs } - }) - - afterEach(() => { - Reflect.set(app, 'rootGraphInternal', originalRootGraph) - app.nodeOutputs = originalNodeOutputs - }) - - it('projects canonical output state to node preview URLs', () => { - const graph = new LGraph() - const node = new LGraphNode('Preview Image') - graph.add(node) - - Reflect.set(app, 'rootGraphInternal', graph) - app.nodeOutputs = {} - - const output: ExecutedWsMessage['output'] = { - images: [ - { - filename: 'execution-result.png', - subfolder: 'daily outputs', - type: 'output' - } - ] - } - - const store = useNodeOutputStore() - const executionId = createNodeExecutionId([node.id]) - store.setNodeOutputsByExecutionId(executionId, output) - - expect(store.nodeOutputs[String(node.id)]).toEqual(output) - expect(app.nodeOutputs[String(node.id)]).toEqual(output) - - const [previewUrl] = - store.getNodeImageUrlsByExecutionId(executionId, node) ?? [] - const parsedPreviewUrl = new URL(previewUrl, window.location.origin) - expect(parsedPreviewUrl.pathname).toBe('/api/view') - expect(parsedPreviewUrl.searchParams.get('filename')).toBe( - 'execution-result.png' - ) - expect(parsedPreviewUrl.searchParams.get('subfolder')).toBe('daily outputs') - expect(parsedPreviewUrl.searchParams.get('type')).toBe('output') - }) -}) diff --git a/src/stores/nodeOutputStore.outputProjection.test.ts b/src/stores/nodeOutputStore.outputProjection.test.ts new file mode 100644 index 00000000000..2f62754c9aa --- /dev/null +++ b/src/stores/nodeOutputStore.outputProjection.test.ts @@ -0,0 +1,80 @@ +import { fromAny } from '@total-typescript/shoehorn' +import { beforeEach, describe, expect, it, vi } from 'vitest' + +import type { LGraphNode } from '@/lib/litegraph/src/litegraph' +import type { ExecutedWsMessage } from '@/schemas/apiSchema' +import { app } from '@/scripts/app' +import { useNodeOutputStore } from '@/stores/nodeOutputStore' +import { toNodeId } from '@/types/nodeId' +import { createNodeExecutionId } from '@/types/nodeIdentification' + +const mockGetNodeById = vi.fn() + +vi.mock(import('@/utils/litegraphUtil'), () => ({ + isAnimatedOutput: vi.fn(() => false), + isVideoNode: vi.fn(() => false), + resolveNode: vi.fn() +})) + +vi.mock(import('@/scripts/app'), () => ({ + app: { + getPreviewFormatParam: vi.fn(() => ''), + getRandParam: vi.fn(() => ''), + rootGraph: { + getNodeById: (...args: unknown[]) => mockGetNodeById(...args) + }, + nodeOutputs: {} as Record, + nodePreviewImages: {} as Record + } +})) + +vi.mock(import('@/utils/graphTraversalUtil'), () => ({ + executionIdToNodeLocatorId: vi.fn((_rootGraph: unknown, id: string) => id) +})) + +function createMockNode(id: number): LGraphNode { + return fromAny({ + id: toNodeId(id), + type: 'PreviewImage' + }) +} + +describe('useNodeOutputStore output projection', () => { + beforeEach(() => { + vi.clearAllMocks() + app.nodeOutputs = {} + app.nodePreviewImages = {} + }) + + it('projects an executed output into the store, app.nodeOutputs and view URLs', () => { + const store = useNodeOutputStore() + const node = createMockNode(1) + mockGetNodeById.mockReturnValue(node) + const executionId = createNodeExecutionId([node.id]) + const output: ExecutedWsMessage['output'] = { + images: [ + { + filename: 'execution-result.png', + subfolder: 'daily outputs', + type: 'output' + } + ] + } + + store.setNodeOutputsByExecutionId(executionId, output) + + expect(store.nodeOutputs[String(node.id)]).toEqual(output) + expect(app.nodeOutputs[String(node.id)]).toEqual(output) + + const urls = store.getNodeImageUrlsByExecutionId(executionId, node) + expect(urls).toHaveLength(1) + + const previewUrl = new URL(urls![0], window.location.origin) + expect(previewUrl.pathname).toBe('/api/view') + expect(previewUrl.searchParams.get('filename')).toBe( + 'execution-result.png' + ) + expect(previewUrl.searchParams.get('subfolder')).toBe('daily outputs') + expect(previewUrl.searchParams.get('type')).toBe('output') + }) +}) From 0b493f686f57cc88510af3c789dbccdc358c88a2 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 12 Sep 2026 05:46:13 -0700 Subject: [PATCH 7/9] test(assets): drop redundant vi.clearAllMocks in projection test --- src/stores/nodeOutputStore.outputProjection.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/stores/nodeOutputStore.outputProjection.test.ts b/src/stores/nodeOutputStore.outputProjection.test.ts index 2f62754c9aa..ba8153d4315 100644 --- a/src/stores/nodeOutputStore.outputProjection.test.ts +++ b/src/stores/nodeOutputStore.outputProjection.test.ts @@ -41,7 +41,6 @@ function createMockNode(id: number): LGraphNode { describe('useNodeOutputStore output projection', () => { beforeEach(() => { - vi.clearAllMocks() app.nodeOutputs = {} app.nodePreviewImages = {} }) From e0fbdf6959702615c188d1b52ffd563b26048a01 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sat, 12 Sep 2026 12:52:12 +0000 Subject: [PATCH 8/9] [automated] Apply ESLint and Oxfmt fixes --- src/stores/nodeOutputStore.outputProjection.test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/stores/nodeOutputStore.outputProjection.test.ts b/src/stores/nodeOutputStore.outputProjection.test.ts index ba8153d4315..57522cd5d29 100644 --- a/src/stores/nodeOutputStore.outputProjection.test.ts +++ b/src/stores/nodeOutputStore.outputProjection.test.ts @@ -70,9 +70,7 @@ describe('useNodeOutputStore output projection', () => { const previewUrl = new URL(urls![0], window.location.origin) expect(previewUrl.pathname).toBe('/api/view') - expect(previewUrl.searchParams.get('filename')).toBe( - 'execution-result.png' - ) + expect(previewUrl.searchParams.get('filename')).toBe('execution-result.png') expect(previewUrl.searchParams.get('subfolder')).toBe('daily outputs') expect(previewUrl.searchParams.get('type')).toBe('output') }) From 4542dcb1edfcb4b22abf449e8866e6beffa8687f Mon Sep 17 00:00:00 2001 From: bymyself Date: Sat, 12 Sep 2026 14:34:24 +0000 Subject: [PATCH 9/9] test: move output projection coverage into store suite Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/16261#discussion_r3995411126 --- .../nodeOutputStore.outputProjection.test.ts | 77 ------------------- src/stores/nodeOutputStore.test.ts | 26 +++++++ 2 files changed, 26 insertions(+), 77 deletions(-) delete mode 100644 src/stores/nodeOutputStore.outputProjection.test.ts diff --git a/src/stores/nodeOutputStore.outputProjection.test.ts b/src/stores/nodeOutputStore.outputProjection.test.ts deleted file mode 100644 index 57522cd5d29..00000000000 --- a/src/stores/nodeOutputStore.outputProjection.test.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { fromAny } from '@total-typescript/shoehorn' -import { beforeEach, describe, expect, it, vi } from 'vitest' - -import type { LGraphNode } from '@/lib/litegraph/src/litegraph' -import type { ExecutedWsMessage } from '@/schemas/apiSchema' -import { app } from '@/scripts/app' -import { useNodeOutputStore } from '@/stores/nodeOutputStore' -import { toNodeId } from '@/types/nodeId' -import { createNodeExecutionId } from '@/types/nodeIdentification' - -const mockGetNodeById = vi.fn() - -vi.mock(import('@/utils/litegraphUtil'), () => ({ - isAnimatedOutput: vi.fn(() => false), - isVideoNode: vi.fn(() => false), - resolveNode: vi.fn() -})) - -vi.mock(import('@/scripts/app'), () => ({ - app: { - getPreviewFormatParam: vi.fn(() => ''), - getRandParam: vi.fn(() => ''), - rootGraph: { - getNodeById: (...args: unknown[]) => mockGetNodeById(...args) - }, - nodeOutputs: {} as Record, - nodePreviewImages: {} as Record - } -})) - -vi.mock(import('@/utils/graphTraversalUtil'), () => ({ - executionIdToNodeLocatorId: vi.fn((_rootGraph: unknown, id: string) => id) -})) - -function createMockNode(id: number): LGraphNode { - return fromAny({ - id: toNodeId(id), - type: 'PreviewImage' - }) -} - -describe('useNodeOutputStore output projection', () => { - beforeEach(() => { - app.nodeOutputs = {} - app.nodePreviewImages = {} - }) - - it('projects an executed output into the store, app.nodeOutputs and view URLs', () => { - const store = useNodeOutputStore() - const node = createMockNode(1) - mockGetNodeById.mockReturnValue(node) - const executionId = createNodeExecutionId([node.id]) - const output: ExecutedWsMessage['output'] = { - images: [ - { - filename: 'execution-result.png', - subfolder: 'daily outputs', - type: 'output' - } - ] - } - - store.setNodeOutputsByExecutionId(executionId, output) - - expect(store.nodeOutputs[String(node.id)]).toEqual(output) - expect(app.nodeOutputs[String(node.id)]).toEqual(output) - - const urls = store.getNodeImageUrlsByExecutionId(executionId, node) - expect(urls).toHaveLength(1) - - const previewUrl = new URL(urls![0], window.location.origin) - expect(previewUrl.pathname).toBe('/api/view') - expect(previewUrl.searchParams.get('filename')).toBe('execution-result.png') - expect(previewUrl.searchParams.get('subfolder')).toBe('daily outputs') - expect(previewUrl.searchParams.get('type')).toBe('output') - }) -}) diff --git a/src/stores/nodeOutputStore.test.ts b/src/stores/nodeOutputStore.test.ts index 6819ccd619f..58f5d9c509c 100644 --- a/src/stores/nodeOutputStore.test.ts +++ b/src/stores/nodeOutputStore.test.ts @@ -26,6 +26,7 @@ const mockGetNodeById = vi.fn() vi.mock(import('@/scripts/app'), () => ({ app: { getPreviewFormatParam: vi.fn(() => '&format=test_webp'), + getRandParam: vi.fn(() => ''), rootGraph: { getNodeById: (...args: unknown[]) => mockGetNodeById(...args) }, @@ -133,6 +134,31 @@ describe('nodeOutputStore setNodeOutputsByExecutionId with merge', () => { ).toEqual(['blob:second']) }) + it('projects execution output into canonical state and view URLs', () => { + const store = useNodeOutputStore() + const node = createMockNode({ id: 1 }) + const executionId = createNodeExecutionId([node.id]) + const output = createMockOutputs([ + { + filename: 'execution-result.png', + subfolder: 'daily outputs', + type: 'output' + } + ]) + + store.setNodeOutputsByExecutionId(executionId, output) + + expect(store.nodeOutputs[String(node.id)]).toEqual(output) + expect(app.nodeOutputs[String(node.id)]).toEqual(output) + + const [url] = store.getNodeImageUrlsByExecutionId(executionId, node) ?? [] + const previewUrl = new URL(url, window.location.origin) + expect(previewUrl.pathname).toBe('/api/view') + expect(previewUrl.searchParams.get('filename')).toBe('execution-result.png') + expect(previewUrl.searchParams.get('subfolder')).toBe('daily outputs') + expect(previewUrl.searchParams.get('type')).toBe('output') + }) + it('owns preview arrays after setting them', () => { const store = useNodeOutputStore() const executionId = createNodeExecutionId([toNodeId(11)])