From 965267d67e2486ee78fb392670ba4b3926f3217c Mon Sep 17 00:00:00 2001 From: William Valentin Date: Mon, 16 Feb 2026 22:22:48 -0800 Subject: [PATCH] test(companion): add event surface snapshot integration coverage --- docs/plans/state.json | 11 ++++++++ .../platformClients.integration.test.ts | 28 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/docs/plans/state.json b/docs/plans/state.json index 904e87a..8a8c533 100644 --- a/docs/plans/state.json +++ b/docs/plans/state.json @@ -1108,6 +1108,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-event-surface-snapshot-integration-coverage": { + "status": "completed", + "date": "2026-02-17", + "updated": "2026-02-17", + "summary": "Added platform integration coverage for `getEventSurfaceSnapshot()` across active subscription/waiter and 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 a4d3f2e..c018296 100644 --- a/src/companion/platformClients.integration.test.ts +++ b/src/companion/platformClients.integration.test.ts @@ -228,6 +228,34 @@ describe('platform clients integration', () => { expect(client.eventSubscriptionCount).toBe(0); }); + it('platform getEventSurfaceSnapshot reflects subscription and waiter lifecycle', async () => { + if (!LISTEN_ALLOWED) { + return; + } + + const runtime = createRuntime(); + const client = new IOSCompanionClient({ runtime, nodeId: 'ios-event-snapshot-e2e' }); + + const unsubscribe = client.subscribeEvents(() => undefined); + const pending = client.waitForAnyEvent(['agent.stream'], { timeoutMs: 10_000 }).catch(() => undefined); + + expect(client.getEventSurfaceSnapshot()).toEqual({ + knownEventNames: ['agent.stream', 'agent.typing', 'context_warning'], + eventSubscriptionCount: 2, + pendingEventWaitCount: 1, + }); + + client.clearEventSubscriptions(); + await pending; + expect(client.getEventSurfaceSnapshot()).toEqual({ + knownEventNames: ['agent.stream', 'agent.typing', 'context_warning'], + eventSubscriptionCount: 0, + pendingEventWaitCount: 0, + }); + + unsubscribe(); + }); + it('platform connected reflects runtime connection lifecycle', async () => { if (!LISTEN_ALLOWED) { return;