Files
Profa f13eb30ce1 feat(edge): Phase 4 P2P integration with Edge Server
Phase 4 Implementation:
- SignalingServer: WebSocket server for WebRTC peer discovery
- AgentSpawnAPI: REST API for spawning QE agents from dashboard
- EdgeServer: Combined HTTP + WebSocket server entry point

CLI Enhancements:
- Added `aqe agent spawn <type>` command with task execution
- Added `aqe agent list` to view spawned agents
- Agent state persists to .agentic-qe/agents/ directory

P2PService Fixes (from brutal honesty review):
- Integrated real SignalingClient for WebRTC signaling
- Added RTCPeerConnection management with ICE handling
- Replaced mock connection with actual WebRTC setup
- Fixed PatternCategory enum mapping

Dashboard Fixes:
- Added error state display instead of silent failures
- Shows red error banner when agent spawn fails

Tests:
- AgentSpawnAPI.test.ts (17 tests)
- SignalingServer.test.ts (7 tests)
- Webapp component tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 13:06:48 +00:00

83 lines
1.9 KiB
TypeScript

/**
* Webapp Test Setup
*
* Setup file for React component and hook tests.
* Configures testing-library and mocks browser APIs.
*
* @module tests/edge/webapp/setup
*/
import '@testing-library/jest-dom';
// Re-export mock helpers from the __mocks__ folder for test convenience
export {
mockServiceInstance,
__test__,
resetP2PService
} from '../../../src/edge/webapp/services/__mocks__/P2PService';
// Mock IntersectionObserver
class MockIntersectionObserver {
observe = jest.fn();
unobserve = jest.fn();
disconnect = jest.fn();
}
global.IntersectionObserver = MockIntersectionObserver as any;
// Mock ResizeObserver
class MockResizeObserver {
observe = jest.fn();
unobserve = jest.fn();
disconnect = jest.fn();
}
global.ResizeObserver = MockResizeObserver as any;
// Mock matchMedia
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(),
removeListener: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});
// Mock crypto for generateAgentId
Object.defineProperty(global, 'crypto', {
value: {
getRandomValues: (arr: Uint8Array) => {
for (let i = 0; i < arr.length; i++) {
arr[i] = Math.floor(Math.random() * 256);
}
return arr;
},
},
});
// Mock performance.memory (Chrome-specific)
Object.defineProperty(performance, 'memory', {
value: {
usedJSHeapSize: 50 * 1024 * 1024,
totalJSHeapSize: 100 * 1024 * 1024,
jsHeapSizeLimit: 2 * 1024 * 1024 * 1024,
},
writable: true,
});
// Suppress console.log during tests
// Uncomment if you want to suppress logs
// jest.spyOn(console, 'log').mockImplementation(() => {});
// jest.spyOn(console, 'error').mockImplementation(() => {});
// Clean up after each test
afterEach(() => {
jest.clearAllMocks();
});