feat(companion): add pending work snapshot helper
This commit is contained in:
@@ -643,6 +643,33 @@ describe('CompanionRuntimeClient', () => {
|
||||
expect(client.hasPendingWork).toBe(false);
|
||||
});
|
||||
|
||||
it('returns pending work snapshot', async () => {
|
||||
const client = new CompanionRuntimeClient({
|
||||
url: 'ws://127.0.0.1:1',
|
||||
});
|
||||
|
||||
expect(client.getPendingWorkSnapshot()).toEqual({
|
||||
pendingRequestCount: 0,
|
||||
pendingEventWaitCount: 0,
|
||||
hasPendingWork: false,
|
||||
});
|
||||
|
||||
const pendingWait = client.waitForEvent('agent.stream', { timeoutMs: 10_000 }).catch(() => undefined);
|
||||
expect(client.getPendingWorkSnapshot()).toEqual({
|
||||
pendingRequestCount: 0,
|
||||
pendingEventWaitCount: 1,
|
||||
hasPendingWork: true,
|
||||
});
|
||||
|
||||
client.clearEventSubscriptions();
|
||||
await pendingWait;
|
||||
expect(client.getPendingWorkSnapshot()).toEqual({
|
||||
pendingRequestCount: 0,
|
||||
pendingEventWaitCount: 0,
|
||||
hasPendingWork: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('waitForIdle resolves immediately when no work is pending', async () => {
|
||||
const client = new CompanionRuntimeClient({
|
||||
url: 'ws://127.0.0.1:1',
|
||||
|
||||
Reference in New Issue
Block a user