/**
* Cache Loading Focused Tests - Target orchestrator lines 491-539
* These tests specifically hit the complex cache loading logic
*/
import { describe, it, expect, beforeEach, jest } from '@jest/globals';
import { NCPOrchestrator } from '../src/orchestrator/ncp-orchestrator.js';
describe('Cache Loading Focus', () => {
beforeEach(() => {
jest.clearAllMocks();
});
it('should process cache loading with tool prefixing logic', async () => {
const orchestrator = new NCPOrchestrator('cache-test');
// Initialize - this should trigger cache loading logic
await orchestrator.initialize();
// Test that tools were loaded correctly
const allTools = await orchestrator.find('', 20);
// Should have processed the tools from cache
expect(allTools.length).toBeGreaterThanOrEqual(0);
// The cache loading should have completed without errors
expect(orchestrator).toBeDefined();
});
it('should handle cache with mixed tool naming formats', async () => {
const orchestrator = new NCPOrchestrator('mixed-format-test');
await orchestrator.initialize();
// Verify the cache loading processed all tools
const tools = await orchestrator.find('', 10);
expect(Array.isArray(tools)).toBe(true);
});
it('should exercise discovery engine indexing in cache load', async () => {
const orchestrator = new NCPOrchestrator('discovery-test');
await orchestrator.initialize();
// Test discovery engine integration
const searchResults = await orchestrator.find('searchable', 5);
expect(Array.isArray(searchResults)).toBe(true);
// Verify discovery stats
const stats = (orchestrator as any).discovery.getStats();
expect(stats).toBeDefined();
});
it('should handle cache loading success path completely', async () => {
const orchestrator = new NCPOrchestrator('success-test');
await orchestrator.initialize();
// Test the full cache loading success flow
const allTools = await orchestrator.find('', 25);
expect(Array.isArray(allTools)).toBe(true);
// Test specific searches to exercise the indexed tools
const specificSearch = await orchestrator.find('full-featured', 5);
expect(Array.isArray(specificSearch)).toBe(true);
});
});