From bc6575afbb106ea22ae1ff7b1b9057ccb665a964 Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Thu, 4 Apr 2024 10:28:35 +0100 Subject: [PATCH] fix(editor): Rerun failed nodes in manual executions (#9050) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Iván Ovejero --- .../src/composables/useRunWorkflow.test.ts | 31 ++++++++++++++++++- .../src/composables/useRunWorkflow.ts | 9 ++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/packages/editor-ui/src/composables/useRunWorkflow.test.ts b/packages/editor-ui/src/composables/useRunWorkflow.test.ts index 04e83ef12..4b429325a 100644 --- a/packages/editor-ui/src/composables/useRunWorkflow.test.ts +++ b/packages/editor-ui/src/composables/useRunWorkflow.test.ts @@ -7,7 +7,7 @@ import { useWorkflowsStore } from '@/stores/workflows.store'; import { useUIStore } from '@/stores/ui.store'; import { useWorkflowHelpers } from '@/composables/useWorkflowHelpers'; import { useRouter } from 'vue-router'; -import type { IPinData, IRunData, Workflow } from 'n8n-workflow'; +import { ExpressionError, type IPinData, type IRunData, type Workflow } from 'n8n-workflow'; vi.mock('@/stores/n8nRoot.store', () => ({ useRootStore: vi.fn().mockReturnValue({ pushConnectionActive: true }), @@ -281,5 +281,34 @@ describe('useRunWorkflow({ router })', () => { expect(result.startNodeNames).toContain('node1'); expect(result.runData).toBeUndefined(); }); + + it('should rerun failed parent nodes, adding them to the returned list of start nodes and not adding their result to runData', () => { + const { consolidateRunDataAndStartNodes } = useRunWorkflow({ router }); + const directParentNodes = ['node1']; + const runData = { + node1: [ + { + error: new ExpressionError('error'), + }, + ], + } as unknown as IRunData; + const workflowMock = { + getParentNodes: vi.fn().mockReturnValue([]), + nodes: { + node1: { disabled: false }, + node2: { disabled: false }, + }, + } as unknown as Workflow; + + const result = consolidateRunDataAndStartNodes( + directParentNodes, + runData, + undefined, + workflowMock, + ); + + expect(result.startNodeNames).toContain('node1'); + expect(result.runData).toEqual(undefined); + }); }); }); diff --git a/packages/editor-ui/src/composables/useRunWorkflow.ts b/packages/editor-ui/src/composables/useRunWorkflow.ts index 4e2b73e31..68db3ecfe 100644 --- a/packages/editor-ui/src/composables/useRunWorkflow.ts +++ b/packages/editor-ui/src/composables/useRunWorkflow.ts @@ -349,14 +349,19 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType