fix(editor): Correctly set condition operator when changed (#8700)

This commit is contained in:
Elias Meire 2024-02-21 14:53:42 +01:00 committed by GitHub
parent 35245694b1
commit 23a1bc40a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 9 deletions

View file

@ -12,16 +12,15 @@ describe('FilterConditions > utils', () => {
expect(
handleOperatorChange({
condition,
newOperator: getFilterOperator('number:equals'),
newOperator: getFilterOperator('number:gt'),
}),
).toEqual({
id: '1',
leftValue: 45,
rightValue: 'notANumber',
operator: {
name: 'filter.operator.equals',
operation: 'equals',
type: 'string',
operation: 'gt',
type: 'number',
},
});
});
@ -36,16 +35,15 @@ describe('FilterConditions > utils', () => {
expect(
handleOperatorChange({
condition,
newOperator: getFilterOperator('boolean:equals'),
newOperator: getFilterOperator('boolean:notEquals'),
}),
).toEqual({
id: '1',
leftValue: false,
rightValue: true,
operator: {
name: 'filter.operator.equals',
operation: 'equals',
type: 'string',
operation: 'notEquals',
type: 'boolean',
},
});
});
@ -62,7 +60,15 @@ describe('FilterConditions > utils', () => {
condition,
newOperator: getFilterOperator('boolean:equals'),
}),
).toEqual(condition);
).toEqual({
id: '1',
leftValue: '={{ $json.foo }}',
rightValue: '={{ $("nodename").foo }}',
operator: {
operation: 'equals',
type: 'boolean',
},
});
});
});
});

View file

@ -46,6 +46,13 @@ export const handleOperatorChange = ({
condition.rightValue = convertToType(condition.rightValue, newRightType);
}
condition.operator = {
type: newOperator.type,
operation: newOperator.operation,
rightType: newOperator.rightType,
singleValue: newOperator.singleValue,
};
return condition;
};