mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 06:01:23 +00:00
chore: We have a sleep at home. The sleep at home:
This commit is contained in:
@@ -21,6 +21,7 @@ vi.mock("../config/config.js", async (importOriginal) => {
|
||||
});
|
||||
|
||||
import "./test-helpers/fast-core-tools.js";
|
||||
import { sleep } from "../utils.js";
|
||||
import { createOpenClawTools } from "./openclaw-tools.js";
|
||||
|
||||
const waitForCalls = async (getCount: () => number, count: number, timeoutMs = 2000) => {
|
||||
@@ -29,7 +30,7 @@ const waitForCalls = async (getCount: () => number, count: number, timeoutMs = 2
|
||||
if (Date.now() - start > timeoutMs) {
|
||||
throw new Error(`timed out waiting for ${count} calls`);
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await sleep(0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -185,7 +186,10 @@ describe("sessions tools", () => {
|
||||
const sessionId = "sess-group";
|
||||
const targetKey = "agent:main:discord:channel:1457165743010611293";
|
||||
callGatewayMock.mockImplementation(async (opts: unknown) => {
|
||||
const request = opts as { method?: string; params?: Record<string, unknown> };
|
||||
const request = opts as {
|
||||
method?: string;
|
||||
params?: Record<string, unknown>;
|
||||
};
|
||||
if (request.method === "sessions.resolve") {
|
||||
return {
|
||||
key: targetKey,
|
||||
@@ -388,7 +392,10 @@ describe("sessions tools", () => {
|
||||
const sessionId = "sess-send";
|
||||
const targetKey = "agent:main:discord:channel:123";
|
||||
callGatewayMock.mockImplementation(async (opts: unknown) => {
|
||||
const request = opts as { method?: string; params?: Record<string, unknown> };
|
||||
const request = opts as {
|
||||
method?: string;
|
||||
params?: Record<string, unknown>;
|
||||
};
|
||||
if (request.method === "sessions.resolve") {
|
||||
return { key: targetKey };
|
||||
}
|
||||
@@ -514,8 +521,8 @@ describe("sessions tools", () => {
|
||||
status: "ok",
|
||||
reply: "initial",
|
||||
});
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await sleep(0);
|
||||
await sleep(0);
|
||||
|
||||
const agentCalls = calls.filter((call) => call.method === "agent");
|
||||
expect(agentCalls).toHaveLength(4);
|
||||
|
||||
Reference in New Issue
Block a user