test(companion): add platform waitForIdle integration coverage

This commit is contained in:
William Valentin
2026-02-16 20:56:34 -08:00
parent ed471072bb
commit a000235826
2 changed files with 32 additions and 0 deletions
@@ -150,6 +150,27 @@ describe('platform clients integration', () => {
expect(client.pendingEventWaitCount).toBe(0);
});
it('platform waitForIdle resolves after pending waiters are cleared', async () => {
if (!LISTEN_ALLOWED) {
return;
}
const runtime = createRuntime();
const client = new IOSCompanionClient({ runtime, nodeId: 'ios-wait-idle-e2e' });
const pending = client.waitForAnyEvent(['agent.stream'], { timeoutMs: 10_000 }).catch(() => undefined);
expect(client.hasPendingWork).toBe(true);
const idle = client.waitForIdle({ timeoutMs: 1_000, pollIntervalMs: 5 });
setTimeout(() => {
client.clearEventSubscriptions();
}, 20);
await expect(idle).resolves.toBeUndefined();
await pending;
expect(client.hasPendingWork).toBe(false);
});
it('platform connected reflects runtime connection lifecycle', async () => {
if (!LISTEN_ALLOWED) {
return;