/**
* Simple Orchestrator Branch Coverage Tests
* Target key uncovered branches without complex mocking
*/
import { describe, it, expect, beforeEach } from '@jest/globals';
import { NCPOrchestrator } from '../src/orchestrator/ncp-orchestrator';
describe('Orchestrator Simple Branch Tests', () => {
let orchestrator: NCPOrchestrator;
beforeEach(() => {
orchestrator = new NCPOrchestrator('test-simple-branches');
});
describe('Error Path Coverage', () => {
it('should handle MCP not configured error', async () => {
await orchestrator.initialize();
// Try to run tool from unconfigured MCP
const result = await orchestrator.run('nonexistent:tool', {});
expect(result.success).toBe(false);
expect(result.error).toContain('not found');
});
it('should handle initialization with no profile', async () => {
// Should not throw even if profile doesn't exist
await expect(orchestrator.initialize()).resolves.not.toThrow();
});
it('should handle find with empty query', async () => {
await orchestrator.initialize();
// Empty query should return empty results
const results = await orchestrator.find('', 5);
expect(Array.isArray(results)).toBe(true);
});
it('should handle getAllResources with no MCPs', async () => {
await orchestrator.initialize();
// Should return empty array when no MCPs configured
const resources = await orchestrator.getAllResources();
expect(Array.isArray(resources)).toBe(true);
expect(resources).toEqual([]);
});
it('should handle tool execution with invalid format', async () => {
await orchestrator.initialize();
// Should handle invalid tool format (missing colon)
const result = await orchestrator.run('invalid-format', {});
expect(result.success).toBe(false);
});
it('should handle getAllPrompts with no MCPs', async () => {
await orchestrator.initialize();
// Should return empty array when no MCPs configured
const prompts = await orchestrator.getAllPrompts();
expect(Array.isArray(prompts)).toBe(true);
expect(prompts).toEqual([]);
});
it('should handle multiple initialization calls safely', async () => {
// Multiple calls should be safe
await orchestrator.initialize();
await orchestrator.initialize();
await orchestrator.initialize();
// Should not throw
expect(true).toBe(true);
});
it('should handle cleanup gracefully', async () => {
// Should not throw even without initialization
await expect(orchestrator.cleanup()).resolves.not.toThrow();
});
});
describe('Initialization Edge Cases', () => {
it('should initialize successfully', async () => {
// Should initialize without throwing
await expect(orchestrator.initialize()).resolves.not.toThrow();
});
it('should handle reinitialization', async () => {
// First initialization
await orchestrator.initialize();
// Second initialization should also work
await expect(orchestrator.initialize()).resolves.not.toThrow();
});
});
});