diff --git a/packages/frontend/editor-ui/src/composables/usePushConnection/handlers/executionFinished.test.ts b/packages/frontend/editor-ui/src/composables/usePushConnection/handlers/executionFinished.test.ts index 7bb4f7b6532..273d9ab0364 100644 --- a/packages/frontend/editor-ui/src/composables/usePushConnection/handlers/executionFinished.test.ts +++ b/packages/frontend/editor-ui/src/composables/usePushConnection/handlers/executionFinished.test.ts @@ -1,10 +1,18 @@ import { describe, it, expect, vi } from 'vitest'; import { mock } from 'vitest-mock-extended'; -import { continueEvaluationLoop, type SimplifiedExecution } from './executionFinished'; +import { + continueEvaluationLoop, + executionFinished, + type SimplifiedExecution, +} from './executionFinished'; import type { ITaskData } from 'n8n-workflow'; import { EVALUATION_TRIGGER_NODE_TYPE } from 'n8n-workflow'; import type { INodeUi } from '@/Interface'; import type { Router } from 'vue-router'; +import { mockedStore } from '@/__tests__/utils'; +import { useWorkflowsStore } from '@/stores/workflows.store'; +import { createTestingPinia } from '@pinia/testing'; +import { setActivePinia } from 'pinia'; const runWorkflow = vi.fn(); @@ -170,3 +178,32 @@ describe('continueEvaluationLoop()', () => { expect(runWorkflow).not.toHaveBeenCalled(); }); }); + +describe('executionFinished', () => { + beforeEach(() => { + const pinia = createTestingPinia(); + setActivePinia(pinia); + }); + + it('should clear lastAddedExecutingNode when execution is finished', async () => { + const workflowsStore = mockedStore(useWorkflowsStore); + + workflowsStore.lastAddedExecutingNode = 'test-node'; + + await executionFinished( + { + type: 'executionFinished', + data: { + executionId: '1', + workflowId: '1', + status: 'success', + }, + }, + { + router: mock(), + }, + ); + + expect(workflowsStore.lastAddedExecutingNode).toBeNull(); + }); +}); 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 9b9fdf9b905..303706157b2 100644 --- a/packages/frontend/editor-ui/src/composables/usePushConnection/handlers/executionFinished.ts +++ b/packages/frontend/editor-ui/src/composables/usePushConnection/handlers/executionFinished.ts @@ -43,6 +43,8 @@ export async function executionFinished( const workflowsStore = useWorkflowsStore(); const uiStore = useUIStore(); + workflowsStore.lastAddedExecutingNode = null; + // No workflow is actively running, therefore we ignore this event if (typeof workflowsStore.activeExecutionId === 'undefined') { return;