feat(web): bridge logs to typed event stream

This commit is contained in:
jjbrunton committed 2026-08-08 15:00:02 +01:00
1 parent d6d29badcd
commit 9919b12aab
3 files changed
+41 -1

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
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 },
},
}),
]);
});
});