mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-09 06:43:08 +00:00
fix: harden _cnd operators and add edge case tests
- Add try/catch for invalid regex patterns in regex operator - Add structure validation for between operator (from/to fields) - Add 5 new edge case tests for invalid inputs - Bump version to 2.30.1 - Resolve merge conflict with main (n8n 2.0 update) Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -216,6 +216,36 @@ describe('ConfigValidator _cnd operators', () => {
|
||||
};
|
||||
expect(ConfigValidator.isPropertyVisible(prop, { '@version': 5 })).toBe(false);
|
||||
});
|
||||
|
||||
it('should not match when between structure is null', () => {
|
||||
const prop = {
|
||||
name: 'testField',
|
||||
displayOptions: {
|
||||
show: { '@version': [{ _cnd: { between: null } }] }
|
||||
}
|
||||
};
|
||||
expect(ConfigValidator.isPropertyVisible(prop, { '@version': 4 })).toBe(false);
|
||||
});
|
||||
|
||||
it('should not match when between is missing from field', () => {
|
||||
const prop = {
|
||||
name: 'testField',
|
||||
displayOptions: {
|
||||
show: { '@version': [{ _cnd: { between: { to: 5 } } }] }
|
||||
}
|
||||
};
|
||||
expect(ConfigValidator.isPropertyVisible(prop, { '@version': 4 })).toBe(false);
|
||||
});
|
||||
|
||||
it('should not match when between is missing to field', () => {
|
||||
const prop = {
|
||||
name: 'testField',
|
||||
displayOptions: {
|
||||
show: { '@version': [{ _cnd: { between: { from: 3 } } }] }
|
||||
}
|
||||
};
|
||||
expect(ConfigValidator.isPropertyVisible(prop, { '@version': 4 })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('startsWith operator', () => {
|
||||
@@ -314,6 +344,27 @@ describe('ConfigValidator _cnd operators', () => {
|
||||
};
|
||||
expect(ConfigValidator.isPropertyVisible(prop, { id: 'abc1234' })).toBe(false);
|
||||
});
|
||||
|
||||
it('should not match when regex pattern is invalid', () => {
|
||||
const prop = {
|
||||
name: 'testField',
|
||||
displayOptions: {
|
||||
show: { id: [{ _cnd: { regex: '[invalid(regex' } }] }
|
||||
}
|
||||
};
|
||||
// Invalid regex should return false without throwing
|
||||
expect(ConfigValidator.isPropertyVisible(prop, { id: 'test' })).toBe(false);
|
||||
});
|
||||
|
||||
it('should not match non-string values', () => {
|
||||
const prop = {
|
||||
name: 'testField',
|
||||
displayOptions: {
|
||||
show: { value: [{ _cnd: { regex: '\\d+' } }] }
|
||||
}
|
||||
};
|
||||
expect(ConfigValidator.isPropertyVisible(prop, { value: 123 })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('exists operator', () => {
|
||||
|
||||
Reference in New Issue
Block a user