test: guard realtime talk consult mock call

This commit is contained in:
Peter Steinberger
2026-05-12 03:25:00 +01:00
parent 8cbb2f8027
commit c41fd134d0

View File

@@ -3,6 +3,14 @@
import { describe, expect, it, vi } from "vitest";
import { submitRealtimeTalkConsult } from "./chat/realtime-talk-shared.js";
function requireFirstMockCall(calls: readonly unknown[][], label: string): unknown[] {
const call = calls.at(0);
if (!call) {
throw new Error(`expected ${label} call`);
}
return call;
}
describe("RealtimeTalkSession consult handoff", () => {
it("submits realtime consults through the Gateway tool-call endpoint", async () => {
let listener: ((event: { event: string; payload?: unknown }) => void) | undefined;
@@ -41,7 +49,7 @@ describe("RealtimeTalkSession consult handoff", () => {
submit,
});
const toolCall = request.mock.calls[0] as
const toolCall = requireFirstMockCall(request.mock.calls, "Gateway request") as
| [string, { sessionKey?: string; name?: string; args?: { question?: string } }]
| undefined;
expect(toolCall?.[0]).toBe("talk.client.toolCall");