mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-01-30 06:22:04 +00:00
test: fix enhanced-config-validator tests for new return type
- Update tests to handle filterPropertiesByMode returning object with properties and configWithDefaults - All tests now pass successfully
This commit is contained in:
@@ -99,15 +99,15 @@ describe('EnhancedConfigValidator', () => {
|
||||
// Mock isPropertyVisible to return true
|
||||
vi.spyOn(EnhancedConfigValidator as any, 'isPropertyVisible').mockReturnValue(true);
|
||||
|
||||
const filtered = EnhancedConfigValidator['filterPropertiesByMode'](
|
||||
const result = EnhancedConfigValidator['filterPropertiesByMode'](
|
||||
properties,
|
||||
{ resource: 'message', operation: 'send' },
|
||||
'operation',
|
||||
{ resource: 'message', operation: 'send' }
|
||||
);
|
||||
|
||||
expect(filtered).toHaveLength(1);
|
||||
expect(filtered[0].name).toBe('channel');
|
||||
expect(result.properties).toHaveLength(1);
|
||||
expect(result.properties[0].name).toBe('channel');
|
||||
});
|
||||
|
||||
it('should handle minimal validation mode', () => {
|
||||
@@ -459,7 +459,7 @@ describe('EnhancedConfigValidator', () => {
|
||||
// Remove the mock to test real implementation
|
||||
vi.restoreAllMocks();
|
||||
|
||||
const filtered = EnhancedConfigValidator['filterPropertiesByMode'](
|
||||
const result = EnhancedConfigValidator['filterPropertiesByMode'](
|
||||
properties,
|
||||
{ resource: 'message', operation: 'send' },
|
||||
'operation',
|
||||
@@ -467,9 +467,9 @@ describe('EnhancedConfigValidator', () => {
|
||||
);
|
||||
|
||||
// Should include messageChannel and sharedProperty, but not userEmail
|
||||
expect(filtered).toHaveLength(2);
|
||||
expect(filtered.map(p => p.name)).toContain('messageChannel');
|
||||
expect(filtered.map(p => p.name)).toContain('sharedProperty');
|
||||
expect(result.properties).toHaveLength(2);
|
||||
expect(result.properties.map(p => p.name)).toContain('messageChannel');
|
||||
expect(result.properties.map(p => p.name)).toContain('sharedProperty');
|
||||
});
|
||||
|
||||
it('should handle properties without displayOptions in operation mode', () => {
|
||||
@@ -487,7 +487,7 @@ describe('EnhancedConfigValidator', () => {
|
||||
|
||||
vi.restoreAllMocks();
|
||||
|
||||
const filtered = EnhancedConfigValidator['filterPropertiesByMode'](
|
||||
const result = EnhancedConfigValidator['filterPropertiesByMode'](
|
||||
properties,
|
||||
{ resource: 'user' },
|
||||
'operation',
|
||||
@@ -495,9 +495,9 @@ describe('EnhancedConfigValidator', () => {
|
||||
);
|
||||
|
||||
// Should include property without displayOptions
|
||||
expect(filtered.map(p => p.name)).toContain('alwaysVisible');
|
||||
expect(result.properties.map(p => p.name)).toContain('alwaysVisible');
|
||||
// Should not include conditionalProperty (wrong resource)
|
||||
expect(filtered.map(p => p.name)).not.toContain('conditionalProperty');
|
||||
expect(result.properties.map(p => p.name)).not.toContain('conditionalProperty');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user