test(companion): add pending work snapshot integration coverage

This commit is contained in:
William Valentin
2026-02-16 21:58:03 -08:00
parent b4cef5235e
commit c2395ced75
2 changed files with 41 additions and 0 deletions
@@ -171,6 +171,36 @@ describe('platform clients integration', () => {
expect(client.hasPendingWork).toBe(false);
});
it('platform getPendingWorkSnapshot reflects waiter lifecycle', async () => {
if (!LISTEN_ALLOWED) {
return;
}
const runtime = createRuntime();
const client = new IOSCompanionClient({ runtime, nodeId: 'ios-snapshot-e2e' });
expect(client.getPendingWorkSnapshot()).toEqual({
pendingRequestCount: 0,
pendingEventWaitCount: 0,
hasPendingWork: false,
});
const pending = client.waitForAnyEvent(['agent.stream'], { timeoutMs: 10_000 }).catch(() => undefined);
expect(client.getPendingWorkSnapshot()).toEqual({
pendingRequestCount: 0,
pendingEventWaitCount: 1,
hasPendingWork: true,
});
client.clearEventSubscriptions();
await pending;
expect(client.getPendingWorkSnapshot()).toEqual({
pendingRequestCount: 0,
pendingEventWaitCount: 0,
hasPendingWork: false,
});
});
it('platform connected reflects runtime connection lifecycle', async () => {
if (!LISTEN_ALLOWED) {
return;