test(companion): add connection snapshot integration coverage
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user