refactor: Overhaul nodes-testing setup - Part 1 (no-changelog) (#14303)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2025-04-01 10:15:13 +02:00
committed by GitHub
parent f85b851851
commit 73e8d76e13
165 changed files with 3397 additions and 6453 deletions

View File

@@ -0,0 +1,44 @@
import type { WorkflowTestData } from 'n8n-workflow';
import nock from 'nock';
import { executeWorkflow } from '@test/nodes/ExecuteWorkflow';
import * as Helpers from '@test/nodes/Helpers';
const records = [
{
id: 'rec2BWBoyS5QsS7pT',
createdTime: '2022-08-25T08:22:34.000Z',
fields: {
name: 'Tim',
email: 'tim@email.com',
},
},
];
describe('Execute Airtable Node', () => {
beforeEach(() => {
nock('https://api.airtable.com/v0')
.get('/appIaXXdDqS5ORr4V/tbljyBEdYzCPF0NDh?pageSize=100')
.reply(200, { records });
});
const tests: WorkflowTestData[] = [
{
description: 'List Airtable Records',
input: {
workflowData: Helpers.readJsonFileSync('nodes/Airtable/test/workflow.json'),
},
output: {
nodeData: {
Airtable: [[...records.map((r) => ({ json: r }))]],
},
},
},
];
for (const testData of tests) {
test(testData.description, async () => {
await executeWorkflow(testData);
});
}
});

View File

@@ -0,0 +1,57 @@
{
"meta": {
"instanceId": "104a4d08d8897b8bdeb38aaca515021075e0bd8544c983c2bb8c86e6a8e6081c"
},
"nodes": [
{
"parameters": {},
"id": "f857c37f-36c1-4c9c-9b5f-f6ef49db67e3",
"name": "On clicking 'execute'",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [820, 380]
},
{
"parameters": {
"operation": "list",
"application": {
"__rl": true,
"value": "https://airtable.com/appIaXXdDqS5ORr4V/tbljyBEdYzCPF0NDh/viwInsMdsxffad0aU",
"mode": "url",
"__regex": "https://airtable.com/([a-zA-Z0-9]{2,})"
},
"table": {
"__rl": true,
"value": "https://airtable.com/appIaXXdDqS5ORr4V/tbljyBEdYzCPF0NDh/viwInsMdsxffad0aU",
"mode": "url",
"__regex": "https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"
},
"additionalOptions": {}
},
"id": "5654d3b3-fe83-4988-889b-94f107d41807",
"name": "Airtable",
"type": "n8n-nodes-base.airtable",
"typeVersion": 1,
"position": [1020, 380],
"credentials": {
"airtableApi": {
"id": "20",
"name": "Airtable account"
}
}
}
],
"connections": {
"On clicking 'execute'": {
"main": [
[
{
"node": "Airtable",
"type": "main",
"index": 0
}
]
]
}
}
}