test(companion): cover pending event wait count lifecycle
This commit is contained in:
@@ -131,6 +131,25 @@ describe('platform clients integration', () => {
|
||||
expect(client.eventSubscriptionCount).toBe(0);
|
||||
});
|
||||
|
||||
it('platform pendingEventWaitCount tracks waitForAnyEvent lifecycle', async () => {
|
||||
if (!LISTEN_ALLOWED) {
|
||||
return;
|
||||
}
|
||||
|
||||
const runtime = createRuntime();
|
||||
const client = new IOSCompanionClient({ runtime, nodeId: 'ios-wait-count-e2e' });
|
||||
|
||||
expect(client.pendingEventWaitCount).toBe(0);
|
||||
const awaited = expect(
|
||||
client.waitForAnyEvent(['agent.stream'], { timeoutMs: 10_000 }),
|
||||
).rejects.toThrow('Event subscriptions cleared');
|
||||
expect(client.pendingEventWaitCount).toBe(1);
|
||||
|
||||
client.clearEventSubscriptions();
|
||||
await awaited;
|
||||
expect(client.pendingEventWaitCount).toBe(0);
|
||||
});
|
||||
|
||||
it('platform connected reflects runtime connection lifecycle', async () => {
|
||||
if (!LISTEN_ALLOWED) {
|
||||
return;
|
||||
|
||||
@@ -528,10 +528,12 @@ describe('CompanionRuntimeClient', () => {
|
||||
const client = new CompanionRuntimeClient({
|
||||
url: 'ws://127.0.0.1:1',
|
||||
});
|
||||
expect(client.pendingEventWaitCount).toBe(0);
|
||||
const awaited = client.waitForAnyEvent<{ active?: boolean; token?: string }>(
|
||||
['agent.typing', 'agent.stream'],
|
||||
{ timeoutMs: 2000 },
|
||||
);
|
||||
expect(client.pendingEventWaitCount).toBe(1);
|
||||
|
||||
(client as unknown as { handleMessage: (raw: string) => void }).handleMessage(
|
||||
JSON.stringify({
|
||||
@@ -545,6 +547,7 @@ describe('CompanionRuntimeClient', () => {
|
||||
event: 'agent.typing',
|
||||
data: { active: true },
|
||||
});
|
||||
expect(client.pendingEventWaitCount).toBe(0);
|
||||
});
|
||||
|
||||
it('waitForAnyEvent supports per-event predicate filtering', async () => {
|
||||
|
||||
Reference in New Issue
Block a user