test(Merge Node): Unit tests (no-changelog)

This commit is contained in:
Michael Kret 2023-02-07 19:32:25 +02:00 committed by GitHub
parent 9fb1fa1d79
commit 4d87711ace
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 1266 additions and 0 deletions

View file

@ -0,0 +1,5 @@
import { testWorkflows, getWorkflowFilenames } from '../../../../test/nodes/Helpers';
const workflows = getWorkflowFilenames(__dirname);
describe('Test Merge Node', () => testWorkflows(workflows));

View file

@ -0,0 +1,123 @@
{
"name": "merge tests",
"nodes": [
{
"parameters": {},
"id": "9f880c6f-b5e0-4453-b1d7-550beb1febe8",
"name": "When clicking \"Execute Workflow\"",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [820, 380]
},
{
"parameters": {
"jsCode": "return [\n {id: 1},\n {id: 2},\n {id: 3}, \n];"
},
"id": "263d9c7f-32d4-4112-b271-73d09b73809a",
"name": "Code",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1020, 220]
},
{
"parameters": {},
"id": "82ff69e1-596b-48dd-b724-388ef454a822",
"name": "Merge",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1280, 360]
},
{
"parameters": {
"jsCode": "return [\n {id: 4},\n {id: 5},\n {id: 6}, \n];"
},
"id": "3defcf5a-ec5e-4d23-a1f6-a99b7362a241",
"name": "Code1",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1040, 540]
}
],
"pinData": {
"Merge": [
{
"json": {
"id": 1
}
},
{
"json": {
"id": 2
}
},
{
"json": {
"id": 3
}
},
{
"json": {
"id": 4
}
},
{
"json": {
"id": 5
}
},
{
"json": {
"id": 6
}
}
]
},
"connections": {
"When clicking \"Execute Workflow\"": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
},
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Code1": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
}
},
"active": false,
"settings": {},
"versionId": "7082c0c9-60ab-4bcb-adbd-89e56e0bddd6",
"id": "107",
"meta": {
"instanceId": "36203ea1ce3cef713fa25999bd9874ae26b9e4c2c3a90a365f2882a154d031d0"
},
"tags": []
}

View file

@ -0,0 +1,174 @@
{
"name": "merge tests",
"nodes": [
{
"parameters": {},
"id": "9f880c6f-b5e0-4453-b1d7-550beb1febe8",
"name": "When clicking \"Execute Workflow\"",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [820, 380]
},
{
"parameters": {
"jsCode": "return [\n {id: 1},\n {id: 2},\n {id: 3}, \n];"
},
"id": "263d9c7f-32d4-4112-b271-73d09b73809a",
"name": "Code",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1020, 220]
},
{
"parameters": {
"jsCode": "return [\n {id: 4},\n {id: 5},\n {id: 6}, \n];"
},
"id": "3defcf5a-ec5e-4d23-a1f6-a99b7362a241",
"name": "Code1",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1040, 540]
},
{
"parameters": {
"mode": "chooseBranch"
},
"id": "7120cd6f-29f3-4f5b-aa25-babebd6335d3",
"name": "Merge",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1300, 240]
},
{
"parameters": {
"mode": "chooseBranch",
"output": "input2"
},
"id": "5dbe68d4-bf2f-40ea-a9ae-ee83b4030fa5",
"name": "Merge1",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1300, 380]
},
{
"parameters": {
"mode": "chooseBranch",
"output": "empty"
},
"id": "3b2885c3-5c2e-4972-910a-50ff8e173d11",
"name": "Merge2",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1300, 520]
}
],
"pinData": {
"Merge": [
{
"json": {
"id": 1
}
},
{
"json": {
"id": 2
}
},
{
"json": {
"id": 3
}
}
],
"Merge1": [
{
"json": {
"id": 4
}
},
{
"json": {
"id": 5
}
},
{
"json": {
"id": 6
}
}
],
"Merge2": [
{
"json": {}
}
]
},
"connections": {
"When clicking \"Execute Workflow\"": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
},
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
},
{
"node": "Merge1",
"type": "main",
"index": 0
},
{
"node": "Merge2",
"type": "main",
"index": 0
}
]
]
},
"Code1": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
},
{
"node": "Merge1",
"type": "main",
"index": 1
},
{
"node": "Merge2",
"type": "main",
"index": 1
}
]
]
}
},
"active": false,
"settings": {},
"versionId": "dc43b494-33dc-4671-9004-e5e53170732c",
"id": "107",
"meta": {
"instanceId": "36203ea1ce3cef713fa25999bd9874ae26b9e4c2c3a90a365f2882a154d031d0"
},
"tags": []
}

View file

