Skip to content

Commit da2467e

Browse files
committed
test(xai): await realtime tool result assertions
1 parent e484c09 commit da2467e

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

extensions/xai/realtime-voice-provider.test.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -871,10 +871,10 @@ describe("buildXaiRealtimeVoiceProvider", () => {
871871
);
872872
}
873873

874-
bridge.submitToolResult("call_1", { text: "first" });
874+
await bridge.submitToolResult("call_1", { text: "first" });
875875
expect(parseSent(socket).filter((event) => event.type === "response.create")).toEqual([]);
876876

877-
bridge.submitToolResult("call_2", { text: "second" });
877+
await bridge.submitToolResult("call_2", { text: "second" });
878878
expect(parseSent(socket).slice(-2)).toEqual([
879879
{
880880
type: "conversation.item.create",
@@ -919,12 +919,12 @@ describe("buildXaiRealtimeVoiceProvider", () => {
919919
),
920920
);
921921

922-
bridge.submitToolResult("call_1", { status: "working" }, { willContinue: true });
923-
expect(
924-
parseSent(socket).filter((event) => event.type === "conversation.item.create"),
925-
).toEqual([]);
922+
await bridge.submitToolResult("call_1", { status: "working" }, { willContinue: true });
923+
expect(parseSent(socket).filter((event) => event.type === "conversation.item.create")).toEqual(
924+
[],
925+
);
926926

927-
bridge.submitToolResult("call_1", { text: "final" });
927+
await bridge.submitToolResult("call_1", { text: "final" });
928928
expect(parseSent(socket).slice(-2)).toEqual([
929929
{
930930
type: "conversation.item.create",
@@ -981,7 +981,7 @@ describe("buildXaiRealtimeVoiceProvider", () => {
981981
),
982982
);
983983

984-
bridge.submitToolResult("call_1", { text: "final" });
984+
await bridge.submitToolResult("call_1", { text: "final" });
985985
expect(parseSent(socket).filter((event) => event.type === "response.create")).toEqual([]);
986986

987987
bridge.acknowledgeMark?.();
@@ -1037,10 +1037,10 @@ describe("buildXaiRealtimeVoiceProvider", () => {
10371037
secondSocket.emit("open");
10381038
secondSocket.emit("message", Buffer.from(JSON.stringify({ type: "session.updated" })));
10391039

1040-
bridge.submitToolResult("call_1", { text: "first" });
1040+
await bridge.submitToolResult("call_1", { text: "first" });
10411041
expect(parseSent(secondSocket).filter((event) => event.type === "response.create")).toEqual([]);
10421042

1043-
bridge.submitToolResult("call_2", { text: "second" });
1043+
await bridge.submitToolResult("call_2", { text: "second" });
10441044
expect(parseSent(secondSocket).slice(-2)).toEqual([
10451045
{
10461046
type: "conversation.item.create",
@@ -1103,9 +1103,10 @@ describe("buildXaiRealtimeVoiceProvider", () => {
11031103
secondSocket.readyState = FakeWebSocket.OPEN;
11041104
secondSocket.emit("open");
11051105

1106-
bridge.submitToolResult("call_1", { text: "first" });
1107-
expect(parseSent(secondSocket).filter((event) => event.type === "conversation.item.create"))
1108-
.toEqual([]);
1106+
await bridge.submitToolResult("call_1", { text: "first" });
1107+
expect(
1108+
parseSent(secondSocket).filter((event) => event.type === "conversation.item.create"),
1109+
).toEqual([]);
11091110

11101111
secondSocket.emit("message", Buffer.from(JSON.stringify({ type: "session.updated" })));
11111112
expect(parseSent(secondSocket).filter((event) => event.type === "response.create")).toEqual([]);
@@ -1120,7 +1121,7 @@ describe("buildXaiRealtimeVoiceProvider", () => {
11201121
},
11211122
]);
11221123

1123-
bridge.submitToolResult("call_2", { text: "second" });
1124+
await bridge.submitToolResult("call_2", { text: "second" });
11241125
expect(parseSent(secondSocket).slice(-2)).toEqual([
11251126
{
11261127
type: "conversation.item.create",
@@ -1168,8 +1169,9 @@ describe("buildXaiRealtimeVoiceProvider", () => {
11681169
secondSocket.emit("open");
11691170

11701171
bridge.sendUserMessage?.("OpenClaw finished checking.");
1171-
expect(parseSent(secondSocket).filter((event) => event.type === "conversation.item.create"))
1172-
.toEqual([]);
1172+
expect(
1173+
parseSent(secondSocket).filter((event) => event.type === "conversation.item.create"),
1174+
).toEqual([]);
11731175

11741176
secondSocket.emit("message", Buffer.from(JSON.stringify({ type: "session.updated" })));
11751177
expect(parseSent(secondSocket).slice(-2)).toEqual([

0 commit comments

Comments
 (0)