mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 20:00:02 +00:00
fix(core): Improve handling of disabled Set Metrics node (#17085)
This commit is contained in:
@@ -1022,6 +1022,46 @@ describe('TestRunnerService', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should throw SET_METRICS_NODE_NOT_CONFIGURED when metrics node is disabled', () => {
|
||||||
|
const workflow = mock<IWorkflowBase>({
|
||||||
|
nodes: [
|
||||||
|
{
|
||||||
|
id: 'node1',
|
||||||
|
name: 'Set Metrics',
|
||||||
|
type: EVALUATION_NODE_TYPE,
|
||||||
|
typeVersion: 1,
|
||||||
|
position: [0, 0],
|
||||||
|
disabled: true,
|
||||||
|
parameters: {
|
||||||
|
operation: 'setMetrics',
|
||||||
|
metrics: {
|
||||||
|
assignments: [
|
||||||
|
{
|
||||||
|
id: '1',
|
||||||
|
name: 'assignment1',
|
||||||
|
value: 0.95,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
connections: {},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(() => {
|
||||||
|
(testRunnerService as any).validateSetMetricsNodes(workflow);
|
||||||
|
}).toThrow(TestRunError);
|
||||||
|
|
||||||
|
try {
|
||||||
|
(testRunnerService as any).validateSetMetricsNodes(workflow);
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).toBeInstanceOf(TestRunError);
|
||||||
|
expect(error.code).toBe('SET_METRICS_NODE_NOT_CONFIGURED');
|
||||||
|
expect(error.extra).toEqual({ node_name: 'Set Metrics' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('should throw SET_METRICS_NODE_NOT_CONFIGURED when assignment has null value', () => {
|
it('should throw SET_METRICS_NODE_NOT_CONFIGURED when assignment has null value', () => {
|
||||||
const workflow = mock<IWorkflowBase>({
|
const workflow = mock<IWorkflowBase>({
|
||||||
nodes: [
|
nodes: [
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ export class TestRunnerService {
|
|||||||
|
|
||||||
const unconfiguredMetricsNode = metricsNodes.find(
|
const unconfiguredMetricsNode = metricsNodes.find(
|
||||||
(node) =>
|
(node) =>
|
||||||
|
node.disabled === true ||
|
||||||
!node.parameters ||
|
!node.parameters ||
|
||||||
!node.parameters.metrics ||
|
!node.parameters.metrics ||
|
||||||
(node.parameters.metrics as AssignmentCollectionValue).assignments?.length === 0 ||
|
(node.parameters.metrics as AssignmentCollectionValue).assignments?.length === 0 ||
|
||||||
|
|||||||
Reference in New Issue
Block a user