import { describe, expect, it } from 'vitest'; import { RealtimeEventHub, type RealtimeEvent } from '../src/web/events/index.js'; import { LogBroadcaster } from '../src/web/log-broadcaster.js'; describe('LogBroadcaster realtime bridge', () => { it('publishes each log through the typed event hub', () => { const hub = new RealtimeEventHub({ capacity: 10 }); const received: RealtimeEvent[] = []; hub.subscribe((event) => received.push(event)); const broadcaster = new LogBroadcaster(hub); broadcaster.push('warn', 'Connection is stale', { attempts: 2 }); expect(received).toEqual([ expect.objectContaining({ type: 'log.created', payload: { level: 'warn', message: 'Connection is stale', data: { attempts: 2 }, }, }), ]); }); });