chore: We have a sleep at home. The sleep at home:

This commit is contained in:
cpojer
2026-02-02 21:34:47 +09:00
parent dfef943f0a
commit 6b0d6e2540
18 changed files with 69 additions and 49 deletions

View File

@@ -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);