Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/stores/nodeOutputStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const mockGetNodeById = vi.fn()
vi.mock<unknown>(import('@/scripts/app'), () => ({
app: {
getPreviewFormatParam: vi.fn(() => '&format=test_webp'),
getRandParam: vi.fn(() => ''),
rootGraph: {
getNodeById: (...args: unknown[]) => mockGetNodeById(...args)
},
Expand Down Expand Up @@ -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)])
Expand Down
Loading