From 83ce48302f98db74a6ed6c4037995f82a6922a57 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 16 Feb 2026 04:00:53 +0000 Subject: [PATCH] test: trim timeout-heavy exec and telegram cases --- src/process/exec.test.ts | 13 +++++-------- src/telegram/bot.create-telegram-bot.test.ts | 6 +++--- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/process/exec.test.ts b/src/process/exec.test.ts index 0548da97284..3052c6ea763 100644 --- a/src/process/exec.test.ts +++ b/src/process/exec.test.ts @@ -37,17 +37,14 @@ describe("runCommandWithTimeout", () => { }); it("kills command when no output timeout elapses", async () => { - const startedAt = Date.now(); const result = await runCommandWithTimeout( [process.execPath, "-e", "setTimeout(() => {}, 10_000)"], { timeoutMs: 5_000, - noOutputTimeoutMs: 200, + noOutputTimeoutMs: 100, }, ); - const durationMs = Date.now() - startedAt; - expect(durationMs).toBeLessThan(1_500); expect(result.termination).toBe("no-output-timeout"); expect(result.noOutputTimedOut).toBe(true); expect(result.code).not.toBe(0); @@ -58,25 +55,25 @@ describe("runCommandWithTimeout", () => { [ process.execPath, "-e", - 'let i=0; const t=setInterval(() => { process.stdout.write("."); i += 1; if (i >= 4) { clearInterval(t); process.exit(0); } }, 30);', + 'let i=0; const t=setInterval(() => { process.stdout.write("."); i += 1; if (i >= 3) { clearInterval(t); process.exit(0); } }, 20);', ], { timeoutMs: 5_000, - noOutputTimeoutMs: 200, + noOutputTimeoutMs: 100, }, ); expect(result.code).toBe(0); expect(result.termination).toBe("exit"); expect(result.noOutputTimedOut).toBe(false); - expect(result.stdout.length).toBeGreaterThanOrEqual(4); + expect(result.stdout.length).toBeGreaterThanOrEqual(3); }); it("reports global timeout termination when overall timeout elapses", async () => { const result = await runCommandWithTimeout( [process.execPath, "-e", "setTimeout(() => {}, 10_000)"], { - timeoutMs: 120, + timeoutMs: 80, }, ); diff --git a/src/telegram/bot.create-telegram-bot.test.ts b/src/telegram/bot.create-telegram-bot.test.ts index f3935b68b8b..060ef0832b0 100644 --- a/src/telegram/bot.create-telegram-bot.test.ts +++ b/src/telegram/bot.create-telegram-bot.test.ts @@ -69,7 +69,7 @@ describe("createTelegramBot", () => { globalThis.fetch = originalFetch; } }); - it("passes timeoutSeconds even without a custom fetch", () => { + it("applies global and per-account timeoutSeconds", () => { loadConfig.mockReturnValue({ channels: { telegram: { dmPolicy: "open", allowFrom: ["*"], timeoutSeconds: 60 }, @@ -82,8 +82,8 @@ describe("createTelegramBot", () => { client: expect.objectContaining({ timeoutSeconds: 60 }), }), ); - }); - it("prefers per-account timeoutSeconds overrides", () => { + botCtorSpy.mockClear(); + loadConfig.mockReturnValue({ channels: { telegram: {