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
+11
View File
@@ -1173,6 +1173,17 @@
],
"test_status": "pnpm test:run src/companion/platformClients.integration.test.ts src/companion/platformClients.test.ts src/companion/runtimeClient.test.ts src/companion/heartbeatLoop.test.ts + pnpm typecheck passing"
},
"companion-runtime-cancel-waits-snapshot-coverage": {
"status": "completed",
"date": "2026-02-17",
"updated": "2026-02-17",
"summary": "Added runtime regression coverage proving `cancelPendingEventWaits()` immediately updates pending-work snapshots (`pendingEventWaitCount`, `hasPendingWork`).",
"files_modified": [
"src/companion/runtimeClient.test.ts",
"docs/plans/state.json"
],
"test_status": "pnpm test:run src/companion/runtimeClient.test.ts src/companion/platformClients.test.ts src/companion/heartbeatLoop.test.ts src/companion/platformClients.integration.test.ts + pnpm typecheck passing"
},
"companion-runtime-wait-for-idle-nonfinite-validation-coverage": {
"status": "completed",
"date": "2026-02-17",
+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',