From c2395ced7565bb73155e41c48a82bde94dd9fc0c Mon Sep 17 00:00:00 2001 From: William Valentin Date: Mon, 16 Feb 2026 21:58:03 -0800 Subject: [PATCH] test(companion): add pending work snapshot integration coverage --- docs/plans/state.json | 11 +++++++ .../platformClients.integration.test.ts | 30 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/docs/plans/state.json b/docs/plans/state.json index 912a27d..4735f1c 100644 --- a/docs/plans/state.json +++ b/docs/plans/state.json @@ -979,6 +979,17 @@ ], "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-platform-pending-work-snapshot-integration-coverage": { + "status": "completed", + "date": "2026-02-17", + "updated": "2026-02-17", + "summary": "Added platform integration coverage for `getPendingWorkSnapshot()` across active waiter and teardown lifecycle transitions.", + "files_modified": [ + "src/companion/platformClients.integration.test.ts", + "docs/plans/state.json" + ], + "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" + }, "browser-tools-activation-clarity": { "status": "completed", "date": "2026-02-17", diff --git a/src/companion/platformClients.integration.test.ts b/src/companion/platformClients.integration.test.ts index 7aa4012..ccf98bc 100644 --- a/src/companion/platformClients.integration.test.ts +++ b/src/companion/platformClients.integration.test.ts @@ -171,6 +171,36 @@ describe('platform clients integration', () => { expect(client.hasPendingWork).toBe(false); }); + it('platform getPendingWorkSnapshot reflects waiter lifecycle', async () => { + if (!LISTEN_ALLOWED) { + return; + } + + const runtime = createRuntime(); + const client = new IOSCompanionClient({ runtime, nodeId: 'ios-snapshot-e2e' }); + + expect(client.getPendingWorkSnapshot()).toEqual({ + pendingRequestCount: 0, + pendingEventWaitCount: 0, + hasPendingWork: false, + }); + + const pending = client.waitForAnyEvent(['agent.stream'], { timeoutMs: 10_000 }).catch(() => undefined); + expect(client.getPendingWorkSnapshot()).toEqual({ + pendingRequestCount: 0, + pendingEventWaitCount: 1, + hasPendingWork: true, + }); + + client.clearEventSubscriptions(); + await pending; + expect(client.getPendingWorkSnapshot()).toEqual({ + pendingRequestCount: 0, + pendingEventWaitCount: 0, + hasPendingWork: false, + }); + }); + it('platform connected reflects runtime connection lifecycle', async () => { if (!LISTEN_ALLOWED) { return;