mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 00:28:26 +00:00
refactor(channels): dedupe transport and gateway test scaffolds
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import "./test-helpers.js";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { monitorWebChannelWithCapture } from "./auto-reply.broadcast-groups.test-harness.js";
|
||||
import {
|
||||
monitorWebChannelWithCapture,
|
||||
sendWebDirectInboundAndCollectSessionKeys,
|
||||
} from "./auto-reply.broadcast-groups.test-harness.js";
|
||||
import {
|
||||
installWebAutoReplyTestHomeHooks,
|
||||
installWebAutoReplyUnitTestHooks,
|
||||
resetLoadConfigMock,
|
||||
sendWebDirectInboundMessage,
|
||||
sendWebGroupInboundMessage,
|
||||
setLoadConfigMock,
|
||||
} from "./auto-reply.test-harness.js";
|
||||
@@ -29,22 +31,7 @@ describe("broadcast groups", () => {
|
||||
},
|
||||
} satisfies OpenClawConfig);
|
||||
|
||||
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",
|
||||
});
|
||||
const { seen, resolver } = await sendWebDirectInboundAndCollectSessionKeys();
|
||||
|
||||
expect(resolver).toHaveBeenCalledTimes(2);
|
||||
expect(seen[0]).toContain("agent:alfred:");
|
||||
|
||||
Reference in New Issue
Block a user