From ef89640dea0e99fee9c8f0b579e6629560e73f23 Mon Sep 17 00:00:00 2001 From: Charlie Kolb Date: Thu, 16 Oct 2025 09:30:09 +0200 Subject: [PATCH] fix(editor): Use existing workflowState when setting node execution issues (#20777) --- .../src/composables/useNodeHelpers.test.ts | 26 +++++++++++++++++++ .../src/composables/useNodeHelpers.ts | 6 ++--- .../handlers/executionFinished.ts | 2 +- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/packages/frontend/editor-ui/src/composables/useNodeHelpers.test.ts b/packages/frontend/editor-ui/src/composables/useNodeHelpers.test.ts index fc2bdbdecb0..8d4d56031d7 100644 --- a/packages/frontend/editor-ui/src/composables/useNodeHelpers.test.ts +++ b/packages/frontend/editor-ui/src/composables/useNodeHelpers.test.ts @@ -19,6 +19,15 @@ import { faker } from '@faker-js/faker'; import type { INodeUi } from '@/Interface'; import type { IUsedCredential } from '@/features/credentials/credentials.types'; import { useNodeTypesStore } from '@/stores/nodeTypes.store'; +import { injectWorkflowState, useWorkflowState } from './useWorkflowState'; + +vi.mock('@/composables/useWorkflowState', async () => { + const actual = await vi.importActual('@/composables/useWorkflowState'); + return { + ...actual, + injectWorkflowState: vi.fn(), + }; +}); describe('useNodeHelpers()', () => { beforeAll(() => { @@ -29,6 +38,23 @@ describe('useNodeHelpers()', () => { vi.clearAllMocks(); }); + describe('initialization', () => { + it('should use provided workflowState and not inject', () => { + const workflowState = useWorkflowState(); + vi.clearAllMocks(); + + useNodeHelpers({ workflowState }); + + expect(injectWorkflowState).not.toBeCalled(); + }); + + it('should create workflowState if not provided', () => { + useNodeHelpers(); + + expect(injectWorkflowState).toBeCalled(); + }); + }); + describe('isNodeExecutable()', () => { it('should return true if the node is null but explicitly executable', () => { const { isNodeExecutable } = useNodeHelpers(); diff --git a/packages/frontend/editor-ui/src/composables/useNodeHelpers.ts b/packages/frontend/editor-ui/src/composables/useNodeHelpers.ts index 9695286a0fb..68a85efeed9 100644 --- a/packages/frontend/editor-ui/src/composables/useNodeHelpers.ts +++ b/packages/frontend/editor-ui/src/composables/useNodeHelpers.ts @@ -51,7 +51,7 @@ import { useTelemetry } from './useTelemetry'; import { hasPermission } from '@/utils/rbac/permissions'; import { useCanvasStore } from '@/stores/canvas.store'; import { useSettingsStore } from '@/stores/settings.store'; -import { injectWorkflowState } from './useWorkflowState'; +import { injectWorkflowState, type WorkflowState } from './useWorkflowState'; declare namespace HttpRequestNode { namespace V2 { @@ -63,12 +63,12 @@ declare namespace HttpRequestNode { } } -export function useNodeHelpers() { +export function useNodeHelpers(opts: { workflowState?: WorkflowState } = {}) { const credentialsStore = useCredentialsStore(); const historyStore = useHistoryStore(); const nodeTypesStore = useNodeTypesStore(); const workflowsStore = useWorkflowsStore(); - const workflowState = injectWorkflowState(); + const workflowState = opts.workflowState ?? injectWorkflowState(); const settingsStore = useSettingsStore(); const i18n = useI18n(); const canvasStore = useCanvasStore(); diff --git a/packages/frontend/editor-ui/src/composables/usePushConnection/handlers/executionFinished.ts b/packages/frontend/editor-ui/src/composables/usePushConnection/handlers/executionFinished.ts index 58da69a9265..58c401bc330 100644 --- a/packages/frontend/editor-ui/src/composables/usePushConnection/handlers/executionFinished.ts +++ b/packages/frontend/editor-ui/src/composables/usePushConnection/handlers/executionFinished.ts @@ -421,7 +421,7 @@ export function setRunExecutionData( workflowState: WorkflowState, ) { const workflowsStore = useWorkflowsStore(); - const nodeHelpers = useNodeHelpers(); + const nodeHelpers = useNodeHelpers({ workflowState }); const runDataExecutedErrorMessage = getRunDataExecutedErrorMessage(execution); const workflowExecution = workflowsStore.getWorkflowExecution;