mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 05:11:36 +00:00
test(media-dedup): add missing coverage for Discord media dedup wiring
Cover three integration points where media dedup could silently regress: - trimMessagingToolSent FIFO cap at 200 entries - buildReplyPayloads media filter wiring (new test file) - followup-runner messagingToolSentMediaUrls filtering
This commit is contained in:
committed by
Peter Steinberger
parent
4640999e77
commit
c7681c3cff
46
src/auto-reply/reply/agent-runner-payloads.test.ts
Normal file
46
src/auto-reply/reply/agent-runner-payloads.test.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildReplyPayloads } from "./agent-runner-payloads.js";
|
||||
|
||||
const baseParams = {
|
||||
isHeartbeat: false,
|
||||
didLogHeartbeatStrip: false,
|
||||
blockStreamingEnabled: false,
|
||||
blockReplyPipeline: null,
|
||||
replyToMode: "off" as const,
|
||||
};
|
||||
|
||||
describe("buildReplyPayloads media filter integration", () => {
|
||||
it("strips media URL from payload when in messagingToolSentMediaUrls", () => {
|
||||
const { replyPayloads } = buildReplyPayloads({
|
||||
...baseParams,
|
||||
payloads: [{ text: "hello", mediaUrl: "file:///tmp/photo.jpg" }],
|
||||
messagingToolSentMediaUrls: ["file:///tmp/photo.jpg"],
|
||||
});
|
||||
|
||||
expect(replyPayloads).toHaveLength(1);
|
||||
expect(replyPayloads[0].mediaUrl).toBeUndefined();
|
||||
});
|
||||
|
||||
it("preserves media URL when not in messagingToolSentMediaUrls", () => {
|
||||
const { replyPayloads } = buildReplyPayloads({
|
||||
...baseParams,
|
||||
payloads: [{ text: "hello", mediaUrl: "file:///tmp/photo.jpg" }],
|
||||
messagingToolSentMediaUrls: ["file:///tmp/other.jpg"],
|
||||
});
|
||||
|
||||
expect(replyPayloads).toHaveLength(1);
|
||||
expect(replyPayloads[0].mediaUrl).toBe("file:///tmp/photo.jpg");
|
||||
});
|
||||
|
||||
it("applies media filter after text filter", () => {
|
||||
const { replyPayloads } = buildReplyPayloads({
|
||||
...baseParams,
|
||||
payloads: [{ text: "hello world!", mediaUrl: "file:///tmp/photo.jpg" }],
|
||||
messagingToolSentTexts: ["hello world!"],
|
||||
messagingToolSentMediaUrls: ["file:///tmp/photo.jpg"],
|
||||
});
|
||||
|
||||
// Text filter removes the payload entirely (text matched), so nothing remains.
|
||||
expect(replyPayloads).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user