mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +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,21 +1,18 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import { readFileSync } from 'fs';
|
||||
import type { IWorkflowBase, WorkflowTestData } from 'n8n-workflow';
|
||||
import type { WorkflowTestData } from 'n8n-workflow';
|
||||
import path from 'path';
|
||||
|
||||
import { executeWorkflow } from '@test/nodes/ExecuteWorkflow';
|
||||
import * as Helpers from '@test/nodes/Helpers';
|
||||
|
||||
describe('Execute Spreadsheet File Node', () => {
|
||||
const testHarness = new NodeTestHarness();
|
||||
const readBinaryFile = (fileName: string) =>
|
||||
readFileSync(path.resolve(__dirname, fileName), 'base64');
|
||||
|
||||
const loadWorkflow = (fileName: string, csvName: string) => {
|
||||
const workflow = Helpers.readJsonFileSync<IWorkflowBase>(
|
||||
`nodes/SpreadsheetFile/test/${fileName}`,
|
||||
);
|
||||
const node = workflow.nodes.find((n) => n.name === 'Read Binary File');
|
||||
node!.parameters.fileSelector = path.join(__dirname, csvName);
|
||||
return workflow;
|
||||
const workflowData = testHarness.readWorkflowJSON(fileName);
|
||||
const node = workflowData.nodes.find((n) => n.name === 'Read Binary File')!;
|
||||
node.parameters.fileSelector = path.join(__dirname, csvName);
|
||||
return workflowData;
|
||||
};
|
||||
|
||||
const tests: WorkflowTestData[] = [
|
||||
@@ -25,6 +22,7 @@ describe('Execute Spreadsheet File Node', () => {
|
||||
workflowData: loadWorkflow('workflow.json', 'spreadsheet.csv'),
|
||||
},
|
||||
output: {
|
||||
assertBinaryData: true,
|
||||
nodeData: {
|
||||
'Read From File': [
|
||||
[
|
||||
@@ -197,18 +195,6 @@ describe('Execute Spreadsheet File Node', () => {
|
||||
];
|
||||
|
||||
for (const testData of tests) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
||||
test(testData.description, async () => {
|
||||
// execute workflow
|
||||
const { result } = await executeWorkflow(testData);
|
||||
|
||||
// check if result node data matches expected test data
|
||||
const resultNodeData = Helpers.getResultNodeData(result, testData);
|
||||
resultNodeData.forEach(({ nodeName, resultData }) =>
|
||||
expect(resultData).toEqual(testData.output.nodeData[nodeName]),
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
});
|
||||
testHarness.setupTest(testData);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user