-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d240c9b
commit 336c8e7
Showing
1 changed file
with
84 additions
and
0 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
.../src/evaluation.ee/test-runner/__tests__/format-test-case-execution-input-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,84 @@ | ||
import { readFileSync } from 'fs'; | ||
import { mock } from 'jest-mock-extended'; | ||
import path from 'path'; | ||
|
||
import type { TestCaseRunMetadata } from '@/evaluation.ee/test-runner/test-runner.service.ee'; | ||
import { formatTestCaseExecutionInputData } from '@/evaluation.ee/test-runner/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('formatTestCaseExecutionInputData', () => { | ||
test('should format the test case execution input data correctly', () => { | ||
const data = formatTestCaseExecutionInputData( | ||
executionDataJson.resultData.runData, | ||
wfUnderTestJson, | ||
executionDataJson.resultData.runData, | ||
wfUnderTestJson, | ||
mock<TestCaseRunMetadata>({ | ||
pastExecutionId: 'exec-id', | ||
highlightedData: [], | ||
annotation: { | ||
vote: 'up', | ||
tags: [{ id: 'tag-id', name: 'tag-name' }], | ||
}, | ||
}), | ||
); | ||
|
||
// Check data have all expected properties | ||
expect(data.json).toMatchObject({ | ||
originalExecution: expect.anything(), | ||
newExecution: expect.anything(), | ||
annotations: expect.anything(), | ||
}); | ||
|
||
// Check original execution contains all the expected nodes | ||
expect(data.json.originalExecution).toHaveProperty('72256d90-3a67-4e29-b032-47df4e5768af'); | ||
expect(data.json.originalExecution).toHaveProperty('319f29bc-1dd4-4122-b223-c584752151a4'); | ||
expect(data.json.originalExecution).toHaveProperty('d2474215-63af-40a4-a51e-0ea30d762621'); | ||
|
||
// Check format of specific node data | ||
expect(data.json.originalExecution).toMatchObject({ | ||
'72256d90-3a67-4e29-b032-47df4e5768af': { | ||
nodeName: 'When clicking ‘Test workflow’', | ||
runs: [ | ||
{ | ||
executionTime: 0, | ||
rootNode: true, | ||
output: { | ||
main: [ | ||
[ | ||
{ | ||
query: 'First item', | ||
}, | ||
{ | ||
query: 'Second item', | ||
}, | ||
{ | ||
query: 'Third item', | ||
}, | ||
], | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
// Check annotations | ||
expect(data).toMatchObject({ | ||
json: { | ||
annotations: { | ||
vote: 'up', | ||
tags: [{ id: 'tag-id', name: 'tag-name' }], | ||
highlightedData: {}, | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); |