mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 12:57:40 +00:00
test(web): stabilize processMessage inbound contract cleanup
This commit is contained in:
@@ -8,6 +8,7 @@ let capturedCtx: unknown;
|
|||||||
let capturedDispatchParams: unknown;
|
let capturedDispatchParams: unknown;
|
||||||
let sessionDir: string | undefined;
|
let sessionDir: string | undefined;
|
||||||
let sessionStorePath: string;
|
let sessionStorePath: string;
|
||||||
|
let backgroundTasks: Set<Promise<unknown>>;
|
||||||
|
|
||||||
vi.mock("../../../auto-reply/reply/provider-dispatcher.js", () => ({
|
vi.mock("../../../auto-reply/reply/provider-dispatcher.js", () => ({
|
||||||
// oxlint-disable-next-line typescript/no-explicit-any
|
// oxlint-disable-next-line typescript/no-explicit-any
|
||||||
@@ -19,7 +20,12 @@ vi.mock("../../../auto-reply/reply/provider-dispatcher.js", () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock("./last-route.js", () => ({
|
vi.mock("./last-route.js", () => ({
|
||||||
trackBackgroundTask: () => undefined,
|
trackBackgroundTask: (tasks: Set<Promise<unknown>>, task: Promise<unknown>) => {
|
||||||
|
tasks.add(task);
|
||||||
|
task.finally(() => {
|
||||||
|
tasks.delete(task);
|
||||||
|
});
|
||||||
|
},
|
||||||
updateLastRouteInBackground: vi.fn(),
|
updateLastRouteInBackground: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -29,11 +35,13 @@ describe("web processMessage inbound contract", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
capturedCtx = undefined;
|
capturedCtx = undefined;
|
||||||
capturedDispatchParams = undefined;
|
capturedDispatchParams = undefined;
|
||||||
|
backgroundTasks = new Set();
|
||||||
sessionDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-process-message-"));
|
sessionDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-process-message-"));
|
||||||
sessionStorePath = path.join(sessionDir, "sessions.json");
|
sessionStorePath = path.join(sessionDir, "sessions.json");
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
|
await Promise.allSettled(Array.from(backgroundTasks));
|
||||||
if (sessionDir) {
|
if (sessionDir) {
|
||||||
await fs.rm(sessionDir, { recursive: true, force: true });
|
await fs.rm(sessionDir, { recursive: true, force: true });
|
||||||
sessionDir = undefined;
|
sessionDir = undefined;
|
||||||
@@ -73,7 +81,7 @@ describe("web processMessage inbound contract", () => {
|
|||||||
replyResolver: (async () => undefined) as any,
|
replyResolver: (async () => undefined) as any,
|
||||||
// oxlint-disable-next-line typescript/no-explicit-any
|
// oxlint-disable-next-line typescript/no-explicit-any
|
||||||
replyLogger: { info: () => {}, warn: () => {}, error: () => {}, debug: () => {} } as any,
|
replyLogger: { info: () => {}, warn: () => {}, error: () => {}, debug: () => {} } as any,
|
||||||
backgroundTasks: new Set(),
|
backgroundTasks,
|
||||||
rememberSentText: (_text: string | undefined, _opts: unknown) => {},
|
rememberSentText: (_text: string | undefined, _opts: unknown) => {},
|
||||||
echoHas: () => false,
|
echoHas: () => false,
|
||||||
echoForget: () => {},
|
echoForget: () => {},
|
||||||
@@ -119,7 +127,7 @@ describe("web processMessage inbound contract", () => {
|
|||||||
replyResolver: (async () => undefined) as any,
|
replyResolver: (async () => undefined) as any,
|
||||||
// oxlint-disable-next-line typescript/no-explicit-any
|
// oxlint-disable-next-line typescript/no-explicit-any
|
||||||
replyLogger: { info: () => {}, warn: () => {}, error: () => {}, debug: () => {} } as any,
|
replyLogger: { info: () => {}, warn: () => {}, error: () => {}, debug: () => {} } as any,
|
||||||
backgroundTasks: new Set(),
|
backgroundTasks,
|
||||||
rememberSentText: (_text: string | undefined, _opts: unknown) => {},
|
rememberSentText: (_text: string | undefined, _opts: unknown) => {},
|
||||||
echoHas: () => false,
|
echoHas: () => false,
|
||||||
echoForget: () => {},
|
echoForget: () => {},
|
||||||
@@ -181,7 +189,7 @@ describe("web processMessage inbound contract", () => {
|
|||||||
replyResolver: (async () => undefined) as any,
|
replyResolver: (async () => undefined) as any,
|
||||||
// oxlint-disable-next-line typescript/no-explicit-any
|
// oxlint-disable-next-line typescript/no-explicit-any
|
||||||
replyLogger: { info: () => {}, warn: () => {}, error: () => {}, debug: () => {} } as any,
|
replyLogger: { info: () => {}, warn: () => {}, error: () => {}, debug: () => {} } as any,
|
||||||
backgroundTasks: new Set(),
|
backgroundTasks,
|
||||||
rememberSentText: (_text: string | undefined, _opts: unknown) => {},
|
rememberSentText: (_text: string | undefined, _opts: unknown) => {},
|
||||||
echoHas: () => false,
|
echoHas: () => false,
|
||||||
echoForget: () => {},
|
echoForget: () => {},
|
||||||
@@ -246,7 +254,7 @@ describe("web processMessage inbound contract", () => {
|
|||||||
replyResolver: (async () => undefined) as any,
|
replyResolver: (async () => undefined) as any,
|
||||||
// oxlint-disable-next-line typescript/no-explicit-any
|
// oxlint-disable-next-line typescript/no-explicit-any
|
||||||
replyLogger: { info: () => {}, warn: () => {}, error: () => {}, debug: () => {} } as any,
|
replyLogger: { info: () => {}, warn: () => {}, error: () => {}, debug: () => {} } as any,
|
||||||
backgroundTasks: new Set(),
|
backgroundTasks,
|
||||||
rememberSentText: (_text: string | undefined, _opts: unknown) => {},
|
rememberSentText: (_text: string | undefined, _opts: unknown) => {},
|
||||||
echoHas: () => false,
|
echoHas: () => false,
|
||||||
echoForget: () => {},
|
echoForget: () => {},
|
||||||
|
|||||||
Reference in New Issue
Block a user