feat: No expression error when node hasn’t executed (#8448)

Co-authored-by: Giulio Andreini <andreini@netseven.it>
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Elias Meire
2024-02-27 10:29:16 +01:00
committed by GitHub
parent 737170893d
commit f9a99ec029
29 changed files with 2818 additions and 558 deletions

View File

@@ -11,6 +11,7 @@ import type { INodeExecutionData } from '@/Interfaces';
import { extendSyntax } from '@/Extensions/ExpressionExtension';
import { ExpressionError } from '@/errors/expression.error';
import { setDifferEnabled, setEvaluator } from '@/ExpressionEvaluatorProxy';
import { workflow } from './ExpressionExtensions/Helpers';
setDifferEnabled(true);
@@ -172,24 +173,6 @@ for (const evaluator of ['tmpl', 'tournament'] as const) {
});
describe('Test all expression value fixtures', () => {
const nodeTypes = Helpers.NodeTypes();
const workflow = new Workflow({
id: '1',
nodes: [
{
name: 'node',
typeVersion: 1,
type: 'test.set',
id: 'uuid-1234',
position: [0, 0],
parameters: {},
},
],
connections: {},
active: false,
nodeTypes,
});
const expression = workflow.expression;
const evaluate = (value: string, data: INodeExecutionData[]) => {
@@ -202,12 +185,18 @@ for (const evaluator of ['tmpl', 'tournament'] as const) {
continue;
}
test(t.expression, () => {
for (const test of t.tests.filter(
const evaluationTests = t.tests.filter(
(test) => test.type === 'evaluation',
) as ExpressionTestEvaluation[]) {
expect(
evaluate(t.expression, test.input.map((d) => ({ json: d })) as any),
).toStrictEqual(test.output);
) as ExpressionTestEvaluation[];
for (const test of evaluationTests) {
const input = test.input.map((d) => ({ json: d })) as any;
if ('error' in test) {
expect(() => evaluate(t.expression, input)).toThrowError(test.error);
} else {
expect(evaluate(t.expression, input)).toStrictEqual(test.output);
}
}
});
}