test: share whatsapp inbound reply fixture

This commit is contained in:
Peter Steinberger
2026-04-20 16:16:43 +01:00
parent 9b21540a4e
commit d02b10c3fb

View File

@@ -4,6 +4,30 @@ import {
resolveVisibleWhatsAppReplyContext,
} from "./inbound-context.js";
type ReplyContextParams = Parameters<typeof resolveVisibleWhatsAppReplyContext>[0];
const makeBlockedQuotedReplyMessage = (id: string): ReplyContextParams["msg"] => ({
id,
from: "123@g.us",
conversationId: "123@g.us",
to: "+2000",
accountId: "default",
chatType: "group",
chatId: "123@g.us",
body: "Current message",
senderName: "Alice",
senderJid: "111@s.whatsapp.net",
senderE164: "+111",
selfE164: "+999",
replyToId: "blocked-reply",
replyToBody: "Blocked quoted text",
replyToSender: "Mallory (+999)",
replyToSenderJid: "999@s.whatsapp.net",
sendComposing: async () => {},
reply: async () => {},
sendMedia: async () => {},
});
describe("whatsapp inbound context visibility", () => {
it("filters non-allowlisted group history from supplemental context", () => {
const history = resolveVisibleWhatsAppGroupHistory({
@@ -34,52 +58,22 @@ describe("whatsapp inbound context visibility", () => {
it("redacts blocked quoted replies in allowlist mode", () => {
const reply = resolveVisibleWhatsAppReplyContext({
msg: {
id: "msg-reply-1",
from: "123@g.us",
conversationId: "123@g.us",
to: "+2000",
chatType: "group",
body: "Current message",
senderName: "Alice",
senderJid: "111@s.whatsapp.net",
senderE164: "+111",
selfE164: "+999",
replyToId: "blocked-reply",
replyToBody: "Blocked quoted text",
replyToSender: "Mallory (+999)",
replyToSenderJid: "999@s.whatsapp.net",
},
msg: makeBlockedQuotedReplyMessage("msg-reply-1"),
mode: "allowlist",
groupPolicy: "allowlist",
groupAllowFrom: ["+111"],
} as Parameters<typeof resolveVisibleWhatsAppReplyContext>[0]);
});
expect(reply).toBeNull();
});
it("keeps blocked quoted replies in allowlist_quote mode", () => {
const reply = resolveVisibleWhatsAppReplyContext({
msg: {
id: "msg-reply-2",
from: "123@g.us",
conversationId: "123@g.us",
to: "+2000",
chatType: "group",
body: "Current message",
senderName: "Alice",
senderJid: "111@s.whatsapp.net",
senderE164: "+111",
selfE164: "+999",
replyToId: "blocked-reply",
replyToBody: "Blocked quoted text",
replyToSender: "Mallory (+999)",
replyToSenderJid: "999@s.whatsapp.net",
},
msg: makeBlockedQuotedReplyMessage("msg-reply-2"),
mode: "allowlist_quote",
groupPolicy: "allowlist",
groupAllowFrom: ["+111"],
} as Parameters<typeof resolveVisibleWhatsAppReplyContext>[0]);
});
expect(reply).toMatchObject({
id: "blocked-reply",