diff --git a/ui/src/ui/realtime-talk-gateway-relay.test.ts b/ui/src/ui/realtime-talk-gateway-relay.test.ts index ccdc92bb43c..486ec4be284 100644 --- a/ui/src/ui/realtime-talk-gateway-relay.test.ts +++ b/ui/src/ui/realtime-talk-gateway-relay.test.ts @@ -104,6 +104,13 @@ function pumpMicrophone(samples: Float32Array): void { }); } +function requestCallsFor( + client: RealtimeTalkTransportContext["client"], + method: string, +): Array> { + 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(() =>