refactor(web-test): share mock listener harness

This commit is contained in:
Peter Steinberger
2026-02-18 16:59:43 +00:00
parent f05395ae00
commit e9f6a2ce52
3 changed files with 18 additions and 28 deletions

View File

@@ -3,6 +3,7 @@ import { describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { monitorWebChannel } from "./auto-reply.js";
import {
createMockWebListener,
installWebAutoReplyTestHomeHooks,
installWebAutoReplyUnitTestHooks,
resetLoadConfigMock,
@@ -11,18 +12,6 @@ import {
installWebAutoReplyTestHomeHooks();
function createMockListener() {
return {
close: vi.fn(async () => undefined),
onClose: new Promise<import("./inbound.js").WebListenerCloseReason>(() => {}),
signalClose: vi.fn(),
sendMessage: vi.fn(async () => ({ messageId: "msg-1" })),
sendPoll: vi.fn(async () => ({ messageId: "poll-1" })),
sendReaction: vi.fn(async () => undefined),
sendComposingTo: vi.fn(async () => undefined),
};
}
describe("typing controller idle", () => {
installWebAutoReplyUnitTestHooks();
@@ -70,7 +59,7 @@ describe("typing controller idle", () => {
reply,
sendMedia,
});
return createMockListener();
return createMockWebListener();
},
false,
replyResolver,