mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 22:54:05 -08:00
d97edbcffa
* fix(core): Make node execution order configurable, and backward-compatible * ⚡ Also add new Merge-Node behaviour * ⚡ Fix typo * Fix lint issue * update labels * rename legacy to v0 * remove the unnecessary log * default all new workflows to use v1 execution-order * remove the controller changes * clone default settings to avoid it getting modified --------- Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { WorkflowExecute } from 'n8n-core';
|
|
import type { INodeTypes, IRun } from 'n8n-workflow';
|
|
import { createDeferredPromise, Workflow } from 'n8n-workflow';
|
|
import * as Helpers from './Helpers';
|
|
import type { WorkflowTestData } from './types';
|
|
|
|
export async function executeWorkflow(testData: WorkflowTestData, nodeTypes: INodeTypes) {
|
|
const executionMode = 'manual';
|
|
const workflowInstance = new Workflow({
|
|
id: 'test',
|
|
nodes: testData.input.workflowData.nodes,
|
|
connections: testData.input.workflowData.connections,
|
|
active: false,
|
|
nodeTypes,
|
|
settings: testData.input.workflowData.settings,
|
|
});
|
|
const waitPromise = await createDeferredPromise<IRun>();
|
|
const nodeExecutionOrder: string[] = [];
|
|
const additionalData = Helpers.WorkflowExecuteAdditionalData(
|
|
waitPromise,
|
|
nodeExecutionOrder,
|
|
testData,
|
|
);
|
|
const workflowExecute = new WorkflowExecute(additionalData, executionMode);
|
|
|
|
const executionData = await workflowExecute.run(workflowInstance);
|
|
const result = await waitPromise.promise();
|
|
return { executionData, result, nodeExecutionOrder };
|
|
}
|