@ -0,0 +1,486 @@
{
"name": "merge tests",
"nodes": [
{
"parameters": {},
"id": "9f880c6f-b5e0-4453-b1d7-550beb1febe8",
"name": "When clicking \"Execute Workflow\"",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [700, 660]
},
{
"parameters": {
"jsCode": "return [\n {id: 1, data: 'a', input: 1, text: 'foo'},\n {id: 2, data: 'b', input: 1, text: 'foo'},\n];"
},
"id": "263d9c7f-32d4-4112-b271-73d09b73809a",
"name": "Code",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [900, 540]
},
{
"parameters": {
"jsCode": "return [\n {id: 1, data: 'c', input: 2, tag: 'second'},\n {id: 2, data: 'd', input: 2, tag: 'second'},\n {id: 3, data: 'e', input: 2, tag: 'second'},\n];"
},
"id": "3defcf5a-ec5e-4d23-a1f6-a99b7362a241",
"name": "Code1",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [900, 780]
},
{
"parameters": {
"mode": "combine",
"mergeByFields": {
"values": [
{
"field1": "id",
"field2": "id"
}
]
},
"options": {}
},
"id": "7120cd6f-29f3-4f5b-aa25-babebd6335d3",
"name": "Merge",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1320, 140]
},
{
"parameters": {
"mode": "combine",
"mergeByFields": {
"values": [
{
"field1": "id",
"field2": "id"
}
]
},
"joinMode": "keepNonMatches",
"options": {}
},
"id": "1d6973e5-0716-4d47-85ef-298d3f86bb9d",
"name": "Merge1",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1320, 280]
},
{
"parameters": {
"mode": "combine",
"mergeByFields": {
"values": [
{
"field1": "id",
"field2": "id"
}
]
},
"joinMode": "keepEverything",
"options": {}
},
"id": "dd75b8c0-21bf-460f-9920-644a467ed356",
"name": "Merge2",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1320, 420]
},
{
"parameters": {
"mode": "combine",
"mergeByFields": {
"values": [
{
"field1": "id",
"field2": "id"
}
]
},
"joinMode": "enrichInput1",
"options": {}
},
"id": "3545877d-6e4f-437e-b91f-4c792d714e73",
"name": "Merge3",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1320, 560]
},
{
"parameters": {
"mode": "combine",
"mergeByFields": {
"values": [
{
"field1": "id",
"field2": "id"
}
]
},
"joinMode": "enrichInput2",
"options": {}
},
"id": "4b6ac099-6e6f-4e91-bcfe-74d7524fad54",
"name": "Merge4",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1320, 740]
},
{
"parameters": {
"mode": "combine",
"mergeByFields": {
"values": [
{
"field1": "id",
"field2": "id"
}
]
},
"outputDataFrom": "input1",
"options": {}
},
"id": "fb4fef36-26ea-4fc0-b6e9-a4b2781c94fa",
"name": "Merge5",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1320, 900]
},
{
"parameters": {
"mode": "combine",
"mergeByFields": {
"values": [
{
"field1": "id",
"field2": "id"
}
]
},
"outputDataFrom": "input2",
"options": {}
},
"id": "0b4fbaaa-cf0b-4da5-b35f-da3f49409965",
"name": "Merge6",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1320, 1040]
},
{
"parameters": {
"mode": "combine",
"mergeByFields": {
"values": [
{
"field1": "id",
"field2": "id"
}
]
},
"options": {
"clashHandling": {
"values": {
"resolveClash": "addSuffix"
}
}
}
},
"id": "25489a7a-74c1-48d5-a03d-1bbd2aba2abe",
"name": "Merge7",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1320, 1200]
}
],
"pinData": {
"Merge": [
{
"json": {
"id": 1,
"data": "c",
"input": 2,
"text": "foo",
"tag": "second"
}
},
{
"json": {
"id": 2,
"data": "d",
"input": 2,
"text": "foo",
"tag": "second"
}
}
],
"Merge1": [
{
"json": {
"id": 3,
"data": "e",
"input": 2,
"tag": "second",
"_source": "input2"
}
}
],
"Merge2": [
{
"json": {
"id": 1,
"data": "c",
"input": 2,
"text": "foo",
"tag": "second"
}
},
{
"json": {
"id": 2,
"data": "d",
"input": 2,
"text": "foo",
"tag": "second"
}
},
{
"json": {
"id": 3,
"data": "e",
"input": 2,
"tag": "second"
}
}
],
"Merge3": [
{
"json": {
"id": 1,
"data": "c",
"input": 2,
"text": "foo",
"tag": "second"
}
},
{
"json": {
"id": 2,
"data": "d",
"input": 2,
"text": "foo",
"tag": "second"
}
}
],
"Merge4": [
{
"json": {
"id": 1,
"data": "c",
"input": 2,
"text": "foo",
"tag": "second"
}
},
{
"json": {
"id": 2,
"data": "d",
"input": 2,
"text": "foo",
"tag": "second"
}
},
{
"json": {
"id": 3,
"data": "e",
"input": 2,
"tag": "second"
}
}
],
"Merge5": [
{
"json": {
"id": 1,
"data": "a",
"input": 1,
"text": "foo"
}
},
{
"json": {
"id": 2,
"data": "b",
"input": 1,
"text": "foo"
}
}
],
"Merge6": [
{
"json": {
"id": 1,
"data": "c",
"input": 2,
"tag": "second"
}
},
{
"json": {
"id": 2,
"data": "d",
"input": 2,
"tag": "second"
}
}
],
"Merge7": [
{
"json": {
"id_1": 1,
"data_1": "a",
"input_1": 1,
"text_1": "foo",
"id_2": 1,
"data_2": "c",
"input_2": 2,
"tag_2": "second"
}
},
{
"json": {
"id_1": 2,
"data_1": "b",
"input_1": 1,
"text_1": "foo",
"id_2": 2,
"data_2": "d",
"input_2": 2,
"tag_2": "second"
}
}
]
},
"connections": {
"When clicking \"Execute Workflow\"": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
},
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
},
{
"node": "Merge1",
"type": "main",
"index": 0
},
{
"node": "Merge2",
"type": "main",
"index": 0
},
{
"node": "Merge3",
"type": "main",
"index": 0
},
{
"node": "Merge4",
"type": "main",
"index": 0
},
{
"node": "Merge5",
"type": "main",
"index": 0
},
{
"node": "Merge6",
"type": "main",
"index": 0
},
{
"node": "Merge7",
"type": "main",
"index": 0
}
]
]
},
"Code1": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
},
{
"node": "Merge3",
"type": "main",
"index": 1
},
{
"node": "Merge2",
"type": "main",
"index": 1
},
{
"node": "Merge1",
"type": "main",
"index": 1
},
{
"node": "Merge4",
"type": "main",
"index": 1
},
{
"node": "Merge5",
"type": "main",
"index": 1
},
{
"node": "Merge6",
"type": "main",
"index": 1
},
{
"node": "Merge7",
"type": "main",
"index": 1
}
]
]
}
},
"active": false,
"settings": {},
"versionId": "8bad6701-bb00-4617-b1d5-bd24145eadaf",
"id": "107",
"meta": {
"instanceId": "36203ea1ce3cef713fa25999bd9874ae26b9e4c2c3a90a365f2882a154d031d0"
},
"tags": []
}

