forked from n8n-io/n8n
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Get past execution's start and destination nodes while running…
… tests (no-changelog) (n8n-io#11983)
- Loading branch information
1 parent
e68c9da
commit b0e9085
Showing
7 changed files
with
373 additions
and
30 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
packages/cli/src/evaluation/test-runner/__tests__/create-pin-data.ee.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { readFileSync } from 'fs'; | ||
import path from 'path'; | ||
|
||
import { createPinData } from '../utils.ee'; | ||
|
||
const wfUnderTestJson = JSON.parse( | ||
readFileSync(path.join(__dirname, './mock-data/workflow.under-test.json'), { encoding: 'utf-8' }), | ||
); | ||
|
||
const executionDataJson = JSON.parse( | ||
readFileSync(path.join(__dirname, './mock-data/execution-data.json'), { encoding: 'utf-8' }), | ||
); | ||
|
||
describe('createPinData', () => { | ||
test('should create pin data from past execution data', () => { | ||
const pinData = createPinData(wfUnderTestJson, executionDataJson); | ||
|
||
expect(pinData).toEqual( | ||
expect.objectContaining({ | ||
'When clicking ‘Test workflow’': expect.anything(), | ||
}), | ||
); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
packages/cli/src/evaluation/test-runner/__tests__/get-start-node.ee.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { readFileSync } from 'fs'; | ||
import path from 'path'; | ||
|
||
import { getPastExecutionStartNode } from '../utils.ee'; | ||
|
||
const executionDataJson = JSON.parse( | ||
readFileSync(path.join(__dirname, './mock-data/execution-data.json'), { encoding: 'utf-8' }), | ||
); | ||
|
||
const executionDataMultipleTriggersJson = JSON.parse( | ||
readFileSync(path.join(__dirname, './mock-data/execution-data.multiple-triggers.json'), { | ||
encoding: 'utf-8', | ||
}), | ||
); | ||
|
||
const executionDataMultipleTriggersJson2 = JSON.parse( | ||
readFileSync(path.join(__dirname, './mock-data/execution-data.multiple-triggers-2.json'), { | ||
encoding: 'utf-8', | ||
}), | ||
); | ||
|
||
describe('getPastExecutionStartNode', () => { | ||
test('should return the start node of the past execution', () => { | ||
const startNode = getPastExecutionStartNode(executionDataJson); | ||
|
||
expect(startNode).toEqual('When clicking ‘Test workflow’'); | ||
}); | ||
|
||
test('should return the start node of the past execution with multiple triggers', () => { | ||
const startNode = getPastExecutionStartNode(executionDataMultipleTriggersJson); | ||
|
||
expect(startNode).toEqual('When clicking ‘Test workflow’'); | ||
}); | ||
|
||
test('should return the start node of the past execution with multiple triggers - chat trigger', () => { | ||
const startNode = getPastExecutionStartNode(executionDataMultipleTriggersJson2); | ||
|
||
expect(startNode).toEqual('When chat message received'); | ||
}); | ||
}); |
95 changes: 95 additions & 0 deletions
95
...li/src/evaluation/test-runner/__tests__/mock-data/execution-data.multiple-triggers-2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
"startData": {}, | ||
"resultData": { | ||
"runData": { | ||
"When chat message received": [ | ||
{ | ||
"startTime": 1732882447976, | ||
"executionTime": 0, | ||
"executionStatus": "success", | ||
"data": { | ||
"main": [ | ||
[ | ||
{ | ||
"json": { | ||
"sessionId": "192c5b3c0b0642d68eab1a747a59cb6e", | ||
"action": "sendMessage", | ||
"chatInput": "hey" | ||
} | ||
} | ||
] | ||
] | ||
}, | ||
"source": [null] | ||
} | ||
], | ||
"NoOp": [ | ||
{ | ||
"hints": [], | ||
"startTime": 1732882448034, | ||
"executionTime": 0, | ||
"source": [ | ||
{ | ||
"previousNode": "When clicking ‘Test workflow’" | ||
} | ||
], | ||
"executionStatus": "success", | ||
"data": { | ||
"main": [ | ||
[ | ||
{ | ||
"json": { | ||
"sessionId": "192c5b3c0b0642d68eab1a747a59cb6e", | ||
"action": "sendMessage", | ||
"chatInput": "hey" | ||
}, | ||
"pairedItem": { | ||
"item": 0 | ||
} | ||
} | ||
] | ||
] | ||
} | ||
} | ||
], | ||
"NoOp2": [ | ||
{ | ||
"hints": [], | ||
"startTime": 1732882448037, | ||
"executionTime": 0, | ||
"source": [ | ||
{ | ||
"previousNode": "NoOp" | ||
} | ||
], | ||
"executionStatus": "success", | ||
"data": { | ||
"main": [ | ||
[ | ||
{ | ||
"json": { | ||
"sessionId": "192c5b3c0b0642d68eab1a747a59cb6e", | ||
"action": "sendMessage", | ||
"chatInput": "hey" | ||
}, | ||
"pairedItem": { | ||
"item": 0 | ||
} | ||
} | ||
] | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"pinData": {}, | ||
"lastNodeExecuted": "NoOp2" | ||
}, | ||
"executionData": { | ||
"contextData": {}, | ||
"nodeExecutionStack": [], | ||
"metadata": {}, | ||
"waitingExecution": {}, | ||
"waitingExecutionSource": {} | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
.../cli/src/evaluation/test-runner/__tests__/mock-data/execution-data.multiple-triggers.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ | ||
"startData": {}, | ||
"resultData": { | ||
"runData": { | ||
"When clicking ‘Test workflow’": [ | ||
{ | ||
"hints": [], | ||
"startTime": 1732882424975, | ||
"executionTime": 0, | ||
"source": [], | ||
"executionStatus": "success", | ||
"data": { | ||
"main": [ | ||
[ | ||
{ | ||
"json": {}, | ||
"pairedItem": { | ||
"item": 0 | ||
} | ||
} | ||
] | ||
] | ||
} | ||
} | ||
], | ||
"NoOp": [ | ||
{ | ||
"hints": [], | ||
"startTime": 1732882424977, | ||
"executionTime": 1, | ||
"source": [ | ||
{ | ||
"previousNode": "When clicking ‘Test workflow’" | ||
} | ||
], | ||
"executionStatus": "success", | ||
"data": { | ||
"main": [ | ||
[ | ||
{ | ||
"json": {}, | ||
"pairedItem": { | ||
"item": 0 | ||
} | ||
} | ||
] | ||
] | ||
} | ||
} | ||
], | ||
"NoOp2": [ | ||
{ | ||
"hints": [], | ||
"startTime": 1732882424978, | ||
"executionTime": 0, | ||
"source": [ | ||
{ | ||
"previousNode": "NoOp" | ||
} | ||
], | ||
"executionStatus": "success", | ||
"data": { | ||
"main": [ | ||
[ | ||
{ | ||
"json": {}, | ||
"pairedItem": { | ||
"item": 0 | ||
} | ||
} | ||
] | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"pinData": {}, | ||
"lastNodeExecuted": "NoOp2" | ||
}, | ||
"executionData": { | ||
"contextData": {}, | ||
"nodeExecutionStack": [], | ||
"metadata": {}, | ||
"waitingExecution": {}, | ||
"waitingExecutionSource": {} | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
packages/cli/src/evaluation/test-runner/__tests__/mock-data/workflow.multiple-triggers.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"name": "Multiple Triggers Workflow", | ||
"nodes": [ | ||
{ | ||
"parameters": {}, | ||
"type": "n8n-nodes-base.manualTrigger", | ||
"typeVersion": 1, | ||
"position": [-20, -120], | ||
"id": "19562c2d-d2c8-45c8-ae0a-1b1effe29817", | ||
"name": "When clicking ‘Test workflow’" | ||
}, | ||
{ | ||
"parameters": { | ||
"options": {} | ||
}, | ||
"type": "@n8n/n8n-nodes-langchain.chatTrigger", | ||
"typeVersion": 1.1, | ||
"position": [-20, 120], | ||
"id": "9b4b833b-56f6-4099-9b7d-5e94b75a735c", | ||
"name": "When chat message received", | ||
"webhookId": "8aeccd03-d45f-48d2-a2c7-1fb8c53d2ad7" | ||
}, | ||
{ | ||
"parameters": {}, | ||
"type": "n8n-nodes-base.noOp", | ||
"typeVersion": 1, | ||
"position": [260, -20], | ||
"id": "d3ab7426-11e7-4f42-9a57-11b8de019783", | ||
"name": "NoOp" | ||
}, | ||
{ | ||
"parameters": {}, | ||
"type": "n8n-nodes-base.noOp", | ||
"typeVersion": 1, | ||
"position": [480, -20], | ||
"id": "fb73bed6-ec2a-4283-b564-c96730b94889", | ||
"name": "NoOp2" | ||
} | ||
], | ||
"connections": { | ||
"When clicking ‘Test workflow’": { | ||
"main": [ | ||
[ | ||
{ | ||
"node": "NoOp", | ||
"type": "main", | ||
"index": 0 | ||
} | ||
] | ||
] | ||
}, | ||
"When chat message received": { | ||
"main": [ | ||
[ | ||
{ | ||
"node": "NoOp", | ||
"type": "main", | ||
"index": 0 | ||
} | ||
] | ||
] | ||
}, | ||
"NoOp": { | ||
"main": [ | ||
[ | ||
{ | ||
"node": "NoOp2", | ||
"type": "main", | ||
"index": 0 | ||
} | ||
] | ||
] | ||
} | ||
}, | ||
"pinData": {} | ||
} |
Oops, something went wrong.