feat(companion): add typed wait helpers for stream events
This commit is contained in:
@@ -321,6 +321,40 @@ describe('CompanionRuntimeClient', () => {
|
||||
await awaited;
|
||||
});
|
||||
|
||||
it('waitForAgentStream resolves on agent.stream events', async () => {
|
||||
const client = new CompanionRuntimeClient({
|
||||
url: 'ws://127.0.0.1:1',
|
||||
});
|
||||
|
||||
const awaited = client.waitForAgentStream<{ token: string }>({ timeoutMs: 2000 });
|
||||
(client as unknown as { handleMessage: (raw: string) => void }).handleMessage(
|
||||
JSON.stringify({
|
||||
id: 54,
|
||||
event: 'agent.stream',
|
||||
data: { token: 'typed-stream' },
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(awaited).resolves.toEqual({ token: 'typed-stream' });
|
||||
});
|
||||
|
||||
it('waitForAgentTyping resolves on agent.typing events', async () => {
|
||||
const client = new CompanionRuntimeClient({
|
||||
url: 'ws://127.0.0.1:1',
|
||||
});
|
||||
|
||||
const awaited = client.waitForAgentTyping<{ active: boolean }>({ timeoutMs: 2000 });
|
||||
(client as unknown as { handleMessage: (raw: string) => void }).handleMessage(
|
||||
JSON.stringify({
|
||||
id: 55,
|
||||
event: 'agent.typing',
|
||||
data: { active: true },
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(awaited).resolves.toEqual({ active: true });
|
||||
});
|
||||
|
||||
it('connects and performs node registration + capability discovery', async () => {
|
||||
if (!LISTEN_ALLOWED) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user