test(companion): cover cancel wait snapshot updates

This commit is contained in:
William Valentin
2026-02-16 22:27:27 -08:00
parent 33812e3845
commit 44916fc9b2
2 changed files with 32 additions and 0 deletions
+21
View File
@@ -420,6 +420,27 @@ describe('CompanionRuntimeClient', () => {
expect(client.cancelPendingEventWaits()).toBe(0);
});
it('cancelPendingEventWaits updates pending work snapshot immediately', async () => {
const client = new CompanionRuntimeClient({
url: 'ws://127.0.0.1:1',
});
const pendingWait = client.waitForEvent('agent.stream', { timeoutMs: 10_000 }).catch(() => undefined);
expect(client.getPendingWorkSnapshot()).toEqual({
pendingRequestCount: 0,
pendingEventWaitCount: 1,
hasPendingWork: true,
});
expect(client.cancelPendingEventWaits('snapshot cancel')).toBe(1);
expect(client.getPendingWorkSnapshot()).toEqual({
pendingRequestCount: 0,
pendingEventWaitCount: 0,
hasPendingWork: false,
});
await pendingWait;
});
it('waitForEvent rejects immediately on disconnect', async () => {
const client = new CompanionRuntimeClient({
url: 'ws://127.0.0.1:1',