mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 22:21:37 +00:00
test: remove fixed waits from tool-result ordering tests
This commit is contained in:
@@ -556,17 +556,16 @@ describe("runReplyAgent typing (heartbeat)", () => {
|
|||||||
const deliveryOrder: string[] = [];
|
const deliveryOrder: string[] = [];
|
||||||
const onToolResult = vi.fn(async (payload: { text?: string }) => {
|
const onToolResult = vi.fn(async (payload: { text?: string }) => {
|
||||||
// Simulate variable network latency: first result is slower than second
|
// Simulate variable network latency: first result is slower than second
|
||||||
const delay = payload.text === "first" ? 50 : 10;
|
const delay = payload.text === "first" ? 5 : 1;
|
||||||
await new Promise((r) => setTimeout(r, delay));
|
await new Promise((r) => setTimeout(r, delay));
|
||||||
deliveryOrder.push(payload.text ?? "");
|
deliveryOrder.push(payload.text ?? "");
|
||||||
});
|
});
|
||||||
|
|
||||||
state.runEmbeddedPiAgentMock.mockImplementationOnce(async (params: AgentRunParams) => {
|
state.runEmbeddedPiAgentMock.mockImplementationOnce(async (params: AgentRunParams) => {
|
||||||
// Fire two tool results without awaiting — simulates concurrent tool completion
|
// Fire two tool results without awaiting each one; await both at the end.
|
||||||
void params.onToolResult?.({ text: "first", mediaUrls: [] });
|
const first = params.onToolResult?.({ text: "first", mediaUrls: [] });
|
||||||
void params.onToolResult?.({ text: "second", mediaUrls: [] });
|
const second = params.onToolResult?.({ text: "second", mediaUrls: [] });
|
||||||
// Small delay to let the chain settle before returning
|
await Promise.all([first, second]);
|
||||||
await new Promise((r) => setTimeout(r, 150));
|
|
||||||
return { payloads: [{ text: "final" }], meta: {} };
|
return { payloads: [{ text: "final" }], meta: {} };
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -591,9 +590,9 @@ describe("runReplyAgent typing (heartbeat)", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
state.runEmbeddedPiAgentMock.mockImplementationOnce(async (params: AgentRunParams) => {
|
state.runEmbeddedPiAgentMock.mockImplementationOnce(async (params: AgentRunParams) => {
|
||||||
void params.onToolResult?.({ text: "first", mediaUrls: [] });
|
const first = params.onToolResult?.({ text: "first", mediaUrls: [] });
|
||||||
void params.onToolResult?.({ text: "second", mediaUrls: [] });
|
const second = params.onToolResult?.({ text: "second", mediaUrls: [] });
|
||||||
await new Promise((r) => setTimeout(r, 50));
|
await Promise.allSettled([first, second]);
|
||||||
return { payloads: [{ text: "final" }], meta: {} };
|
return { payloads: [{ text: "final" }], meta: {} };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user