mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
feat(core): Parent workflows should wait for sub-workflows to finish (#11985)
This commit is contained in:
committed by
GitHub
parent
956b11a560
commit
60b3dccf93
@@ -1,11 +1,11 @@
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { IWorkflowBase } from 'n8n-workflow';
|
||||
import {
|
||||
type IExecuteWorkflowInfo,
|
||||
type IWorkflowExecuteAdditionalData,
|
||||
type ExecuteWorkflowOptions,
|
||||
type IRun,
|
||||
type INodeExecutionData,
|
||||
import type {
|
||||
IExecuteWorkflowInfo,
|
||||
IWorkflowExecuteAdditionalData,
|
||||
ExecuteWorkflowOptions,
|
||||
IRun,
|
||||
INodeExecutionData,
|
||||
} from 'n8n-workflow';
|
||||
import type PCancelable from 'p-cancelable';
|
||||
import Container from 'typedi';
|
||||
@@ -50,6 +50,7 @@ const getMockRun = ({ lastNodeOutput }: { lastNodeOutput: Array<INodeExecutionDa
|
||||
mode: 'manual',
|
||||
startedAt: new Date(),
|
||||
status: 'new',
|
||||
waitTill: undefined,
|
||||
});
|
||||
|
||||
const getCancelablePromise = async (run: IRun) =>
|
||||
@@ -114,7 +115,9 @@ describe('WorkflowExecuteAdditionalData', () => {
|
||||
});
|
||||
|
||||
describe('executeWorkflow', () => {
|
||||
const runWithData = getMockRun({ lastNodeOutput: [[{ json: { test: 1 } }]] });
|
||||
const runWithData = getMockRun({
|
||||
lastNodeOutput: [[{ json: { test: 1 } }]],
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
workflowRepository.get.mockResolvedValue(
|
||||
@@ -159,6 +162,23 @@ describe('WorkflowExecuteAdditionalData', () => {
|
||||
|
||||
expect(executionRepository.setRunning).toHaveBeenCalledWith(EXECUTION_ID);
|
||||
});
|
||||
|
||||
it('should return waitTill property when workflow execution is waiting', async () => {
|
||||
const waitTill = new Date();
|
||||
runWithData.waitTill = waitTill;
|
||||
|
||||
const response = await executeWorkflow(
|
||||
mock<IExecuteWorkflowInfo>(),
|
||||
mock<IWorkflowExecuteAdditionalData>(),
|
||||
mock<ExecuteWorkflowOptions>({ loadedWorkflowData: undefined, doNotWaitToFinish: false }),
|
||||
);
|
||||
|
||||
expect(response).toEqual({
|
||||
data: runWithData.data.resultData.runData[LAST_NODE_EXECUTED][0].data!.main,
|
||||
executionId: EXECUTION_ID,
|
||||
waitTill,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getRunData', () => {
|
||||
@@ -230,6 +250,10 @@ describe('WorkflowExecuteAdditionalData', () => {
|
||||
waitingExecution: {},
|
||||
waitingExecutionSource: {},
|
||||
},
|
||||
parentExecution: {
|
||||
executionId: '123',
|
||||
workflowId: '567',
|
||||
},
|
||||
resultData: { runData: {} },
|
||||
startData: {},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user