import { WebSocketClient } from '@/lib/websocket/client' import { WebSocketMessage } from '@/lib/websocket/types' describe('E2E: Real-time WebSocket Sync', () => { it('should initialize clients', () => { const client = new WebSocketClient('ws://localhost:3011') expect(client.getClientId()).toBeDefined() expect(client.isConnected()).toBe(false) client.disconnect() }) it('should queue messages when offline', () => { const client = new WebSocketClient('ws://localhost:3011') client.send('highlight:create', { verseId: 'v-1', color: 'yellow' }) client.send('highlight:update', { id: 'h-1', color: 'blue' }) expect(client.getQueueLength()).toBe(2) client.disconnect() }) it('should handle multiple message types', () => { const client = new WebSocketClient('ws://localhost:3011') const messages: string[] = [] client.on('message', (msg: WebSocketMessage) => { messages.push(msg.type) }) client.send('highlight:create', { verseId: 'v-1', color: 'yellow' }) client.send('highlight:update', { id: 'h-1', color: 'blue' }) client.send('highlight:delete', { highlightId: 'h-1' }) expect(client.getQueueLength()).toBe(3) client.disconnect() }) })