refactor(test): share web broadcast-groups harness

This commit is contained in:
Peter Steinberger
2026-02-15 15:03:14 +00:00
parent 86df160617
commit fe27215747
3 changed files with 34 additions and 43 deletions

View 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 };
}