Skip to content

Commit c3a4192

Browse files
committed
test: pin LiveDataManager stale-registration dispose guard
https://claude.ai/code/session_01KuiTyhDAEWtQX9oTKGatzN
1 parent d888328 commit c3a4192

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

test/service/liveData.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,21 @@ describe('liveDataManager', () => {
383383
expect(manager.appendData({ x: 'C', y: 3 })).toBe(false);
384384
});
385385

386+
test('disposing a stale registration does not evict a newer one for the same id', () => {
387+
const first = jest.fn();
388+
const second = jest.fn();
389+
const staleDisposable = manager.register(createBarMaidr(), first);
390+
manager.register(createBarMaidr(), second);
391+
392+
// Disposing the replaced (stale) registration must not unregister the
393+
// chart: the listener-identity guard keeps the newer registration alive.
394+
staleDisposable.dispose();
395+
396+
expect(manager.setData(createBarMaidr())).toBe(true);
397+
expect(second).toHaveBeenCalledTimes(1);
398+
expect(first).not.toHaveBeenCalled();
399+
});
400+
386401
test('register returns a disposable that unregisters the chart', () => {
387402
const initial = createBarMaidr();
388403
const listener = jest.fn();

0 commit comments

Comments
 (0)