fix(editor): Reset lastAddedExecutingNode on execution finished event (no-changelog) (#16791)

This commit is contained in:
Alex Grozav
2025-06-30 12:00:48 +03:00
committed by GitHub
parent 5821abae17
commit 934ddda30e
2 changed files with 40 additions and 1 deletions

View File

@@ -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<Router>(),
},
);
expect(workflowsStore.lastAddedExecutingNode).toBeNull();
});
});

View File

@@ -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;