test: stabilize whatsapp pdf media test

This commit is contained in:
Peter Steinberger
2026-04-18 02:00:55 +01:00
parent 0e4ddf7b38
commit 36068281fb

View File

@@ -294,20 +294,14 @@ describe("web auto-reply", () => {
resetLoadConfigMock();
}
});
it("falls back to text when media is unsupported", async () => {
it("sends PDF media as a document", async () => {
const sendMedia = vi.fn();
const { reply, dispatch } = await setupSingleInboundMessage({
resolverValue: { text: "hi", mediaUrl: "https://example.com/file.pdf" },
sendMedia,
});
const fetchMock = vi.spyOn(globalThis, "fetch").mockResolvedValue({
ok: true,
body: true,
arrayBuffer: async () => Buffer.from("%PDF-1.4").buffer,
headers: { get: () => "application/pdf" },
status: 200,
} as unknown as Response);
const fetchMock = mockFetchMediaBuffer(Buffer.from("%PDF-1.4"), "application/pdf");
await dispatch("msg-pdf");