mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
ci: Expand ESLint to tests in BE packages (no-changelog) (#6147)
* 🔧 Adjust base ESLint config * 🔧 Adjust `lint` and `lintfix` in `nodes-base` * 🔧 Include `test` and `utils` in `nodes-base` * 📘 Convert JS tests to TS * 👕 Apply lintfixes
This commit is contained in:
@@ -6,7 +6,7 @@ describe('AugmentObject', () => {
|
||||
describe('augmentArray', () => {
|
||||
test('should work with arrays', () => {
|
||||
const originalObject = [1, 2, 3, 4, null];
|
||||
const copyOriginal = JSON.parse(JSON.stringify(originalObject));
|
||||
const copyOriginal = deepCopy(originalObject);
|
||||
|
||||
const augmentedObject = augmentArray(originalObject);
|
||||
|
||||
@@ -70,7 +70,7 @@ describe('AugmentObject', () => {
|
||||
},
|
||||
],
|
||||
};
|
||||
const copyOriginal = JSON.parse(JSON.stringify(originalObject));
|
||||
const copyOriginal = deepCopy(originalObject);
|
||||
|
||||
const augmentedObject = augmentObject(originalObject);
|
||||
|
||||
@@ -81,13 +81,13 @@ describe('AugmentObject', () => {
|
||||
|
||||
// Make sure that also array operations as push and length work as expected
|
||||
// On lower levels
|
||||
augmentedObject.a.b.c[0].a3!.b3.c3 = '033';
|
||||
expect(augmentedObject.a.b.c[0].a3!.b3.c3).toEqual('033');
|
||||
expect(originalObject.a.b.c[0].a3!.b3.c3).toEqual('03');
|
||||
augmentedObject.a.b.c[0].a3.b3.c3 = '033';
|
||||
expect(augmentedObject.a.b.c[0].a3.b3.c3).toEqual('033');
|
||||
expect(originalObject.a.b.c[0].a3.b3.c3).toEqual('03');
|
||||
|
||||
augmentedObject.a.b.c[1].a3!.b3.c3 = '133';
|
||||
expect(augmentedObject.a.b.c[1].a3!.b3.c3).toEqual('133');
|
||||
expect(originalObject.a.b.c[1].a3!.b3.c3).toEqual('13');
|
||||
augmentedObject.a.b.c[1].a3.b3.c3 = '133';
|
||||
expect(augmentedObject.a.b.c[1].a3.b3.c3).toEqual('133');
|
||||
expect(originalObject.a.b.c[1].a3.b3.c3).toEqual('13');
|
||||
|
||||
augmentedObject.a.b.c.push({
|
||||
a3: {
|
||||
@@ -203,7 +203,7 @@ describe('AugmentObject', () => {
|
||||
d: date,
|
||||
r: regexp,
|
||||
};
|
||||
const copyOriginal = JSON.parse(JSON.stringify(originalObject));
|
||||
const copyOriginal = deepCopy(originalObject);
|
||||
|
||||
const augmentedObject = augmentObject(originalObject);
|
||||
|
||||
@@ -248,30 +248,30 @@ describe('AugmentObject', () => {
|
||||
},
|
||||
aa: '1',
|
||||
};
|
||||
const copyOriginal = JSON.parse(JSON.stringify(originalObject));
|
||||
const copyOriginal = deepCopy(originalObject);
|
||||
|
||||
const augmentedObject = augmentObject(originalObject);
|
||||
|
||||
augmentedObject.a.bb = '92';
|
||||
expect(originalObject.a.bb).toEqual('2');
|
||||
expect(augmentedObject.a!.bb!).toEqual('92');
|
||||
expect(augmentedObject.a.bb).toEqual('92');
|
||||
|
||||
augmentedObject.a!.b!.cc = '93';
|
||||
augmentedObject.a.b.cc = '93';
|
||||
expect(originalObject.a.b.cc).toEqual('3');
|
||||
expect(augmentedObject.a!.b!.cc).toEqual('93');
|
||||
expect(augmentedObject.a.b.cc).toEqual('93');
|
||||
|
||||
// @ts-ignore
|
||||
augmentedObject.a!.b!.ccc = {
|
||||
augmentedObject.a.b.ccc = {
|
||||
d: '4',
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
expect(augmentedObject.a!.b!.ccc).toEqual({ d: '4' });
|
||||
expect(augmentedObject.a.b.ccc).toEqual({ d: '4' });
|
||||
|
||||
// @ts-ignore
|
||||
augmentedObject.a!.b!.ccc.d = '94';
|
||||
augmentedObject.a.b.ccc.d = '94';
|
||||
// @ts-ignore
|
||||
expect(augmentedObject.a!.b!.ccc.d).toEqual('94');
|
||||
expect(augmentedObject.a.b.ccc.d).toEqual('94');
|
||||
|
||||
expect(originalObject).toEqual(copyOriginal);
|
||||
|
||||
@@ -300,7 +300,7 @@ describe('AugmentObject', () => {
|
||||
},
|
||||
aa: '1',
|
||||
};
|
||||
const copyOriginal = JSON.parse(JSON.stringify(originalObject));
|
||||
const copyOriginal = deepCopy(originalObject);
|
||||
|
||||
const augmentedObject = augmentObject(originalObject);
|
||||
|
||||
@@ -351,7 +351,7 @@ describe('AugmentObject', () => {
|
||||
},
|
||||
aa: '1' as string | undefined,
|
||||
};
|
||||
const copyOriginal = JSON.parse(JSON.stringify(originalObject));
|
||||
const copyOriginal = deepCopy(originalObject);
|
||||
|
||||
const augmentedObject = augmentObject(originalObject);
|
||||
|
||||
@@ -423,7 +423,7 @@ describe('AugmentObject', () => {
|
||||
},
|
||||
aa: '1' as string | undefined,
|
||||
};
|
||||
const copyOriginal = JSON.parse(JSON.stringify(originalObject));
|
||||
const copyOriginal = deepCopy(originalObject);
|
||||
|
||||
const augmentedObject = augmentObject(originalObject);
|
||||
|
||||
|
||||
@@ -6,12 +6,9 @@ import { DateTime, Duration, Interval } from 'luxon';
|
||||
import { Expression } from '@/Expression';
|
||||
import { Workflow } from '@/Workflow';
|
||||
import * as Helpers from './Helpers';
|
||||
import {
|
||||
baseFixtures,
|
||||
ExpressionTestEvaluation,
|
||||
ExpressionTestTransform,
|
||||
} from './ExpressionFixtures/base';
|
||||
import { INodeExecutionData } from '@/Interfaces';
|
||||
import type { ExpressionTestEvaluation, ExpressionTestTransform } from './ExpressionFixtures/base';
|
||||
import { baseFixtures } from './ExpressionFixtures/base';
|
||||
import type { INodeExecutionData } from '@/Interfaces';
|
||||
import { extendSyntax } from '@/Extensions/ExpressionExtension';
|
||||
|
||||
describe('Expression', () => {
|
||||
@@ -88,7 +85,7 @@ describe('Expression', () => {
|
||||
|
||||
expect(evaluate('={{new Object()}}')).toEqual(new Object());
|
||||
|
||||
expect(evaluate('={{new Array()}}')).toEqual(new Array());
|
||||
expect(evaluate('={{new Array()}}')).toEqual([]);
|
||||
expect(evaluate('={{new Int8Array()}}')).toEqual(new Int8Array());
|
||||
expect(evaluate('={{new Uint8Array()}}')).toEqual(new Uint8Array());
|
||||
expect(evaluate('={{new Uint8ClampedArray()}}')).toEqual(new Uint8ClampedArray());
|
||||
|
||||
@@ -25,9 +25,7 @@ describe('Data Transformation Functions', () => {
|
||||
{ value: 6, string: '6' },
|
||||
{ value: { something: 'else' } }
|
||||
].pluck("value") }}`),
|
||||
).toEqual(
|
||||
expect.arrayContaining([1, 2, 3, 4, 5, 6, { something: 'else' }]),
|
||||
);
|
||||
).toEqual(expect.arrayContaining([1, 2, 3, 4, 5, 6, { something: 'else' }]));
|
||||
});
|
||||
|
||||
test('.pluck() should work correctly for multiple values', () => {
|
||||
@@ -50,7 +48,10 @@ describe('Data Transformation Functions', () => {
|
||||
}
|
||||
].pluck("firstName", "lastName") }}`),
|
||||
).toEqual(
|
||||
expect.arrayContaining([["John", "Doe"],["Jane", "Doe"]]),
|
||||
expect.arrayContaining([
|
||||
['John', 'Doe'],
|
||||
['Jane', 'Doe'],
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -73,7 +74,7 @@ describe('Data Transformation Functions', () => {
|
||||
{ value: 4, string: '4' },
|
||||
{ value: 5, string: '5' },
|
||||
{ value: 6, string: '6' },
|
||||
{ value: { something: 'else' } }
|
||||
{ value: { something: 'else' } },
|
||||
]),
|
||||
);
|
||||
});
|
||||
@@ -86,10 +87,8 @@ describe('Data Transformation Functions', () => {
|
||||
|
||||
test('.unique() should work on an arrays containing nulls, objects and arrays', () => {
|
||||
expect(
|
||||
evaluate(
|
||||
'={{ [1, 2, 3, "as", {}, {}, 1, 2, [1,2], "[sad]", "[sad]", null].unique() }}',
|
||||
),
|
||||
).toEqual([1, 2, 3, "as", {}, [1,2], "[sad]", null]);
|
||||
evaluate('={{ [1, 2, 3, "as", {}, {}, 1, 2, [1,2], "[sad]", "[sad]", null].unique() }}'),
|
||||
).toEqual([1, 2, 3, 'as', {}, [1, 2], '[sad]', null]);
|
||||
});
|
||||
|
||||
test('.isEmpty() should work correctly on an array', () => {
|
||||
@@ -113,7 +112,7 @@ describe('Data Transformation Functions', () => {
|
||||
evaluate(
|
||||
'={{ [{ test1: 1, test2: 2 }, { test1: 1, test3: 3 }].merge([{ test1: 2, test3: 3 }, { test4: 4 }]) }}',
|
||||
),
|
||||
).toEqual({"test1": 1, "test2": 2, "test3": 3, "test4": 4});
|
||||
).toEqual({ test1: 1, test2: 2, test3: 3, test4: 4 });
|
||||
});
|
||||
|
||||
test('.merge() should work correctly without arguments', () => {
|
||||
@@ -121,7 +120,7 @@ describe('Data Transformation Functions', () => {
|
||||
evaluate(
|
||||
'={{ [{ a: 1, some: null }, { a: 2, c: "something" }, 2, "asds", { b: 23 }, null, [1, 2]].merge() }}',
|
||||
),
|
||||
).toEqual({"a": 1, "some": null, "c": "something", "b": 23});
|
||||
).toEqual({ a: 1, some: null, c: 'something', b: 23 });
|
||||
});
|
||||
|
||||
test('.smartJoin() should work correctly on an array of objects', () => {
|
||||
@@ -175,11 +174,14 @@ describe('Data Transformation Functions', () => {
|
||||
});
|
||||
|
||||
test('.union() should work on an arrays containing nulls, objects and arrays', () => {
|
||||
expect(
|
||||
evaluate(
|
||||
'={{ [1, 2, "dd", {}, null].union([1, {}, null, 3]) }}',
|
||||
),
|
||||
).toEqual([1, 2, "dd", {}, null, 3]);
|
||||
expect(evaluate('={{ [1, 2, "dd", {}, null].union([1, {}, null, 3]) }}')).toEqual([
|
||||
1,
|
||||
2,
|
||||
'dd',
|
||||
{},
|
||||
null,
|
||||
3,
|
||||
]);
|
||||
});
|
||||
|
||||
test('.intersection() should work on an array of objects', () => {
|
||||
@@ -191,11 +193,11 @@ describe('Data Transformation Functions', () => {
|
||||
});
|
||||
|
||||
test('.intersection() should work on an arrays containing nulls, objects and arrays', () => {
|
||||
expect(
|
||||
evaluate(
|
||||
'={{ [1, 2, "dd", {}, null].intersection([1, {}, null]) }}',
|
||||
),
|
||||
).toEqual([1, {}, null]);
|
||||
expect(evaluate('={{ [1, 2, "dd", {}, null].intersection([1, {}, null]) }}')).toEqual([
|
||||
1,
|
||||
{},
|
||||
null,
|
||||
]);
|
||||
});
|
||||
|
||||
test('.difference() should work on an array of objects', () => {
|
||||
@@ -212,10 +214,8 @@ describe('Data Transformation Functions', () => {
|
||||
|
||||
test('.difference() should work on an arrays containing nulls, objects and arrays', () => {
|
||||
expect(
|
||||
evaluate(
|
||||
'={{ [1, 2, "dd", {}, null, ["a", 1]].difference([1, {}, null, ["a", 1]]) }}',
|
||||
),
|
||||
).toEqual([2, "dd"]);
|
||||
evaluate('={{ [1, 2, "dd", {}, null, ["a", 1]].difference([1, {}, null, ["a", 1]]) }}'),
|
||||
).toEqual([2, 'dd']);
|
||||
});
|
||||
|
||||
test('.compact() should work on an array', () => {
|
||||
|
||||
@@ -61,7 +61,6 @@ describe('Data Transformation Functions', () => {
|
||||
expect(evaluate('={{ DateTime.local(2023, 1, 20).extract() }}')).toEqual(3);
|
||||
});
|
||||
|
||||
|
||||
test('.format("yyyy LLL dd") should work correctly on a date', () => {
|
||||
expect(evaluate('={{ DateTime.local(2023, 1, 16).format("yyyy LLL dd") }}')).toEqual(
|
||||
'2023 Jan 16',
|
||||
@@ -74,27 +73,29 @@ describe('Data Transformation Functions', () => {
|
||||
});
|
||||
|
||||
test('.inBetween() should work on string and Date', () => {
|
||||
expect(evaluate(`={{ $now.isBetween('2023-06-23'.toDate(), '2023-06-23') }}`)).toBeDefined();
|
||||
expect(evaluate("={{ $now.isBetween('2023-06-23'.toDate(), '2023-06-23') }}")).toBeDefined();
|
||||
});
|
||||
|
||||
test('.inBetween() should work on string and DateTime', () => {
|
||||
expect(evaluate(`={{ $now.isBetween($now, '2023-06-23') }}`)).toBeDefined();
|
||||
expect(evaluate("={{ $now.isBetween($now, '2023-06-23') }}")).toBeDefined();
|
||||
});
|
||||
|
||||
test('.inBetween() should not work for invalid strings', () => {
|
||||
expect(evaluate(`={{ $now.isBetween($now, 'invalid') }}`)).toBeUndefined();
|
||||
expect(evaluate("={{ $now.isBetween($now, 'invalid') }}")).toBeUndefined();
|
||||
});
|
||||
|
||||
test('.inBetween() should not work for numbers', () => {
|
||||
expect(evaluate(`={{ $now.isBetween($now, 1) }}`)).toBeUndefined();
|
||||
expect(evaluate('={{ $now.isBetween($now, 1) }}')).toBeUndefined();
|
||||
});
|
||||
|
||||
test('.inBetween() should not work for a single argument', () => {
|
||||
expect(() => evaluate(`={{ $now.isBetween($now) }}`)).toThrow();
|
||||
expect(() => evaluate('={{ $now.isBetween($now) }}')).toThrow();
|
||||
});
|
||||
|
||||
test('.inBetween() should not work for a more than two arguments', () => {
|
||||
expect(() => evaluate(`={{ $now.isBetween($now, '2023-06-23', '2023-09-21'.toDate()) }}`)).toThrow();
|
||||
expect(() =>
|
||||
evaluate("={{ $now.isBetween($now, '2023-06-23', '2023-09-21'.toDate()) }}"),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
|
||||
/* eslint-disable n8n-local-rules/no-interpolation-in-regular-string */
|
||||
|
||||
import { extendTransform } from '@/Extensions';
|
||||
import { joinExpression, splitExpression } from '@/Extensions/ExpressionParser';
|
||||
import { evaluate } from './Helpers';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Expression, IDataObject, Workflow } from '../../src';
|
||||
import type { IDataObject } from '../../src';
|
||||
import { Expression, Workflow } from '../../src';
|
||||
import * as Helpers from '../Helpers';
|
||||
|
||||
export const TEST_TIMEZONE = 'America/New_York';
|
||||
@@ -20,7 +21,7 @@ export const workflow = new Workflow({
|
||||
nodeTypes,
|
||||
settings: {
|
||||
timezone: TEST_TIMEZONE,
|
||||
}
|
||||
},
|
||||
});
|
||||
export const expression = new Expression(workflow);
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ describe('Data Transformation Functions', () => {
|
||||
|
||||
describe('Multiple expressions', () => {
|
||||
test('Basic multiple expressions', () => {
|
||||
// eslint-disable-next-line n8n-local-rules/no-interpolation-in-regular-string
|
||||
expect(evaluate('={{ "test abc".toSnakeCase() }} you have ${{ (100).format() }}.')).toEqual(
|
||||
'test_abc you have $100.',
|
||||
);
|
||||
|
||||
@@ -37,8 +37,8 @@ describe('Data Transformation Functions', () => {
|
||||
});
|
||||
|
||||
test('.removeFieldsContaining should not work for empty string', () => {
|
||||
expect(
|
||||
() => evaluate(
|
||||
expect(() =>
|
||||
evaluate(
|
||||
'={{ ({ test1: "i exist", test2: "i should be removed", test3: "i should also be removed" }).removeFieldsContaining("") }}',
|
||||
),
|
||||
).toThrow();
|
||||
@@ -65,8 +65,8 @@ describe('Data Transformation Functions', () => {
|
||||
});
|
||||
|
||||
test('.keepFieldsContaining should not work for empty string', () => {
|
||||
expect(
|
||||
() => evaluate(
|
||||
expect(() =>
|
||||
evaluate(
|
||||
'={{ ({ test1: "i exist", test2: "i should be removed", test3: "i should also be removed" }).keepFieldsContaining("") }}',
|
||||
),
|
||||
).toThrow();
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
|
||||
import { stringExtensions } from '@/Extensions/StringExtensions';
|
||||
import { dateExtensions } from '@/Extensions/DateExtensions';
|
||||
import { evaluate } from './Helpers';
|
||||
|
||||
describe('Data Transformation Functions', () => {
|
||||
@@ -157,13 +156,29 @@ describe('Data Transformation Functions', () => {
|
||||
'={{ "I am a test with a url: https://example.net/ and I am a test with an email: test@example.org".extractUrl() }}',
|
||||
),
|
||||
).toEqual('https://example.net/');
|
||||
expect(evaluate('={{ "Check this out: https://subdomain.example.com:3000/path?q=1#hash".extractUrl() }}')).toEqual('https://subdomain.example.com:3000/path?q=1#hash');
|
||||
expect(
|
||||
evaluate(
|
||||
'={{ "Check this out: https://subdomain.example.com:3000/path?q=1#hash".extractUrl() }}',
|
||||
),
|
||||
).toEqual('https://subdomain.example.com:3000/path?q=1#hash');
|
||||
expect(evaluate('={{ "Invalid URL: http:///example.com".extractUrl() }}')).toEqual(undefined);
|
||||
expect(evaluate('={{ "Mixed content: https://www.example.com and http://www.example.org".extractUrl() }}')).toEqual('https://www.example.com');
|
||||
expect(evaluate('={{ "Text without URL: This is just a simple text".extractUrl() }}')).toEqual(undefined);
|
||||
expect(evaluate('={{ "URL with Unicode: http://www.xn--80aswg.xn--j1amh".extractUrl() }}')).toEqual('http://www.xn--80aswg.xn--j1amh');
|
||||
expect(evaluate('={{ "Localhost URL: http://localhost:8080/test?x=1".extractUrl() }}')).toEqual('http://localhost:8080/test?x=1');
|
||||
expect(evaluate('={{ "IP URL: http://192.168.1.1:8000/path?q=value#frag".extractUrl() }}')).toEqual('http://192.168.1.1:8000/path?q=value#frag');
|
||||
expect(
|
||||
evaluate(
|
||||
'={{ "Mixed content: https://www.example.com and http://www.example.org".extractUrl() }}',
|
||||
),
|
||||
).toEqual('https://www.example.com');
|
||||
expect(
|
||||
evaluate('={{ "Text without URL: This is just a simple text".extractUrl() }}'),
|
||||
).toEqual(undefined);
|
||||
expect(
|
||||
evaluate('={{ "URL with Unicode: http://www.xn--80aswg.xn--j1amh".extractUrl() }}'),
|
||||
).toEqual('http://www.xn--80aswg.xn--j1amh');
|
||||
expect(
|
||||
evaluate('={{ "Localhost URL: http://localhost:8080/test?x=1".extractUrl() }}'),
|
||||
).toEqual('http://localhost:8080/test?x=1');
|
||||
expect(
|
||||
evaluate('={{ "IP URL: http://192.168.1.1:8000/path?q=value#frag".extractUrl() }}'),
|
||||
).toEqual('http://192.168.1.1:8000/path?q=value#frag');
|
||||
});
|
||||
|
||||
test('.extractDomain should work on a string', () => {
|
||||
@@ -175,24 +190,46 @@ describe('Data Transformation Functions', () => {
|
||||
expect(evaluate('={{ "google.com".extractDomain() }}')).toEqual('google.com');
|
||||
expect(evaluate('={{ "www.example.net".extractDomain() }}')).toEqual('www.example.net');
|
||||
expect(evaluate('={{ "//example.com".extractDomain() }}')).toEqual('example.com');
|
||||
expect(evaluate('={{ "mailto:john.doe@example.com".extractDomain() }}')).toEqual('example.com');
|
||||
expect(evaluate('={{ "mailto:john.doe@example.com".extractDomain() }}')).toEqual(
|
||||
'example.com',
|
||||
);
|
||||
expect(evaluate('={{ "tel:+1-555-123-4567".extractDomain() }}')).toEqual(undefined);
|
||||
expect(evaluate('={{ "jane.doe@example.org".extractDomain() }}')).toEqual('example.org');
|
||||
expect(evaluate('={{ "name+tag@example.com".extractDomain() }}')).toEqual('example.com');
|
||||
expect(evaluate('={{ "first.last@example.co.uk".extractDomain() }}')).toEqual('example.co.uk');
|
||||
expect(evaluate('={{ "user@subdomain.example.com".extractDomain() }}')).toEqual('subdomain.example.com');
|
||||
expect(evaluate('={{ "www.example.net?test=1213".extractDomain() }}')).toEqual('www.example.net');
|
||||
expect(evaluate('={{ "first.last@example.co.uk".extractDomain() }}')).toEqual(
|
||||
'example.co.uk',
|
||||
);
|
||||
expect(evaluate('={{ "user@subdomain.example.com".extractDomain() }}')).toEqual(
|
||||
'subdomain.example.com',
|
||||
);
|
||||
expect(evaluate('={{ "www.example.net?test=1213".extractDomain() }}')).toEqual(
|
||||
'www.example.net',
|
||||
);
|
||||
expect(evaluate('={{ "www.example.net?test".extractDomain() }}')).toEqual('www.example.net');
|
||||
expect(evaluate('={{ "www.example.net#tesdt123".extractDomain() }}')).toEqual('www.example.net');
|
||||
expect(evaluate('={{ "https://www.example.net?test=1213".extractDomain() }}')).toEqual('www.example.net');
|
||||
expect(evaluate('={{ "https://www.example.net?test".extractDomain() }}')).toEqual('www.example.net');
|
||||
expect(evaluate('={{ "https://www.example.net#tesdt123".extractDomain() }}')).toEqual('www.example.net');
|
||||
expect(evaluate('={{ "www.example.net#tesdt123".extractDomain() }}')).toEqual(
|
||||
'www.example.net',
|
||||
);
|
||||
expect(evaluate('={{ "https://www.example.net?test=1213".extractDomain() }}')).toEqual(
|
||||
'www.example.net',
|
||||
);
|
||||
expect(evaluate('={{ "https://www.example.net?test".extractDomain() }}')).toEqual(
|
||||
'www.example.net',
|
||||
);
|
||||
expect(evaluate('={{ "https://www.example.net#tesdt123".extractDomain() }}')).toEqual(
|
||||
'www.example.net',
|
||||
);
|
||||
expect(evaluate('={{ "https://192.168.1.1".extractDomain() }}')).toEqual('192.168.1.1');
|
||||
expect(evaluate('={{ "http://www.xn--80aswg.xn--j1amh".extractDomain() }}')).toEqual('www.xn--80aswg.xn--j1amh');
|
||||
expect(evaluate('={{ "http://www.xn--80aswg.xn--j1amh".extractDomain() }}')).toEqual(
|
||||
'www.xn--80aswg.xn--j1amh',
|
||||
);
|
||||
expect(evaluate('={{ "https://localhost".extractDomain() }}')).toEqual('localhost');
|
||||
expect(evaluate('={{ "https://localhost?test=123".extractDomain() }}')).toEqual('localhost');
|
||||
expect(evaluate('={{ "https://www.example_with_underscore.com".extractDomain() }}')).toEqual('www.example_with_underscore.com');
|
||||
expect(evaluate('={{ "https://www.example.com:8080".extractDomain() }}')).toEqual('www.example.com');
|
||||
expect(evaluate('={{ "https://www.example_with_underscore.com".extractDomain() }}')).toEqual(
|
||||
'www.example_with_underscore.com',
|
||||
);
|
||||
expect(evaluate('={{ "https://www.example.com:8080".extractDomain() }}')).toEqual(
|
||||
'www.example.com',
|
||||
);
|
||||
expect(evaluate('={{ "https://example.space".extractDomain() }}')).toEqual('example.space');
|
||||
});
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import type {
|
||||
WorkflowExecuteMode,
|
||||
} from '@/Interfaces';
|
||||
import { ICredentials, ICredentialsHelper } from '@/Interfaces';
|
||||
import { Workflow } from '@/Workflow';
|
||||
import type { Workflow } from '@/Workflow';
|
||||
import { WorkflowDataProxy } from '@/WorkflowDataProxy';
|
||||
import { WorkflowHooks } from '@/WorkflowHooks';
|
||||
import * as NodeHelpers from '@/NodeHelpers';
|
||||
@@ -76,7 +76,7 @@ export class Credentials extends ICredentials {
|
||||
const fullData = this.getData(encryptionKey, nodeType);
|
||||
|
||||
if (fullData === null) {
|
||||
throw new Error(`No data was set.`);
|
||||
throw new Error('No data was set.');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
@@ -89,7 +89,7 @@ export class Credentials extends ICredentials {
|
||||
|
||||
getDataToSave(): ICredentialsEncrypted {
|
||||
if (this.data === undefined) {
|
||||
throw new Error(`No credentials were set to save.`);
|
||||
throw new Error('No credentials were set to save.');
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -277,7 +277,7 @@ export function getExecuteFunctions(
|
||||
return mode;
|
||||
},
|
||||
getNode: () => {
|
||||
return JSON.parse(JSON.stringify(node));
|
||||
return deepCopy(node);
|
||||
},
|
||||
getRestApiUrl: (): string => {
|
||||
return additionalData.restApiUrl;
|
||||
@@ -444,7 +444,7 @@ export function getExecuteSingleFunctions(
|
||||
return mode;
|
||||
},
|
||||
getNode: () => {
|
||||
return JSON.parse(JSON.stringify(node));
|
||||
return deepCopy(node);
|
||||
},
|
||||
getRestApiUrl: (): string => {
|
||||
return additionalData.restApiUrl;
|
||||
|
||||
@@ -5,7 +5,6 @@ import type {
|
||||
DeclarativeRestApiSettings,
|
||||
IRunExecutionData,
|
||||
INodeProperties,
|
||||
IDataObject,
|
||||
IExecuteSingleFunctions,
|
||||
IHttpRequestOptions,
|
||||
IN8nHttpFullResponse,
|
||||
@@ -34,7 +33,7 @@ const preSendFunction1 = async function (
|
||||
this: IExecuteSingleFunctions,
|
||||
requestOptions: IHttpRequestOptions,
|
||||
): Promise<IHttpRequestOptions> {
|
||||
requestOptions.headers = (requestOptions.headers || {}) as IDataObject;
|
||||
requestOptions.headers = requestOptions.headers || {};
|
||||
requestOptions.headers.addedIn = 'preSendFunction1';
|
||||
return requestOptions;
|
||||
};
|
||||
@@ -344,6 +343,7 @@ describe('RoutingNode', () => {
|
||||
type: 'string',
|
||||
routing: {
|
||||
send: {
|
||||
// eslint-disable-next-line n8n-local-rules/no-interpolation-in-regular-string
|
||||
property: '={{ `value${5+1}A` }}',
|
||||
type: 'query',
|
||||
value: '={{$value.toUpperCase()}}',
|
||||
@@ -357,6 +357,7 @@ describe('RoutingNode', () => {
|
||||
type: 'string',
|
||||
routing: {
|
||||
send: {
|
||||
// eslint-disable-next-line n8n-local-rules/no-interpolation-in-regular-string
|
||||
property: '={{ `value${6+1}B` }}',
|
||||
type: 'body',
|
||||
value: "={{$value.split(',')}}",
|
||||
|
||||
@@ -751,7 +751,7 @@ describe('Workflow', () => {
|
||||
});
|
||||
|
||||
describe('getParameterValue', () => {
|
||||
const tests: {
|
||||
const tests: Array<{
|
||||
description: string;
|
||||
input: {
|
||||
[nodeName: string]: {
|
||||
@@ -761,7 +761,7 @@ describe('Workflow', () => {
|
||||
};
|
||||
};
|
||||
output: Record<string, unknown>;
|
||||
}[] = [
|
||||
}> = [
|
||||
{
|
||||
description: 'read simple not expression value',
|
||||
input: {
|
||||
@@ -1296,7 +1296,7 @@ describe('Workflow', () => {
|
||||
const itemIndex = 0;
|
||||
const runIndex = 0;
|
||||
const connectionInputData: INodeExecutionData[] =
|
||||
runExecutionData.resultData.runData!['Node1']![0]!.data!.main[0]!;
|
||||
runExecutionData.resultData.runData.Node1[0]!.data!.main[0]!;
|
||||
|
||||
for (const parameterName of Object.keys(testData.output)) {
|
||||
const parameterValue = nodes.find((node) => node.name === activeNodeName)!.parameters[
|
||||
@@ -1451,7 +1451,7 @@ describe('Workflow', () => {
|
||||
const itemIndex = 0;
|
||||
const runIndex = 0;
|
||||
const connectionInputData: INodeExecutionData[] =
|
||||
runExecutionData.resultData.runData!['Node1']![0]!.data!.main[0]!;
|
||||
runExecutionData.resultData.runData.Node1[0]!.data!.main[0]!;
|
||||
const parameterName = 'values';
|
||||
|
||||
const parameterValue = nodes.find((node) => node.name === activeNodeName)!.parameters[
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IConnections, IExecuteData, INode, IRunExecutionData } from '@/Interfaces';
|
||||
import type { IConnections, IExecuteData, INode, IRunExecutionData } from '@/Interfaces';
|
||||
import { Workflow } from '@/Workflow';
|
||||
import { WorkflowDataProxy } from '@/WorkflowDataProxy';
|
||||
import * as Helpers from './Helpers';
|
||||
@@ -234,7 +234,7 @@ describe('WorkflowDataProxy', () => {
|
||||
data: runExecutionData.resultData.runData[nameLastNode][0].data!,
|
||||
node: nodes.find((node) => node.name === nameLastNode) as INode,
|
||||
source: {
|
||||
main: runExecutionData.resultData.runData[nameLastNode][0].source!,
|
||||
main: runExecutionData.resultData.runData[nameLastNode][0].source,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user