mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor: Overhaul nodes-testing setup - Part 3 (no-changelog) (#14967)
This commit is contained in:
committed by
GitHub
parent
3e43f9f8bc
commit
979f9e6327
@@ -1,16 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/no-loop-func */
|
||||
import type { IDataObject, WorkflowTestData } from 'n8n-workflow';
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import type { WorkflowTestData } from 'n8n-workflow';
|
||||
import os from 'node:os';
|
||||
import path from 'path';
|
||||
|
||||
import { executeWorkflow } from '@test/nodes/ExecuteWorkflow';
|
||||
import { getResultNodeData, readJsonFileSync } from '@test/nodes/Helpers';
|
||||
|
||||
if (os.platform() !== 'win32') {
|
||||
describe('Execute Compression Node', () => {
|
||||
const workflowData = readJsonFileSync('nodes/Compression/test/node/workflow.compression.json');
|
||||
const testHarness = new NodeTestHarness();
|
||||
const workflowData = testHarness.readWorkflowJSON('workflow.compression.json');
|
||||
|
||||
const node = workflowData.nodes.find((n: IDataObject) => n.name === 'Read Binary File');
|
||||
const node = workflowData.nodes.find((n) => n.name === 'Read Binary File')!;
|
||||
node.parameters.filePath = path.join(__dirname, 'lorem.txt');
|
||||
|
||||
const tests: WorkflowTestData[] = [
|
||||
@@ -20,6 +18,7 @@ if (os.platform() !== 'win32') {
|
||||
workflowData,
|
||||
},
|
||||
output: {
|
||||
assertBinaryData: true,
|
||||
nodeData: {
|
||||
Compression1: [
|
||||
[
|
||||
@@ -44,16 +43,7 @@ if (os.platform() !== 'win32') {
|
||||
];
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => {
|
||||
const { result } = await executeWorkflow(testData);
|
||||
|
||||
const resultNodeData = getResultNodeData(result, testData);
|
||||
resultNodeData.forEach(({ nodeName, resultData }) => {
|
||||
expect(resultData).toEqual(testData.output.nodeData[nodeName]);
|
||||
});
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
});
|
||||
testHarness.setupTest(testData);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user