test(companion): add connection snapshot integration coverage

This commit is contained in:
William Valentin
2026-02-16 22:24:52 -08:00
parent c8f6d76638
commit 06bdb27f70
2 changed files with 54 additions and 0 deletions
+11
View File
@@ -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" "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": { "companion-runtime-wait-for-idle-nonfinite-validation-coverage": {
"status": "completed", "status": "completed",
"date": "2026-02-17", "date": "2026-02-17",
@@ -256,6 +256,49 @@ describe('platform clients integration', () => {
unsubscribe(); 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 () => { it('platform connected reflects runtime connection lifecycle', async () => {
if (!LISTEN_ALLOWED) { if (!LISTEN_ALLOWED) {
return; return;