first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled

This commit is contained in:
2026-03-17 16:22:57 +03:30
commit 3d5eaf9445
15349 changed files with 2847338 additions and 0 deletions
@@ -0,0 +1,83 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import fsPromises from 'fs/promises';
import type { WorkflowTestData } from 'n8n-workflow';
describe('Test ReadWriteFile Node', () => {
const directory = __dirname.replace(/\\/gi, '/');
const testHarness = new NodeTestHarness();
const workflowData = testHarness.readWorkflowJSON('ReadWriteFile.workflow.json');
const readFileNode = workflowData.nodes.find((n) => n.name === 'Read from Disk')!;
readFileNode.parameters.fileSelector = `${directory}/image.jpg`;
const writeFileNode = workflowData.nodes.find((n) => n.name === 'Write to Disk')!;
writeFileNode.parameters.fileName = `${testHarness.temporaryDir}/image-written.jpg`;
const realpathSpy = jest.spyOn(fsPromises, 'realpath');
realpathSpy.mockImplementation(async (path) => path as string);
const tests: WorkflowTestData[] = [
{
description: 'nodes/Files/ReadWriteFile/test/ReadWriteFile.workflow.json',
input: {
workflowData,
},
output: {
assertBinaryData: true,
nodeData: {
'Read from Disk': [
[
{
json: {
fileExtension: 'jpg',
fileName: 'image.jpg',
fileSize: '1.04 kB',
fileType: 'image',
mimeType: 'image/jpeg',
},
binary: {
data: {
mimeType: 'image/jpeg',
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DqccDrQDpyRNPdRwEKcsx7CobIebPLORwThc0inGMF724jagNpxG4OOM1dIDAgjIPBpkqUOxnR2pmh85pW3nJB9KkNi4yqTssZ6rSNXNX0ehHFfusYDLuI7+tXY4I40ChQcdzQRKcL7Fb7PcQO32cqUY5we1XqZPtH11KsFoFDGYK7sckkZxVqgTnJlEQXMBZYGUoTkZ7VeoH7RvcqwWaIh80K7k5JIq1QJzkyhbMtvdSxMdqnlc1amgjmx5i5I70inNSVpFdrmaWRltkBVerHvUW57B2AUNGxyOaC+VW9xXLVrcGbcjrtkXqKZZxvveeTAL9APSgiooq1ty3RTMj//2Q==',
fileName: 'image.jpg',
fileSize: '1.04 kB',
},
},
},
],
],
'Write to Disk': [
[
{
json: {
fileExtension: 'jpg',
fileName: writeFileNode.parameters.fileName,
fileSize: '1.04 kB',
fileType: 'image',
mimeType: 'image/jpeg',
},
binary: {
data: {
mimeType: 'image/jpeg',
fileType: 'image',
fileExtension: 'jpg',
data: '/9j/4AAQSkZJRgABAQEASABIAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAARlJAAAD6AABGUkAAAPocGFpbnQubmV0IDUuMC4xAP/bAEMAIBYYHBgUIBwaHCQiICYwUDQwLCwwYkZKOlB0Znp4cmZwboCQuJyAiK6KbnCg2qKuvsTO0M58muLy4MjwuMrOxv/bAEMBIiQkMCowXjQ0XsaEcITGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxv/AABEIAB8AOwMBEgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/AOgqgrXF2zNHJ5aKcD3oNPZ23di/VKG82bkuTh1OMgdaAdOSLtZ6G5ut0iSeWoOAKAdO27NCqUN8oQrcHDqccDrQDpyRNPdRwEKcsx7CobIebPLORwThc0inGMF724jagNpxG4OOM1dIDAgjIPBpkqUOxnR2pmh85pW3nJB9KkNi4yqTssZ6rSNXNX0ehHFfusYDLuI7+tXY4I40ChQcdzQRKcL7Fb7PcQO32cqUY5we1XqZPtH11KsFoFDGYK7sckkZxVqgTnJlEQXMBZYGUoTkZ7VeoH7RvcqwWaIh80K7k5JIq1QJzkyhbMtvdSxMdqnlc1amgjmx5i5I70inNSVpFdrmaWRltkBVerHvUW57B2AUNGxyOaC+VW9xXLVrcGbcjrtkXqKZZxvveeTAL9APSgiooq1ty3RTMj//2Q==',
fileName: 'image.jpg',
fileSize: '1.04 kB',
},
},
},
],
],
},
},
},
];
for (const testData of tests) {
testHarness.setupTest(testData);
}
});
@@ -0,0 +1,72 @@
{
"meta": {
"instanceId": "104a4d08d8897b8bdeb38aaca515021075e0bd8544c983c2bb8c86e6a8e6081c"
},
"nodes": [
{
"parameters": {},
"id": "01b8609f-a345-41de-80bf-6d84276b5e7a",
"name": "When clicking \"Execute Workflow\"",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
700,
320
]
},
{
"parameters": {
"fileSelector": "C:/Test/image.jpg",
"options": {}
},
"id": "a1ea0fd0-cc95-4de2-bc58-bc980cb1d97e",
"name": "Read from Disk",
"type": "n8n-nodes-base.readWriteFile",
"typeVersion": 1,
"position": [
920,
320
]
},
{
"parameters": {
"operation": "write",
"fileName": "C:/Test/image-written.jpg",
"options": {}
},
"id": "94abac52-bd10-4b57-85b0-691c70989137",
"name": "Write to Disk",
"type": "n8n-nodes-base.readWriteFile",
"typeVersion": 1,
"position": [
1140,
320
]
}
],
"connections": {
"When clicking \"Execute Workflow\"": {
"main": [
[
{
"node": "Read from Disk",
"type": "main",
"index": 0
}
]
]
},
"Read from Disk": {
"main": [
[
{
"node": "Write to Disk",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

@@ -0,0 +1,43 @@
import { escapeSpecialCharacters, normalizeFileSelector } from '../helpers/utils';
describe('Read/Write Files from Disk', () => {
describe('escapeSpecialCharacters', () => {
it('should escape parentheses in a string', () => {
const input = '/home/michael/Desktop/test(1).txt';
const expectedOutput = '/home/michael/Desktop/test\\(1\\).txt';
expect(escapeSpecialCharacters(input)).toBe(expectedOutput);
});
it('should not modify strings that do not contain parentheses', () => {
const input = '/home/michael/Desktop/test.txt';
const expectedOutput = '/home/michael/Desktop/test.txt';
expect(escapeSpecialCharacters(input)).toBe(expectedOutput);
});
});
describe('normalizeFileSelector', () => {
it('should normalize UNIX file selector with parentheses', () => {
const input = '/home/michael/Desktop/test(1).txt';
const expectedOutput = '/home/michael/Desktop/test\\(1\\).txt';
expect(normalizeFileSelector(input)).toBe(expectedOutput);
});
it('should normalize Windows file selector with \\ and parentheses', () => {
const input = 'C:\\Users\\michael\\Desktop\\test(1).txt';
const expectedOutput = 'C:/Users/michael/Desktop/test\\(1\\).txt';
expect(normalizeFileSelector(input)).toBe(expectedOutput);
});
it('should normalize Windows file selector with \\\\', () => {
const input = 'C:\\\\Users\\\\michael\\\\Desktop\\\\test.txt';
const expectedOutput = 'C:/Users/michael/Desktop/test.txt';
expect(normalizeFileSelector(input)).toBe(expectedOutput);
});
it('should normalize Windows file selector with /', () => {
const input = 'C:/Users/michael/Desktop/test.txt';
const expectedOutput = 'C:/Users/michael/Desktop/test.txt';
expect(normalizeFileSelector(input)).toBe(expectedOutput);
});
});
});