test(whatsapp): preserve media test module exports

This commit is contained in:
Vincent Koc 2026-03-23 14:34:33 -07:00 committed by Peter Steinberger
parent e87a64f8d0
commit 7b03502175
1 changed files with 5 additions and 4 deletions

View File

@ -55,9 +55,8 @@ vi.mock("openclaw/plugin-sdk/media-runtime", async () => {
const HOME = path.join(os.tmpdir(), `openclaw-inbound-media-${crypto.randomUUID()}`);
process.env.HOME = HOME;
vi.mock("@whiskeysockets/baileys", async () => {
const actual =
await vi.importActual<typeof import("@whiskeysockets/baileys")>("@whiskeysockets/baileys");
vi.mock("@whiskeysockets/baileys", async (importOriginal) => {
const actual = await importOriginal<typeof import("@whiskeysockets/baileys")>();
const jpegBuffer = Buffer.from([
0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02,
0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05,
@ -76,7 +75,8 @@ vi.mock("@whiskeysockets/baileys", async () => {
};
});
vi.mock("./session.js", () => {
vi.mock("./session.js", async () => {
const actual = await vi.importActual<typeof import("./session.js")>("./session.js");
const { EventEmitter } = require("node:events");
const ev = new EventEmitter();
const sock = {
@ -90,6 +90,7 @@ vi.mock("./session.js", () => {
user: { id: "me@s.whatsapp.net" },
};
return {
...actual,
createWaSocket: vi.fn().mockResolvedValue(sock),
waitForWaConnection: vi.fn().mockResolvedValue(undefined),
getStatusCode: vi.fn(() => 200),