🐛 Fix issue that nodes did execute even if there was no input data

This commit is contained in:
Jan Oberhauser
2021-05-08 21:49:55 -05:00
parent 29b9ebfaff
commit b47f4bc012
3 changed files with 199 additions and 2 deletions

View File

@@ -1154,6 +1154,174 @@ describe('WorkflowExecute', () => {
},
},
},
{
description: 'should not use empty data in sibling if parent did not send any data',
input: {
// Leave the workflowData in regular JSON to be able to easily
// copy it from/in the UI
workflowData: {
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
250,
300,
],
},
{
"parameters": {
"values": {
"number": [
{
"name": "value1",
},
],
},
"options": {},
},
"name": "Set",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
450,
300,
],
},
{
"parameters": {},
"name": "Merge",
"type": "n8n-nodes-base.merge",
"typeVersion": 1,
"position": [
1050,
250,
],
},
{
"parameters": {
"conditions": {
"number": [
{
"value1": "={{$json[\"value1\"]}}",
"operation": "equal",
"value2": 1,
},
],
},
},
"name": "IF",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
650,
300,
],
},
{
"parameters": {},
"name": "NoOpTrue",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
850,
150,
],
},
{
"parameters": {},
"name": "NoOpFalse",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
850,
400,
],
},
],
"connections": {
"Start": {
"main": [
[
{
"node": "Set",
"type": "main",
"index": 0,
},
],
],
},
"Set": {
"main": [
[
{
"node": "IF",
"type": "main",
"index": 0,
},
],
],
},
"IF": {
"main": [
[
{
"node": "NoOpTrue",
"type": "main",
"index": 0,
},
{
"node": "Merge",
"type": "main",
"index": 1,
},
],
[
{
"node": "NoOpFalse",
"type": "main",
"index": 0,
},
],
],
},
"NoOpTrue": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0,
},
],
],
},
},
},
},
output: {
nodeExecutionOrder: [
'Start',
'Set',
'IF',
'NoOpFalse',
],
nodeData: {
IF: [
[],
],
NoOpFalse: [
[
{
value1: 0,
},
],
],
},
},
},
];
const fakeLogger = {
@@ -1165,7 +1333,6 @@ describe('WorkflowExecute', () => {
error: () => {},
} as ILogger;
const executionMode = 'manual';
const nodeTypes = Helpers.NodeTypes();
LoggerProxy.init(fakeLogger);
@@ -1213,7 +1380,6 @@ describe('WorkflowExecute', () => {
expect(result.finished).toEqual(true);
expect(result.data.executionData!.contextData).toEqual({});
expect(result.data.executionData!.nodeExecutionStack).toEqual([]);
expect(result.data.executionData!.waitingExecution).toEqual({});
});
}