mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-06 13:33:11 +00:00
feat: implement Phase 8 integration tests for system tools
Implement comprehensive integration tests for 3 system tool handlers: - handleHealthCheck (3 tests): API connectivity, version checking, feature availability - handleListAvailableTools (7 tests): Tool discovery by category, configuration status, API limitations - handleDiagnostic (9 tests): Environment checks, API status, tools availability, verbose mode All 19 tests passing against real n8n instance. Coverage: - Health check: API availability verification, version information, feature discovery - Tool listing: All categories (Workflow Management, Execution Management, System), configuration details - Diagnostics: Environment variables, API connectivity, tool availability, troubleshooting steps, verbose debug mode 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
109
tests/integration/n8n-api/system/health-check.test.ts
Normal file
109
tests/integration/n8n-api/system/health-check.test.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* Integration Tests: handleHealthCheck
|
||||
*
|
||||
* Tests API health check against a real n8n instance.
|
||||
* Covers connectivity verification and feature availability.
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { createMcpContext } from '../utils/mcp-context';
|
||||
import { InstanceContext } from '../../../../src/types/instance-context';
|
||||
import { handleHealthCheck } from '../../../../src/mcp/handlers-n8n-manager';
|
||||
|
||||
describe('Integration: handleHealthCheck', () => {
|
||||
let mcpContext: InstanceContext;
|
||||
|
||||
beforeEach(() => {
|
||||
mcpContext = createMcpContext();
|
||||
});
|
||||
|
||||
// ======================================================================
|
||||
// Successful Health Check
|
||||
// ======================================================================
|
||||
|
||||
describe('API Available', () => {
|
||||
it('should successfully check n8n API health', async () => {
|
||||
const response = await handleHealthCheck(mcpContext);
|
||||
|
||||
expect(response.success).toBe(true);
|
||||
expect(response.data).toBeDefined();
|
||||
|
||||
const data = response.data as any;
|
||||
|
||||
// Verify required fields
|
||||
expect(data).toHaveProperty('status');
|
||||
expect(data).toHaveProperty('apiUrl');
|
||||
expect(data).toHaveProperty('mcpVersion');
|
||||
|
||||
// Status should be a string (e.g., "ok", "healthy")
|
||||
if (data.status) {
|
||||
expect(typeof data.status).toBe('string');
|
||||
}
|
||||
|
||||
// API URL should match configuration
|
||||
expect(data.apiUrl).toBeDefined();
|
||||
expect(typeof data.apiUrl).toBe('string');
|
||||
|
||||
// MCP version should be defined
|
||||
expect(data.mcpVersion).toBeDefined();
|
||||
expect(typeof data.mcpVersion).toBe('string');
|
||||
});
|
||||
|
||||
it('should include feature availability information', async () => {
|
||||
const response = await handleHealthCheck(mcpContext);
|
||||
|
||||
expect(response.success).toBe(true);
|
||||
const data = response.data as any;
|
||||
|
||||
// Check for feature information
|
||||
// Note: Features may vary by n8n instance configuration
|
||||
if (data.features) {
|
||||
expect(typeof data.features).toBe('object');
|
||||
}
|
||||
|
||||
// Check for version information
|
||||
if (data.n8nVersion) {
|
||||
expect(typeof data.n8nVersion).toBe('string');
|
||||
}
|
||||
|
||||
if (data.supportedN8nVersion) {
|
||||
expect(typeof data.supportedN8nVersion).toBe('string');
|
||||
}
|
||||
|
||||
// Should include version note for AI agents
|
||||
if (data.versionNote) {
|
||||
expect(typeof data.versionNote).toBe('string');
|
||||
expect(data.versionNote).toContain('version');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ======================================================================
|
||||
// Response Format Verification
|
||||
// ======================================================================
|
||||
|
||||
describe('Response Format', () => {
|
||||
it('should return complete health check response structure', async () => {
|
||||
const response = await handleHealthCheck(mcpContext);
|
||||
|
||||
expect(response.success).toBe(true);
|
||||
expect(response.data).toBeDefined();
|
||||
|
||||
const data = response.data as any;
|
||||
|
||||
// Verify all expected fields are present
|
||||
const expectedFields = ['status', 'apiUrl', 'mcpVersion'];
|
||||
expectedFields.forEach(field => {
|
||||
expect(data).toHaveProperty(field);
|
||||
});
|
||||
|
||||
// Optional fields that may be present
|
||||
const optionalFields = ['instanceId', 'n8nVersion', 'features', 'supportedN8nVersion', 'versionNote'];
|
||||
optionalFields.forEach(field => {
|
||||
if (data[field] !== undefined) {
|
||||
expect(data[field]).not.toBeNull();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user