test(auto-reply): cover sender_id metadata

This commit is contained in:
Sebastian
2026-02-17 10:02:20 -05:00
parent 11fcbadec8
commit 21978303a9
2 changed files with 31 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ Docs: https://docs.openclaw.ai
- Discord: add per-button `allowedUsers` allowlist for interactive components to restrict who can click buttons. Thanks @thewilloftheshadow.
- Docker: add optional `OPENCLAW_INSTALL_BROWSER` build arg to preinstall Chromium + Xvfb in the Docker image, avoiding runtime Playwright installs. (#18449)
- Agents/Z.AI: enable `tool_stream` by default for real-time tool call streaming, with opt-out via `params.tool_stream: false`. (#18173) Thanks @tianxiao1430-jpg.
- Auto-reply: include `sender_id` in trusted inbound metadata so moderation workflows can target the sender without relying on untrusted text. (#18303) Thanks @crimeacs.
### Fixes

View File

@@ -47,6 +47,36 @@ describe("buildInboundMetaSystemPrompt", () => {
expect(payload["sender_id"]).toBe("289522496");
});
it("trims sender_id before storing", () => {
const prompt = buildInboundMetaSystemPrompt({
MessageSid: "457",
SenderId: " 289522496 ",
OriginatingTo: "telegram:-1001249586642",
OriginatingChannel: "telegram",
Provider: "telegram",
Surface: "telegram",
ChatType: "group",
} as TemplateContext);
const payload = parseInboundMetaPayload(prompt);
expect(payload["sender_id"]).toBe("289522496");
});
it("omits sender_id when blank", () => {
const prompt = buildInboundMetaSystemPrompt({
MessageSid: "458",
SenderId: " ",
OriginatingTo: "telegram:-1001249586642",
OriginatingChannel: "telegram",
Provider: "telegram",
Surface: "telegram",
ChatType: "group",
} as TemplateContext);
const payload = parseInboundMetaPayload(prompt);
expect(payload["sender_id"]).toBeUndefined();
});
it("omits sender_id when not provided", () => {
const prompt = buildInboundMetaSystemPrompt({
MessageSid: "789",