mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 17:01:53 +03:00
perf(test): consolidate web auto-reply suites
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildInboundLine } from "./message-line.js";
|
||||
import { buildInboundLine, formatReplyContext } from "./message-line.js";
|
||||
|
||||
describe("buildInboundLine", () => {
|
||||
it("prefixes group messages with sender", () => {
|
||||
@@ -30,4 +30,53 @@ describe("buildInboundLine", () => {
|
||||
expect(line).toContain("Bob (+15550001111):");
|
||||
expect(line).toContain("ping");
|
||||
});
|
||||
|
||||
it("includes reply-to context blocks when replyToBody is present", () => {
|
||||
const line = buildInboundLine({
|
||||
cfg: {
|
||||
agents: { defaults: { workspace: "/tmp/openclaw" } },
|
||||
channels: { whatsapp: { messagePrefix: "" } },
|
||||
} as never,
|
||||
agentId: "main",
|
||||
msg: {
|
||||
from: "+1555",
|
||||
to: "+1555",
|
||||
body: "hello",
|
||||
chatType: "direct",
|
||||
replyToId: "q1",
|
||||
replyToBody: "original",
|
||||
replyToSender: "+1999",
|
||||
} as never,
|
||||
envelope: { includeTimestamp: false },
|
||||
});
|
||||
|
||||
expect(line).toContain("[Replying to +1999 id:q1]");
|
||||
expect(line).toContain("original");
|
||||
expect(line).toContain("[/Replying]");
|
||||
});
|
||||
|
||||
it("applies the WhatsApp messagePrefix when configured", () => {
|
||||
const line = buildInboundLine({
|
||||
cfg: {
|
||||
agents: { defaults: { workspace: "/tmp/openclaw" } },
|
||||
channels: { whatsapp: { messagePrefix: "[PFX]" } },
|
||||
} as never,
|
||||
agentId: "main",
|
||||
msg: {
|
||||
from: "+1555",
|
||||
to: "+2666",
|
||||
body: "ping",
|
||||
chatType: "direct",
|
||||
} as never,
|
||||
envelope: { includeTimestamp: false },
|
||||
});
|
||||
|
||||
expect(line).toContain("[PFX] ping");
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatReplyContext", () => {
|
||||
it("returns null when replyToBody is missing", () => {
|
||||
expect(formatReplyContext({} as never)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user