mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
test: wait for discord voice tool results by assertion
This commit is contained in:
@@ -1085,9 +1085,11 @@ describe("DiscordVoiceManager", () => {
|
||||
},
|
||||
realtimeSessionMock,
|
||||
);
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
await new Promise((resolve) => setTimeout(resolve, 20));
|
||||
await vi.waitFor(() =>
|
||||
expect(realtimeSessionMock.submitToolResult).toHaveBeenCalledWith("call-1", {
|
||||
text: "agent proxy answer",
|
||||
}),
|
||||
);
|
||||
|
||||
const commandArgs = lastAgentCommandArgs();
|
||||
expect(commandArgs.model).toBe("openai-codex/gpt-5.5");
|
||||
@@ -1103,9 +1105,6 @@ describe("DiscordVoiceManager", () => {
|
||||
"working",
|
||||
);
|
||||
expect(workingToolResultCall?.[2]).toEqual({ willContinue: true });
|
||||
expect(realtimeSessionMock.submitToolResult).toHaveBeenCalledWith("call-1", {
|
||||
text: "agent proxy answer",
|
||||
});
|
||||
});
|
||||
|
||||
it("does not require speaker context for internal exact-speech consults", async () => {
|
||||
@@ -1798,20 +1797,19 @@ describe("DiscordVoiceManager", () => {
|
||||
realtimeSessionMock,
|
||||
);
|
||||
rejectAgentTurn?.(new Error("agent broke"));
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
await new Promise((resolve) => setTimeout(resolve, 20));
|
||||
await vi.waitFor(() =>
|
||||
expect(realtimeSessionMock.submitToolResult).toHaveBeenCalledWith(
|
||||
"call-late",
|
||||
{
|
||||
status: "already_delivered",
|
||||
message: "OpenClaw already delivered this answer to Discord voice.",
|
||||
},
|
||||
{ suppressResponse: true },
|
||||
),
|
||||
);
|
||||
|
||||
expect(agentCommandMock).toHaveBeenCalledTimes(1);
|
||||
expectUserMessageIncludes("I hit an error while checking that. Please try again.");
|
||||
expect(realtimeSessionMock.submitToolResult).toHaveBeenCalledWith(
|
||||
"call-late",
|
||||
{
|
||||
status: "already_delivered",
|
||||
message: "OpenClaw already delivered this answer to Discord voice.",
|
||||
},
|
||||
{ suppressResponse: true },
|
||||
);
|
||||
});
|
||||
|
||||
it("does not reuse recent agent-proxy answers over newer speaker audio", async () => {
|
||||
@@ -1947,13 +1945,11 @@ describe("DiscordVoiceManager", () => {
|
||||
},
|
||||
realtimeSessionMock,
|
||||
);
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
await new Promise((resolve) => setTimeout(resolve, 20));
|
||||
|
||||
expect(realtimeSessionMock.submitToolResult).toHaveBeenCalledWith("call-old", {
|
||||
text: "old direct answer",
|
||||
});
|
||||
await vi.waitFor(() =>
|
||||
expect(realtimeSessionMock.submitToolResult).toHaveBeenCalledWith("call-old", {
|
||||
text: "old direct answer",
|
||||
}),
|
||||
);
|
||||
|
||||
const secondTurn = entry.realtime?.beginSpeakerTurn(
|
||||
{ extraSystemPrompt: undefined, senderIsOwner: true, speakerLabel: "Owner" },
|
||||
@@ -2105,9 +2101,11 @@ describe("DiscordVoiceManager", () => {
|
||||
},
|
||||
realtimeSessionMock,
|
||||
);
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
await new Promise((resolve) => setTimeout(resolve, 20));
|
||||
await vi.waitFor(() =>
|
||||
expect(realtimeSessionMock.submitToolResult).toHaveBeenCalledWith("call-1", {
|
||||
text: "consult answer",
|
||||
}),
|
||||
);
|
||||
|
||||
const workingToolResultCall = mockCall(
|
||||
realtimeSessionMock.submitToolResult as unknown as MockCallSource,
|
||||
@@ -2119,9 +2117,6 @@ describe("DiscordVoiceManager", () => {
|
||||
"working",
|
||||
);
|
||||
expect(workingToolResultCall?.[2]).toEqual({ willContinue: true });
|
||||
expect(realtimeSessionMock.submitToolResult).toHaveBeenCalledWith("call-1", {
|
||||
text: "consult answer",
|
||||
});
|
||||
const commandArgs = lastAgentCommandArgs();
|
||||
expect(commandArgs.senderIsOwner).toBe(true);
|
||||
expect(commandArgs.toolsAllow).toEqual([
|
||||
@@ -2206,14 +2201,13 @@ describe("DiscordVoiceManager", () => {
|
||||
},
|
||||
realtimeSessionMock,
|
||||
);
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
await new Promise((resolve) => setTimeout(resolve, 20));
|
||||
await vi.waitFor(() =>
|
||||
expect(realtimeSessionMock.submitToolResult).toHaveBeenCalledWith("call-1", {
|
||||
text: "maintainer answer",
|
||||
}),
|
||||
);
|
||||
|
||||
expect(lastAgentCommandArgs().sessionKey).toBe("agent:main:discord:channel:maintainers");
|
||||
expect(realtimeSessionMock.submitToolResult).toHaveBeenCalledWith("call-1", {
|
||||
text: "maintainer answer",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps bidi realtime consults on the audio turn speaker context", async () => {
|
||||
|
||||
Reference in New Issue
Block a user