fix(dashboard): deduplicate realtime log replay

This commit is contained in:
jjbrunton committed 2026-08-08 15:15:54 +01:00
1 parent e003b0d8b2
commit 89f7376b1b
4 files changed
+49 -9

No files matched your search

+13 -1
View File
@@ -4,12 +4,21 @@ 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 occurredAt = new Date('2026-08-08T15:00:00.000Z');
const hub = new RealtimeEventHub({
capacity: 10,
clock: { now: () => occurredAt },
});
const received: RealtimeEvent[] = [];
let recent: unknown;
hub.subscribe((event) => received.push(event));
const broadcaster = new LogBroadcaster(hub);
broadcaster.push('warn', 'Connection is stale', { attempts: 2 });
broadcaster.recent(
{ query: {} } as never,
{ json: (value: unknown) => { recent = value; } } as never,
);
expect(received).toEqual([
expect.objectContaining({
@@ -21,5 +30,8 @@ describe('LogBroadcaster realtime bridge', () => {
},
}),
]);
expect(recent).toEqual([
expect.objectContaining({ timestamp: occurredAt.getTime() }),
]);
});
});