View file

@ -0,0 +1,219 @@
{
"name": "merge tests",
"nodes": [
{
"parameters": {},
"id": "9f880c6f-b5e0-4453-b1d7-550beb1febe8",
"name": "When clicking \"Execute Workflow\"",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [840, 360]
},
{
"parameters": {
"jsCode": "return [\n {id: 1, data: 'a', input: 1},\n {id: 2, data: 'b', input: 1},\n];"
},
"id": "263d9c7f-32d4-4112-b271-73d09b73809a",
"name": "Code",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1040, 200]
},
{
"parameters": {
"jsCode": "return [\n {id: 1, data: 'c', input: 2},\n {id: 2, data: 'd', input: 2},\n {id: 3, data: 'e', input: 2},\n];"
},
"id": "3defcf5a-ec5e-4d23-a1f6-a99b7362a241",
"name": "Code1",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1060, 520]
},
{
"parameters": {
"mode": "combine",
"combinationMode": "mergeByPosition",
"options": {
"clashHandling": {
"values": {
"resolveClash": "addSuffix"
}
}
}
},
"id": "7120cd6f-29f3-4f5b-aa25-babebd6335d3",
"name": "Merge",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1260, 200]
},
{
"parameters": {
"mode": "combine",
"combinationMode": "mergeByPosition",
"options": {
"clashHandling": {
"values": {
"resolveClash": "preferInput1"
}
}
}
},
"id": "b40fdf2e-7527-4954-84fe-464a762f8957",
"name": "Merge1",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1260, 380]
},
{
"parameters": {
"mode": "combine",
"combinationMode": "mergeByPosition",
"options": {
"clashHandling": {
"values": {
"resolveClash": "preferInput2"
}
},
"includeUnpaired": true
}
},
"id": "daca2305-691a-45c2-9010-34a9ef5a783f",
"name": "Merge2",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1260, 540]
}
],
"pinData": {
"Merge": [
{
"json": {
"id_1": 1,
"data_1": "a",
"input_1": 1,
"id_2": 1,
"data_2": "c",
"input_2": 2
}
},
{
"json": {
"id_1": 2,
"data_1": "b",
"input_1": 1,
"id_2": 2,
"data_2": "d",
"input_2": 2
}
}
],
"Merge1": [
{
"json": {
"id": 1,
"data": "a",
"input": 1
}
},
{
"json": {
"id": 2,
"data": "b",
"input": 1
}
}
],
"Merge2": [
{
"json": {
"id": 1,
"data": "c",
"input": 2
}
},
{
"json": {
"id": 2,
"data": "d",
"input": 2
}
},
{
"json": {
"id": 3,
"data": "e",
"input": 2
}
}
]
},
"connections": {
"When clicking \"Execute Workflow\"": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
},
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
},
{
"node": "Merge1",
"type": "main",
"index": 0
},
{
"node": "Merge2",
"type": "main",
"index": 0
}
]
]
},
"Code1": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
},
{
"node": "Merge1",
"type": "main",
"index": 1
},
{
"node": "Merge2",
"type": "main",
"index": 1
}
]
]
}
},
"active": false,
"settings": {},
"versionId": "c61ce62f-d995-46bb-900a-8b3edf95a858",
"id": "107",
"meta": {
"instanceId": "36203ea1ce3cef713fa25999bd9874ae26b9e4c2c3a90a365f2882a154d031d0"
},
"tags": []
}

