mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
feat(HTTP Request Node): Add additional tests for HTTP response encoding (no-changelog) (#11655)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
parent
969439ce56
commit
3814f42ada
|
@ -0,0 +1,40 @@
|
||||||
|
import nock from 'nock';
|
||||||
|
import {
|
||||||
|
setup,
|
||||||
|
equalityTest,
|
||||||
|
workflowToTests,
|
||||||
|
getWorkflowFilenames,
|
||||||
|
initBinaryDataService,
|
||||||
|
} from '@test/nodes/Helpers';
|
||||||
|
|
||||||
|
describe('Test Quoted Response Encoding', () => {
|
||||||
|
const workflows = getWorkflowFilenames(__dirname);
|
||||||
|
const tests = workflowToTests(workflows);
|
||||||
|
|
||||||
|
const baseUrl = 'https://dummy.domain';
|
||||||
|
const payload = Buffer.from(
|
||||||
|
'El rápido zorro marrón salta sobre el perro perezoso. ¡Qué bello día en París! Árbol, cañón, façade.',
|
||||||
|
'latin1',
|
||||||
|
);
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await initBinaryDataService();
|
||||||
|
|
||||||
|
nock.disableNetConnect();
|
||||||
|
|
||||||
|
nock(baseUrl)
|
||||||
|
.persist()
|
||||||
|
.get('/index.html')
|
||||||
|
.reply(200, payload, { 'content-type': 'text/plain; charset="latin1"' });
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
nock.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
const nodeTypes = setup(tests);
|
||||||
|
|
||||||
|
for (const testData of tests) {
|
||||||
|
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,69 @@
|
||||||
|
{
|
||||||
|
"name": "Response Encoding Test",
|
||||||
|
"nodes": [
|
||||||
|
{
|
||||||
|
"parameters": {},
|
||||||
|
"name": "When clicking \"Execute Workflow\"",
|
||||||
|
"type": "n8n-nodes-base.manualTrigger",
|
||||||
|
"typeVersion": 1,
|
||||||
|
"position": [180, 820],
|
||||||
|
"id": "635fb102-a760-4b9e-836c-82e71bba7974"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parameters": {
|
||||||
|
"url": "https://dummy.domain/index.html",
|
||||||
|
"options": {}
|
||||||
|
},
|
||||||
|
"name": "HTTP Request (v3)",
|
||||||
|
"type": "n8n-nodes-base.httpRequest",
|
||||||
|
"typeVersion": 3,
|
||||||
|
"position": [520, 720],
|
||||||
|
"id": "eb243cfd-fbd6-41ef-935d-4ea98617355f"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"parameters": {
|
||||||
|
"url": "https://dummy.domain/index.html",
|
||||||
|
"options": {}
|
||||||
|
},
|
||||||
|
"name": "HTTP Request (v4)",
|
||||||
|
"type": "n8n-nodes-base.httpRequest",
|
||||||
|
"typeVersion": 4,
|
||||||
|
"position": [520, 920],
|
||||||
|
"id": "cc2f185d-df6a-4fa3-b7f4-29f0dbad0f9b"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"connections": {
|
||||||
|
"When clicking \"Execute Workflow\"": {
|
||||||
|
"main": [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"node": "HTTP Request (v3)",
|
||||||
|
"type": "main",
|
||||||
|
"index": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": "HTTP Request (v4)",
|
||||||
|
"type": "main",
|
||||||
|
"index": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pinData": {
|
||||||
|
"HTTP Request (v3)": [
|
||||||
|
{
|
||||||
|
"json": {
|
||||||
|
"data": "El rápido zorro marrón salta sobre el perro perezoso. ¡Qué bello día en París! Árbol, cañón, façade."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"HTTP Request (v4)": [
|
||||||
|
{
|
||||||
|
"json": {
|
||||||
|
"data": "El rápido zorro marrón salta sobre el perro perezoso. ¡Qué bello día en París! Árbol, cañón, façade."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -182,7 +182,7 @@ describe('HttpRequestV3', () => {
|
||||||
];
|
];
|
||||||
|
|
||||||
it.each(authenticationTypes)(
|
it.each(authenticationTypes)(
|
||||||
'should handle %s authentication',
|
'should handle $genericCredentialType authentication',
|
||||||
async ({ genericCredentialType, credentials, authField, authValue }) => {
|
async ({ genericCredentialType, credentials, authField, authValue }) => {
|
||||||
(executeFunctions.getInputData as jest.Mock).mockReturnValue([{ json: {} }]);
|
(executeFunctions.getInputData as jest.Mock).mockReturnValue([{ json: {} }]);
|
||||||
(executeFunctions.getNodeParameter as jest.Mock).mockImplementation((paramName: string) => {
|
(executeFunctions.getNodeParameter as jest.Mock).mockImplementation((paramName: string) => {
|
||||||
|
|
Loading…
Reference in a new issue