test: trim timeout-heavy exec and telegram cases

This commit is contained in:
Peter Steinberger
2026-02-16 04:00:53 +00:00
parent 25dc4293bf
commit 83ce48302f
2 changed files with 8 additions and 11 deletions

View File

@@ -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,
},
);

View File

@@ -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: {