mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
fix(editor): Fix Cannot read properties of undefined (reading 'finished') (#11367)
This commit is contained in:
parent
e61a8535aa
commit
475d72e0bc
|
@ -8,7 +8,13 @@ import {
|
|||
WAIT_NODE_TYPE,
|
||||
} from '@/constants';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import type { IExecutionResponse, INodeUi, IWorkflowDb, IWorkflowSettings } from '@/Interface';
|
||||
import type {
|
||||
IExecutionResponse,
|
||||
IExecutionsCurrentSummaryExtended,
|
||||
INodeUi,
|
||||
IWorkflowDb,
|
||||
IWorkflowSettings,
|
||||
} from '@/Interface';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
|
||||
import {
|
||||
|
@ -594,6 +600,50 @@ describe('useWorkflowsStore', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('finishActiveExecution', () => {
|
||||
it('should update execution', async () => {
|
||||
const cursor = 1;
|
||||
const ids = ['0', '1', '2'];
|
||||
workflowsStore.setActiveExecutions(
|
||||
ids.map((id) => ({ id })) as IExecutionsCurrentSummaryExtended[],
|
||||
);
|
||||
|
||||
const stoppedAt = new Date();
|
||||
|
||||
workflowsStore.finishActiveExecution({
|
||||
executionId: ids[cursor],
|
||||
data: {
|
||||
finished: true,
|
||||
stoppedAt,
|
||||
},
|
||||
} as PushPayload<'executionFinished'>);
|
||||
|
||||
expect(workflowsStore.activeExecutions[cursor]).toStrictEqual({
|
||||
id: ids[cursor],
|
||||
finished: true,
|
||||
stoppedAt,
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle parameter casting', async () => {
|
||||
const cursor = 1;
|
||||
const ids = ['0', '1', '2'];
|
||||
workflowsStore.setActiveExecutions(
|
||||
ids.map((id) => ({ id })) as IExecutionsCurrentSummaryExtended[],
|
||||
);
|
||||
|
||||
workflowsStore.finishActiveExecution({
|
||||
executionId: ids[cursor],
|
||||
} as PushPayload<'executionFinished'>);
|
||||
|
||||
expect(workflowsStore.activeExecutions[cursor]).toStrictEqual({
|
||||
id: ids[cursor],
|
||||
finished: undefined,
|
||||
stoppedAt: undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function getMockEditFieldsNode() {
|
||||
|
|
|
@ -47,7 +47,6 @@ import type {
|
|||
INodeParameters,
|
||||
INodeTypes,
|
||||
IPinData,
|
||||
IRun,
|
||||
IRunData,
|
||||
IRunExecutionData,
|
||||
ITaskData,
|
||||
|
@ -1344,23 +1343,16 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
return;
|
||||
}
|
||||
|
||||
const activeExecution = activeExecutions.value[activeExecutionIndex];
|
||||
Object.assign(activeExecutions.value[activeExecutionIndex], {
|
||||
...(finishedActiveExecution.executionId !== undefined
|
||||
? { id: finishedActiveExecution.executionId }
|
||||
: {}),
|
||||
finished: finishedActiveExecution.data?.finished,
|
||||
stoppedAt: finishedActiveExecution.data?.stoppedAt,
|
||||
});
|
||||
|
||||
activeExecutions.value = [
|
||||
...activeExecutions.value.slice(0, activeExecutionIndex),
|
||||
{
|
||||
...activeExecution,
|
||||
...(finishedActiveExecution.executionId !== undefined
|
||||
? { id: finishedActiveExecution.executionId }
|
||||
: {}),
|
||||
finished: finishedActiveExecution.data.finished,
|
||||
stoppedAt: finishedActiveExecution.data.stoppedAt,
|
||||
},
|
||||
...activeExecutions.value.slice(activeExecutionIndex + 1),
|
||||
];
|
||||
|
||||
if (finishedActiveExecution.data && (finishedActiveExecution.data as IRun).data) {
|
||||
setWorkflowExecutionRunData((finishedActiveExecution.data as IRun).data);
|
||||
if (finishedActiveExecution.data?.data) {
|
||||
setWorkflowExecutionRunData(finishedActiveExecution.data.data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue