mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-16 18:34:18 +00:00
test: pin realtime relay requests
This commit is contained in:
@@ -104,6 +104,13 @@ function pumpMicrophone(samples: Float32Array): void {
|
||||
});
|
||||
}
|
||||
|
||||
function requestCallsFor(
|
||||
client: RealtimeTalkTransportContext["client"],
|
||||
method: string,
|
||||
): Array<Parameters<RealtimeTalkTransportContext["client"]["request"]>> {
|
||||
return vi.mocked(client.request).mock.calls.filter((call) => call[0] === method);
|
||||
}
|
||||
|
||||
describe("GatewayRelayRealtimeTalkTransport", () => {
|
||||
beforeEach(() => {
|
||||
listeners.clear();
|
||||
@@ -209,7 +216,7 @@ describe("GatewayRelayRealtimeTalkTransport", () => {
|
||||
});
|
||||
pumpMicrophone(new Float32Array(4096));
|
||||
|
||||
expect(client.request).not.toHaveBeenCalledWith("talk.session.cancelOutput", expect.anything());
|
||||
expect(requestCallsFor(client, "talk.session.cancelOutput")).toHaveLength(0);
|
||||
const appendCall = vi
|
||||
.mocked(client.request)
|
||||
.mock.calls.find((call) => call[0] === "talk.session.appendAudio");
|
||||
@@ -334,7 +341,7 @@ describe("GatewayRelayRealtimeTalkTransport", () => {
|
||||
},
|
||||
});
|
||||
pumpMicrophone(speech);
|
||||
expect(client.request).not.toHaveBeenCalledWith("talk.session.cancelOutput", expect.anything());
|
||||
expect(requestCallsFor(client, "talk.session.cancelOutput")).toHaveLength(0);
|
||||
|
||||
pumpMicrophone(speech);
|
||||
pumpMicrophone(speech);
|
||||
@@ -435,9 +442,23 @@ describe("GatewayRelayRealtimeTalkTransport", () => {
|
||||
args: { question: "status?" },
|
||||
},
|
||||
});
|
||||
await vi.waitFor(() =>
|
||||
expect(client.request).toHaveBeenCalledWith("talk.client.toolCall", expect.anything()),
|
||||
);
|
||||
await vi.waitFor(() => {
|
||||
const toolCall = requestCallsFor(client, "talk.client.toolCall")[0];
|
||||
const params = toolCall?.[1] as
|
||||
| {
|
||||
args?: unknown;
|
||||
callId?: string;
|
||||
name?: string;
|
||||
relaySessionId?: string;
|
||||
sessionKey?: string;
|
||||
}
|
||||
| undefined;
|
||||
expect(params?.sessionKey).toBe("main");
|
||||
expect(params?.callId).toBe("call-1");
|
||||
expect(params?.name).toBe(REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME);
|
||||
expect(params?.args).toEqual({ question: "status?" });
|
||||
expect(params?.relaySessionId).toBe("relay-1");
|
||||
});
|
||||
|
||||
transport.stop();
|
||||
await vi.waitFor(() =>
|
||||
|
||||
Reference in New Issue
Block a user