
























@@ -1,5 +1,17 @@
1-import { describe, expect, it } from "vitest";
2-import { isHttpMediaUrl } from "./inbound.js";
1+import { createPluginRuntimeMock } from "openclaw/plugin-sdk/channel-test-helpers";
2+import { beforeEach, describe, expect, it, vi } from "vitest";
3+import { setQaChannelRuntime } from "../api.js";
4+import { handleQaInbound, isHttpMediaUrl } from "./inbound.js";
5+6+const dispatchInboundReplyWithBaseMock = vi.hoisted(() => vi.fn());
7+8+vi.mock("openclaw/plugin-sdk/inbound-reply-dispatch", () => ({
9+dispatchInboundReplyWithBase: dispatchInboundReplyWithBaseMock,
10+}));
11+12+beforeEach(() => {
13+dispatchInboundReplyWithBaseMock.mockReset();
14+});
315416describe("isHttpMediaUrl", () => {
517it("accepts only http and https urls", () => {
@@ -10,3 +22,45 @@ describe("isHttpMediaUrl", () => {
1022expect(isHttpMediaUrl("data:text/plain;base64,SGVsbG8=")).toBe(false);
1123});
1224});
25+26+describe("handleQaInbound", () => {
27+it("marks group messages that match configured mention patterns", async () => {
28+const runtime = createPluginRuntimeMock();
29+vi.mocked(runtime.channel.mentions.buildMentionRegexes).mockReturnValue([/\b@?openclaw\b/i]);
30+setQaChannelRuntime(runtime);
31+32+await handleQaInbound({
33+channelId: "qa-channel",
34+channelLabel: "QA Channel",
35+account: {
36+accountId: "default",
37+enabled: true,
38+configured: true,
39+baseUrl: "http://127.0.0.1:43123",
40+botUserId: "openclaw",
41+botDisplayName: "OpenClaw QA",
42+pollTimeoutMs: 250,
43+config: {},
44+},
45+config: {},
46+message: {
47+id: "msg-1",
48+accountId: "default",
49+direction: "inbound",
50+conversation: {
51+kind: "channel",
52+id: "qa-room",
53+title: "QA Room",
54+},
55+senderId: "alice",
56+senderName: "Alice",
57+text: "@openclaw ping",
58+timestamp: 1_777_000_000_000,
59+reactions: [],
60+},
61+});
62+63+expect(dispatchInboundReplyWithBaseMock).toHaveBeenCalledTimes(1);
64+expect(dispatchInboundReplyWithBaseMock.mock.calls[0]?.[0].ctxPayload.WasMentioned).toBe(true);
65+});
66+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。