mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 02:48:27 +00:00
refactor(channels): dedupe transport and gateway test scaffolds
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { vi } from "vitest";
|
||||
import type { WebInboundMessage } from "./inbound.js";
|
||||
import { monitorWebChannel } from "./auto-reply.js";
|
||||
import {
|
||||
createWebInboundDeliverySpies,
|
||||
createWebListenerFactoryCapture,
|
||||
sendWebDirectInboundMessage,
|
||||
} from "./auto-reply.test-harness.js";
|
||||
|
||||
export async function monitorWebChannelWithCapture(resolver: unknown): Promise<{
|
||||
@@ -20,3 +22,26 @@ export async function monitorWebChannelWithCapture(resolver: unknown): Promise<{
|
||||
|
||||
return { spies, onMessage };
|
||||
}
|
||||
|
||||
export async function sendWebDirectInboundAndCollectSessionKeys(): Promise<{
|
||||
seen: string[];
|
||||
resolver: ReturnType<typeof vi.fn>;
|
||||
}> {
|
||||
const seen: string[] = [];
|
||||
const resolver = vi.fn(async (ctx: { SessionKey?: unknown }) => {
|
||||
seen.push(String(ctx.SessionKey));
|
||||
return { text: "ok" };
|
||||
});
|
||||
|
||||
const { spies, onMessage } = await monitorWebChannelWithCapture(resolver);
|
||||
await sendWebDirectInboundMessage({
|
||||
onMessage,
|
||||
spies,
|
||||
id: "m1",
|
||||
from: "+1000",
|
||||
to: "+2000",
|
||||
body: "hello",
|
||||
});
|
||||
|
||||
return { seen, resolver };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user