Skip to main content
Glama

Debugg AI MCP

Official
by debugg-ai
tunnelManager.test.tsโ€ข4.36 kB
/** * Tests for Tunnel Manager Auto-Shutoff functionality */ import { tunnelManager } from '../../services/ngrok/tunnelManager.js'; describe('Tunnel Manager Auto-Shutoff', () => { describe('URL Detection', () => { test('should detect tunnel URLs correctly', () => { const testCases = [ { url: 'https://abc-123-def.ngrok.debugg.ai', expected: true }, { url: 'https://tunnel-id.ngrok.debugg.ai/path', expected: true }, { url: 'http://localhost:3000', expected: false }, { url: 'https://example.com', expected: false } ]; testCases.forEach(({ url, expected }) => { expect(tunnelManager.isTunnelUrl(url)).toBe(expected); }); }); test('should extract tunnel IDs correctly', () => { const testCases = [ { url: 'https://abc-123-def.ngrok.debugg.ai', expected: 'abc-123-def' }, { url: 'https://tunnel-id.ngrok.debugg.ai/api/status', expected: 'tunnel-id' }, { url: 'http://localhost:3000', expected: null }, { url: 'https://example.com', expected: null } ]; testCases.forEach(({ url, expected }) => { expect(tunnelManager.extractTunnelId(url)).toBe(expected); }); }); }); describe('Timer Management', () => { test('should handle tunnel touch operations', () => { // Test touching non-existent tunnel (should not throw) expect(() => { tunnelManager.touchTunnel('non-existent'); }).not.toThrow(); expect(() => { tunnelManager.touchTunnelByUrl('https://non-existent.ngrok.debugg.ai'); }).not.toThrow(); }); test('should extract tunnel ID from URL for touching', () => { // Test that touchTunnelByUrl correctly extracts tunnel ID // Since we can't easily spy on methods, we'll test the ID extraction separately const tunnelId = tunnelManager.extractTunnelId('https://test-123.ngrok.debugg.ai/path'); expect(tunnelId).toBe('test-123'); // The touch operation should not throw expect(() => { tunnelManager.touchTunnelByUrl('https://test-123.ngrok.debugg.ai/path'); }).not.toThrow(); }); }); describe('Status Information', () => { test('should return null for non-existent tunnel status', () => { const status = tunnelManager.getTunnelStatus('non-existent'); expect(status).toBeNull(); }); test('should return empty array for tunnel statuses when no tunnels', () => { const statuses = tunnelManager.getAllTunnelStatuses(); expect(statuses).toEqual([]); }); test('should return empty array for active tunnels when none exist', () => { const tunnels = tunnelManager.getActiveTunnels(); expect(tunnels).toEqual([]); }); }); describe('Auto-Shutoff Configuration', () => { test('should have correct timeout configuration', () => { // The timeout should be 60 minutes = 3,600,000 milliseconds const expectedTimeout = 60 * 60 * 1000; // We can't directly access the private property, but we can verify // the behavior through the timing calculations expect(expectedTimeout).toBe(3600000); }); }); describe('Integration Points', () => { test('should provide methods for timer reset integration', () => { // Verify the tunnel manager has the expected methods for integration expect(typeof tunnelManager.touchTunnel).toBe('function'); expect(typeof tunnelManager.touchTunnelByUrl).toBe('function'); expect(typeof tunnelManager.getTunnelStatus).toBe('function'); expect(typeof tunnelManager.getAllTunnelStatuses).toBe('function'); }); test('should handle tunnel URL processing', () => { // Test the main URL processing flow without creating actual tunnels const localhostUrl = 'http://localhost:3000'; const tunnelUrl = 'https://abc-123.ngrok.debugg.ai'; expect(tunnelManager.isTunnelUrl(localhostUrl)).toBe(false); expect(tunnelManager.isTunnelUrl(tunnelUrl)).toBe(true); expect(tunnelManager.extractTunnelId(tunnelUrl)).toBe('abc-123'); }); }); describe('Resource Management', () => { test('should provide cleanup methods', () => { expect(typeof tunnelManager.stopTunnel).toBe('function'); expect(typeof tunnelManager.stopAllTunnels).toBe('function'); }); }); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/debugg-ai/debugg-ai-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server