Skip to content

Commit db97b76

Browse files
committed
test: cover WhatsApp successor media handoff
1 parent 9732254 commit db97b76

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

extensions/whatsapp/src/monitor-inbox.streams-inbound-messages.test-support.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,10 @@ describe("web monitor inbox", () => {
852852
}),
853853
);
854854
await waitForMessageCalls(onMessage, 1);
855-
const inbound = inboundMessage(onMessage) as { reply: (text: string) => Promise<void> };
855+
const inbound = inboundMessage(onMessage) as {
856+
reply: (text: string) => Promise<void>;
857+
sendMedia: (payload: Record<string, unknown>) => Promise<void>;
858+
};
856859

857860
// The mock harness socket exposes user.id = "123@s.whatsapp.net"; the
858861
// successor handle must report a self identity that overlaps that JID
@@ -882,10 +885,16 @@ describe("web monitor inbox", () => {
882885

883886
try {
884887
await inbound.reply("pong");
888+
await inbound.sendMedia({ text: "media after restart" });
885889

886890
// Captured A reply routed through B via the registry handle.
887-
expect(sockB.sendMessage).toHaveBeenCalledTimes(1);
888-
expect(sockB.sendMessage).toHaveBeenCalledWith("999@s.whatsapp.net", { text: "pong" });
891+
expect(sockB.sendMessage).toHaveBeenCalledTimes(2);
892+
expect(sockB.sendMessage).toHaveBeenNthCalledWith(1, "999@s.whatsapp.net", {
893+
text: "pong",
894+
});
895+
expect(sockB.sendMessage).toHaveBeenNthCalledWith(2, "999@s.whatsapp.net", {
896+
text: "media after restart",
897+
});
889898
} finally {
890899
unregisterWhatsAppConnectionController(DEFAULT_ACCOUNT_ID, handleB);
891900
await listenerA.close();

0 commit comments

Comments
 (0)