fix: update tests for template compression, pagination, and quality filtering

- Fix parameter validation tests to expect mode parameter in getTemplate calls
- Update database utils tests to use totalViews > 10 for quality filter
- Add comprehensive tests for template service functionality
- Fix integration tests for new pagination parameters

All CI tests now passing after template system enhancements
This commit is contained in:
czlonkowski
2025-09-14 15:42:35 +02:00
parent e7895d2e01
commit 3b767c798c
8 changed files with 1425 additions and 16 deletions

View File

@@ -254,7 +254,7 @@ describe('n8nDocumentationToolsFinal', () => {
discovery: ['list_nodes', 'search_nodes', 'list_ai_tools'],
configuration: ['get_node_info', 'get_node_essentials', 'get_node_documentation'],
validation: ['validate_node_operation', 'validate_workflow', 'validate_node_minimal'],
templates: ['list_tasks', 'get_node_for_task', 'search_templates'],
templates: ['list_tasks', 'get_node_for_task', 'search_templates', 'list_templates', 'get_template', 'list_node_templates'],
documentation: ['tools_documentation']
};
@@ -317,4 +317,83 @@ describe('n8nDocumentationToolsFinal', () => {
});
});
});
describe('New Template Tools', () => {
describe('list_templates', () => {
const tool = n8nDocumentationToolsFinal.find(t => t.name === 'list_templates');
it('should exist and be properly defined', () => {
expect(tool).toBeDefined();
expect(tool?.description).toContain('minimal data');
});
it('should have correct parameters', () => {
expect(tool?.inputSchema.properties).toHaveProperty('limit');
expect(tool?.inputSchema.properties).toHaveProperty('offset');
expect(tool?.inputSchema.properties).toHaveProperty('sortBy');
const limitParam = tool?.inputSchema.properties.limit;
expect(limitParam.type).toBe('number');
expect(limitParam.minimum).toBe(1);
expect(limitParam.maximum).toBe(100);
const offsetParam = tool?.inputSchema.properties.offset;
expect(offsetParam.type).toBe('number');
expect(offsetParam.minimum).toBe(0);
const sortByParam = tool?.inputSchema.properties.sortBy;
expect(sortByParam.enum).toEqual(['views', 'created_at', 'name']);
});
it('should have no required parameters', () => {
expect(tool?.inputSchema.required).toBeUndefined();
});
});
describe('get_template (enhanced)', () => {
const tool = n8nDocumentationToolsFinal.find(t => t.name === 'get_template');
it('should exist and support mode parameter', () => {
expect(tool).toBeDefined();
expect(tool?.description).toContain('mode');
});
it('should have mode parameter with correct values', () => {
expect(tool?.inputSchema.properties).toHaveProperty('mode');
const modeParam = tool?.inputSchema.properties.mode;
expect(modeParam.enum).toEqual(['nodes_only', 'structure', 'full']);
expect(modeParam.default).toBe('full');
});
it('should require templateId parameter', () => {
expect(tool?.inputSchema.required).toContain('templateId');
});
});
describe('Enhanced pagination support', () => {
const paginatedTools = ['list_node_templates', 'search_templates', 'get_templates_for_task'];
paginatedTools.forEach(toolName => {
describe(toolName, () => {
const tool = n8nDocumentationToolsFinal.find(t => t.name === toolName);
it('should support limit parameter', () => {
expect(tool?.inputSchema.properties).toHaveProperty('limit');
const limitParam = tool?.inputSchema.properties.limit;
expect(limitParam.type).toBe('number');
expect(limitParam.minimum).toBeGreaterThanOrEqual(1);
expect(limitParam.maximum).toBeGreaterThanOrEqual(50);
});
it('should support offset parameter', () => {
expect(tool?.inputSchema.properties).toHaveProperty('offset');
const offsetParam = tool?.inputSchema.properties.offset;
expect(offsetParam.type).toBe('number');
expect(offsetParam.minimum).toBe(0);
});
});
});
});
});
});