perf(test): consolidate web auto-reply suites

This commit is contained in:
Peter Steinberger
2026-02-14 23:10:06 +00:00
parent 5fd1822c7c
commit fb1d8f8361
8 changed files with 799 additions and 1524 deletions
@@ -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();
});
});