mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(GraphQL Node): Fix request format JSON error (#8646)
This commit is contained in:
54
packages/nodes-base/nodes/GraphQL/test/GraphQL.node.test.ts
Normal file
54
packages/nodes-base/nodes/GraphQL/test/GraphQL.node.test.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import type { WorkflowTestData } from '@test/nodes/types';
|
||||
import { executeWorkflow } from '@test/nodes/ExecuteWorkflow';
|
||||
import * as Helpers from '@test/nodes/Helpers';
|
||||
|
||||
describe('GraphQL Node', () => {
|
||||
const mockResponse = {
|
||||
data: {
|
||||
nodes: {},
|
||||
},
|
||||
};
|
||||
|
||||
const tests: WorkflowTestData[] = [
|
||||
{
|
||||
description: 'should run Request Format JSON',
|
||||
input: {
|
||||
workflowData: Helpers.readJsonFileSync('nodes/GraphQL/test/workflow.json'),
|
||||
},
|
||||
output: {
|
||||
nodeExecutionOrder: ['Start'],
|
||||
nodeData: {
|
||||
'Fetch Request Format JSON': [
|
||||
[
|
||||
{
|
||||
json: mockResponse,
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
nock: {
|
||||
baseUrl: 'https://api.n8n.io',
|
||||
mocks: [
|
||||
{
|
||||
method: 'post',
|
||||
path: '/graphql',
|
||||
statusCode: 200,
|
||||
responseBody: mockResponse,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const nodeTypes = Helpers.setup(tests);
|
||||
|
||||
test.each(tests)('$description', async (testData) => {
|
||||
const { result } = await executeWorkflow(testData, nodeTypes);
|
||||
const resultNodeData = Helpers.getResultNodeData(result, testData);
|
||||
resultNodeData.forEach(({ nodeName, resultData }) =>
|
||||
expect(resultData).toEqual(testData.output.nodeData[nodeName]),
|
||||
);
|
||||
expect(result.finished).toEqual(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user