diff --git a/packages/editor-ui/src/composables/useExecutionDebugging.spec.ts b/packages/editor-ui/src/composables/useExecutionDebugging.spec.ts new file mode 100644 index 0000000000000..a3c0b02ac7d5f --- /dev/null +++ b/packages/editor-ui/src/composables/useExecutionDebugging.spec.ts @@ -0,0 +1,40 @@ +import { createTestingPinia } from '@pinia/testing'; +import { setActivePinia } from 'pinia'; +import { mockedStore } from '@/__tests__/utils'; +import { useWorkflowsStore } from '@/stores/workflows.store'; +import { useExecutionDebugging } from './useExecutionDebugging'; +import type { INodeUi, IExecutionResponse } from '@/Interface'; +import type { Workflow } from 'n8n-workflow'; + +describe('useExecutionDebugging()', () => { + it('should applyExecutionData', async () => { + setActivePinia(createTestingPinia()); + const mockExecution = { + data: { + resultData: { + runData: { + testNode: [ + { + data: {}, + }, + ], + }, + }, + }, + } as unknown as IExecutionResponse; + + const workflowStore = mockedStore(useWorkflowsStore); + workflowStore.getNodes.mockReturnValue([{ name: 'testNode' }] as INodeUi[]); + workflowStore.getExecution.mockResolvedValueOnce(mockExecution); + workflowStore.getCurrentWorkflow.mockReturnValue({ + pinData: {}, + getParentNodes: vi.fn().mockReturnValue([]), + } as unknown as Workflow); + + const { applyExecutionData } = useExecutionDebugging(); + + await applyExecutionData('1'); + + expect(workflowStore.setWorkflowExecutionData).toHaveBeenCalledWith(mockExecution); + }); +}); diff --git a/packages/editor-ui/src/composables/useExecutionDebugging.ts b/packages/editor-ui/src/composables/useExecutionDebugging.ts index b13a22dfa020a..cf59964bb8706 100644 --- a/packages/editor-ui/src/composables/useExecutionDebugging.ts +++ b/packages/editor-ui/src/composables/useExecutionDebugging.ts @@ -105,7 +105,7 @@ export const useExecutionDebugging = () => { let pinnings = 0; pinnableNodes.forEach((node: INodeUi) => { - const nodeData = runData[node.name]?.[0].data?.main[0]; + const nodeData = runData[node.name]?.[0].data?.main?.[0]; if (nodeData) { pinnings++; workflowsStore.pinData({