test(telegram): relax media group test timeouts
This commit is contained in:
@@ -228,16 +228,23 @@ describe("telegram inbound media", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("telegram media groups", () => {
|
describe("telegram media groups", () => {
|
||||||
|
const MEDIA_GROUP_POLL_TIMEOUT_MS = 15_000;
|
||||||
|
const MEDIA_GROUP_TEST_TIMEOUT_MS = 20_000;
|
||||||
|
|
||||||
const waitForMediaGroupProcessing = async (
|
const waitForMediaGroupProcessing = async (
|
||||||
replySpy: ReturnType<typeof vi.fn>,
|
replySpy: ReturnType<typeof vi.fn>,
|
||||||
expectedCalls: number,
|
expectedCalls: number,
|
||||||
) => {
|
) => {
|
||||||
await expect
|
await expect
|
||||||
.poll(() => replySpy.mock.calls.length, { timeout: 10_000 })
|
.poll(() => replySpy.mock.calls.length, {
|
||||||
|
timeout: MEDIA_GROUP_POLL_TIMEOUT_MS,
|
||||||
|
})
|
||||||
.toBe(expectedCalls);
|
.toBe(expectedCalls);
|
||||||
};
|
};
|
||||||
|
|
||||||
it("buffers messages with same media_group_id and processes them together", async () => {
|
it(
|
||||||
|
"buffers messages with same media_group_id and processes them together",
|
||||||
|
async () => {
|
||||||
const { createTelegramBot } = await import("./bot.js");
|
const { createTelegramBot } = await import("./bot.js");
|
||||||
const replyModule = await import("../auto-reply/reply.js");
|
const replyModule = await import("../auto-reply/reply.js");
|
||||||
const replySpy = replyModule.__replySpy as unknown as ReturnType<
|
const replySpy = replyModule.__replySpy as unknown as ReturnType<
|
||||||
@@ -248,12 +255,15 @@ describe("telegram media groups", () => {
|
|||||||
replySpy.mockReset();
|
replySpy.mockReset();
|
||||||
|
|
||||||
const runtimeError = vi.fn();
|
const runtimeError = vi.fn();
|
||||||
const fetchSpy = vi.spyOn(globalThis, "fetch" as never).mockResolvedValue({
|
const fetchSpy = vi
|
||||||
|
.spyOn(globalThis, "fetch" as never)
|
||||||
|
.mockResolvedValue({
|
||||||
ok: true,
|
ok: true,
|
||||||
status: 200,
|
status: 200,
|
||||||
statusText: "OK",
|
statusText: "OK",
|
||||||
headers: { get: () => "image/png" },
|
headers: { get: () => "image/png" },
|
||||||
arrayBuffer: async () => new Uint8Array([0x89, 0x50, 0x4e, 0x47]).buffer,
|
arrayBuffer: async () =>
|
||||||
|
new Uint8Array([0x89, 0x50, 0x4e, 0x47]).buffer,
|
||||||
} as Response);
|
} as Response);
|
||||||
|
|
||||||
createTelegramBot({
|
createTelegramBot({
|
||||||
@@ -306,9 +316,13 @@ describe("telegram media groups", () => {
|
|||||||
expect(payload.MediaPaths).toHaveLength(2);
|
expect(payload.MediaPaths).toHaveLength(2);
|
||||||
|
|
||||||
fetchSpy.mockRestore();
|
fetchSpy.mockRestore();
|
||||||
}, 10_000);
|
},
|
||||||
|
MEDIA_GROUP_TEST_TIMEOUT_MS,
|
||||||
|
);
|
||||||
|
|
||||||
it("processes separate media groups independently", async () => {
|
it(
|
||||||
|
"processes separate media groups independently",
|
||||||
|
async () => {
|
||||||
const { createTelegramBot } = await import("./bot.js");
|
const { createTelegramBot } = await import("./bot.js");
|
||||||
const replyModule = await import("../auto-reply/reply.js");
|
const replyModule = await import("../auto-reply/reply.js");
|
||||||
const replySpy = replyModule.__replySpy as unknown as ReturnType<
|
const replySpy = replyModule.__replySpy as unknown as ReturnType<
|
||||||
@@ -318,12 +332,15 @@ describe("telegram media groups", () => {
|
|||||||
onSpy.mockReset();
|
onSpy.mockReset();
|
||||||
replySpy.mockReset();
|
replySpy.mockReset();
|
||||||
|
|
||||||
const fetchSpy = vi.spyOn(globalThis, "fetch" as never).mockResolvedValue({
|
const fetchSpy = vi
|
||||||
|
.spyOn(globalThis, "fetch" as never)
|
||||||
|
.mockResolvedValue({
|
||||||
ok: true,
|
ok: true,
|
||||||
status: 200,
|
status: 200,
|
||||||
statusText: "OK",
|
statusText: "OK",
|
||||||
headers: { get: () => "image/png" },
|
headers: { get: () => "image/png" },
|
||||||
arrayBuffer: async () => new Uint8Array([0x89, 0x50, 0x4e, 0x47]).buffer,
|
arrayBuffer: async () =>
|
||||||
|
new Uint8Array([0x89, 0x50, 0x4e, 0x47]).buffer,
|
||||||
} as Response);
|
} as Response);
|
||||||
|
|
||||||
createTelegramBot({ token: "tok" });
|
createTelegramBot({ token: "tok" });
|
||||||
@@ -364,7 +381,9 @@ describe("telegram media groups", () => {
|
|||||||
expect(replySpy).toHaveBeenCalledTimes(2);
|
expect(replySpy).toHaveBeenCalledTimes(2);
|
||||||
|
|
||||||
fetchSpy.mockRestore();
|
fetchSpy.mockRestore();
|
||||||
}, 10_000);
|
},
|
||||||
|
MEDIA_GROUP_TEST_TIMEOUT_MS,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("telegram location parsing", () => {
|
describe("telegram location parsing", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user