View file

@ -0,0 +1,259 @@
{
"name": "merge tests",
"nodes": [
{
"parameters": {},
"id": "9f880c6f-b5e0-4453-b1d7-550beb1febe8",
"name": "When clicking \"Execute Workflow\"",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [820, 380]
},
{
"parameters": {
"jsCode": "return [\n {id: 1, data: 'a', input: 1},\n {id: 2, data: 'b', input: 1},\n];"
},
"id": "263d9c7f-32d4-4112-b271-73d09b73809a",
"name": "Code",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1020, 220]
},
{
"parameters": {
"jsCode": "return [\n {id: 1, data: 'c', input: 2},\n {id: 2, data: 'd', input: 2},\n];"
},
"id": "3defcf5a-ec5e-4d23-a1f6-a99b7362a241",
"name": "Code1",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [1040, 540]
},
{
"parameters": {
"mode": "combine",
"combinationMode": "multiplex",
"options": {
"clashHandling": {
"values": {
"resolveClash": "addSuffix"
}
}
}
},
"id": "7120cd6f-29f3-4f5b-aa25-babebd6335d3",
"name": "Merge",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1260, 220]
},
{
"parameters": {
"mode": "combine",
"combinationMode": "multiplex",
"options": {
"clashHandling": {
"values": {
"resolveClash": "preferInput1"
}
}
}
},
"id": "1ec4a466-432d-43f8-b6c0-3cc02cf32f6f",
"name": "Merge1",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1260, 360]
},
{
"parameters": {
"mode": "combine",
"combinationMode": "multiplex",
"options": {
"clashHandling": {
"values": {
"resolveClash": "preferInput2"
}
}
}
},
"id": "fb671be6-b476-4302-984f-0c973839581b",
"name": "Merge2",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [1260, 500]
}
],
"pinData": {
"Merge": [
{
"json": {
"id_1": 1,
"data_1": "a",
"input_1": 1,
"id_2": 1,
"data_2": "c",
"input_2": 2
}
},
{
"json": {
"id_1": 1,
"data_1": "a",
"input_1": 1,
"id_2": 2,
"data_2": "d",
"input_2": 2
}
},
{
"json": {
"id_1": 2,
"data_1": "b",
"input_1": 1,
"id_2": 1,
"data_2": "c",
"input_2": 2
}
},
{
"json": {
"id_1": 2,
"data_1": "b",
"input_1": 1,
"id_2": 2,
"data_2": "d",
"input_2": 2
}
}
],
"Merge1": [
{
"json": {
"id": 1,
"data": "a",
"input": 1
}
},
{
"json": {
"id": 2,
"data": "b",
"input": 1
}
},
{
"json": {
"id": 1,
"data": "a",
"input": 1
}
},
{
"json": {
"id": 2,
"data": "b",
"input": 1
}
}
],
"Merge2": [
{
"json": {
"id": 1,
"data": "c",
"input": 2
}
},
{
"json": {
"id": 2,
"data": "d",
"input": 2
}
},
{
"json": {
"id": 1,
"data": "c",
"input": 2
}
},
{
"json": {
"id": 2,
"data": "d",
"input": 2
}
}
]
},
"connections": {
"When clicking \"Execute Workflow\"": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
},
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
},
{
"node": "Merge1",
"type": "main",
"index": 0
},
{
"node": "Merge2",
"type": "main",
"index": 0
}
]
]
},
"Code1": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
},
{
"node": "Merge1",
"type": "main",
"index": 1
},
{
"node": "Merge2",
"type": "main",
"index": 1
}
]
]
}
},
"active": false,
"settings": {},
"versionId": "0cab5d94-90b7-4024-ad58-af9cafb46a21",
"id": "107",
"meta": {
"instanceId": "36203ea1ce3cef713fa25999bd9874ae26b9e4c2c3a90a365f2882a154d031d0"
},
"tags": []
}