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
@@ -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;