diff --git a/docs/plans/state.json b/docs/plans/state.json index c2596bc..ca7a911 100644 --- a/docs/plans/state.json +++ b/docs/plans/state.json @@ -1135,6 +1135,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-platform-connection-snapshot-integration-coverage": { + "status": "completed", + "date": "2026-02-17", + "updated": "2026-02-17", + "summary": "Added platform integration coverage for `getConnectionSnapshot()` across idle, active waiter/subscription, and cleared-teardown states.", + "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" + }, "companion-runtime-wait-for-idle-nonfinite-validation-coverage": { "status": "completed", "date": "2026-02-17", diff --git a/src/companion/platformClients.integration.test.ts b/src/companion/platformClients.integration.test.ts index c018296..cd565e0 100644 --- a/src/companion/platformClients.integration.test.ts +++ b/src/companion/platformClients.integration.test.ts @@ -256,6 +256,49 @@ describe('platform clients integration', () => { unsubscribe(); }); + it('platform getConnectionSnapshot reflects connection and activity state', async () => { + if (!LISTEN_ALLOWED) { + return; + } + + const runtime = createRuntime(); + const client = new IOSCompanionClient({ runtime, nodeId: 'ios-connection-snapshot-e2e' }); + + expect(client.getConnectionSnapshot()).toEqual({ + connected: false, + eventSubscriptionCount: 0, + pendingRequestCount: 0, + pendingEventWaitCount: 0, + hasPendingWork: false, + idle: true, + }); + + const unsubscribe = client.subscribeEvents(() => undefined); + const pending = client.waitForAnyEvent(['agent.stream'], { timeoutMs: 10_000 }).catch(() => undefined); + + expect(client.getConnectionSnapshot()).toEqual({ + connected: false, + eventSubscriptionCount: 2, + pendingRequestCount: 0, + pendingEventWaitCount: 1, + hasPendingWork: true, + idle: false, + }); + + client.clearEventSubscriptions(); + await pending; + expect(client.getConnectionSnapshot()).toEqual({ + connected: false, + eventSubscriptionCount: 0, + pendingRequestCount: 0, + pendingEventWaitCount: 0, + hasPendingWork: false, + idle: true, + }); + + unsubscribe(); + }); + it('platform connected reflects runtime connection lifecycle', async () => { if (!LISTEN_ALLOWED) { return;