mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 07:11:25 +00:00
refactor(test): share web broadcast-groups harness
This commit is contained in:
22
src/web/auto-reply.broadcast-groups.test-harness.ts
Normal file
22
src/web/auto-reply.broadcast-groups.test-harness.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { WebInboundMessage } from "./inbound.js";
|
||||
import { monitorWebChannel } from "./auto-reply.js";
|
||||
import {
|
||||
createWebInboundDeliverySpies,
|
||||
createWebListenerFactoryCapture,
|
||||
} from "./auto-reply.test-harness.js";
|
||||
|
||||
export async function monitorWebChannelWithCapture(resolver: unknown): Promise<{
|
||||
spies: ReturnType<typeof createWebInboundDeliverySpies>;
|
||||
onMessage: (msg: WebInboundMessage) => Promise<void>;
|
||||
}> {
|
||||
const spies = createWebInboundDeliverySpies();
|
||||
const { listenerFactory, getOnMessage } = createWebListenerFactoryCapture();
|
||||
|
||||
await monitorWebChannel(false, listenerFactory, false, resolver as never);
|
||||
const onMessage = getOnMessage();
|
||||
if (!onMessage) {
|
||||
throw new Error("Missing onMessage handler");
|
||||
}
|
||||
|
||||
return { spies, onMessage };
|
||||
}
|
||||
Reference in New Issue
Block a user