mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 21:19:43 -08:00
6d6e2488c6
Depends on: #7092 | Story: [PAY-768](https://linear.app/n8n/issue/PAY-768) This PR: - Generalizes the `IBinaryDataManager` interface. - Adjusts `Filesystem.ts` to satisfy the interface. - Sets up an S3 client stub to be filled in in the next PR. - Turns `BinaryDataManager` into an injectable service. - Adjusts the config schema and adds new validators. Note that the PR looks large but all the main changes are in `packages/core/src/binaryData`. Out of scope: - `BinaryDataManager` (now `BinaryDataService`) and `Filesystem.ts` (now `fs.client.ts`) were slightly refactored for maintainability, but fully overhauling them is **not** the focus of this PR, which is meant to clear the way for the S3 implementation. Future improvements for these two should include setting up a backwards-compatible dir structure that makes it easier to locate binary data files to delete, removing duplication, simplifying cloning methods, using integers for binary data size instead of `prettyBytes()`, writing tests for existing binary data logic, etc. --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
111 lines
2.6 KiB
TypeScript
111 lines
2.6 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-loop-func */
|
|
import * as Helpers from '@test/nodes/Helpers';
|
|
import type { WorkflowTestData } from '@test/nodes/types';
|
|
import { executeWorkflow } from '@test/nodes/ExecuteWorkflow';
|
|
import nock from 'nock';
|
|
|
|
describe('Test QuickChart Node', () => {
|
|
beforeEach(async () => {
|
|
await Helpers.initBinaryDataService();
|
|
nock.disableNetConnect();
|
|
nock('https://quickchart.io')
|
|
.persist()
|
|
.get(/chart.*/)
|
|
.reply(200, { success: true });
|
|
});
|
|
|
|
afterEach(() => {
|
|
nock.restore();
|
|
});
|
|
|
|
const workflow = Helpers.readJsonFileSync('nodes/QuickChart/test/QuickChart.workflow.json');
|
|
|
|
const tests: WorkflowTestData[] = [
|
|
{
|
|
description: 'nodes/QuickChart/test/QuickChart.workflow.json',
|
|
input: {
|
|
workflowData: workflow,
|
|
},
|
|
output: {
|
|
nodeData: {
|
|
BarChart: [
|
|
[
|
|
{
|
|
json: {
|
|
chart: {
|
|
type: 'horizontalBar',
|
|
data: {
|
|
labels: ['Q1', 'Q2', 'Q3', 'Q4'],
|
|
datasets: [
|
|
{
|
|
label: 'Free Users',
|
|
data: [50, 60, 70, 180],
|
|
backgroundColor: '#121d6d77',
|
|
borderColor: '#e81010',
|
|
type: 'horizontalBar',
|
|
},
|
|
{
|
|
label: 'Paid Users',
|
|
data: [30, 10, 14, 25],
|
|
backgroundColor: '#0c0d0d96',
|
|
borderColor: '#e81010',
|
|
type: 'horizontalBar',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
],
|
|
Doughnut: [
|
|
[
|
|
{
|
|
json: {
|
|
chart: {
|
|
type: 'doughnut',
|
|
data: {
|
|
labels: ['Q1', 'Q2', 'Q3', 'Q4'],
|
|
datasets: [
|
|
{
|
|
label: 'Free Users',
|
|
data: [50, 60, 70, 180],
|
|
backgroundColor: '#121d6d77',
|
|
borderColor: '#e81010',
|
|
type: 'doughnut',
|
|
},
|
|
{
|
|
label: 'Paid Users',
|
|
data: [30, 10, 14, 25],
|
|
backgroundColor: '#0c0d0d96',
|
|
borderColor: '#e81010',
|
|
type: 'doughnut',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
],
|
|
},
|
|
},
|
|
},
|
|
];
|
|
|
|
const nodeTypes = Helpers.setup(tests);
|
|
|
|
for (const testData of tests) {
|
|
test(testData.description, async () => {
|
|
const { result } = await executeWorkflow(testData, nodeTypes);
|
|
|
|
const resultNodeData = Helpers.getResultNodeData(result, testData);
|
|
resultNodeData.forEach(({ nodeName, resultData }) => {
|
|
delete resultData[0]![0].binary;
|
|
expect(resultData).toEqual(testData.output.nodeData[nodeName]);
|
|
});
|
|
expect(result.finished).toEqual(true);
|
|
});
|
|
}
|
|
});
|