From 596f7a5cdacfe8a832782829213cc6048d40d280 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 13 May 2026 04:39:58 +0100 Subject: [PATCH] test: dedupe pty fallback mock reads --- .../bash-tools.exec-runtime.pty-fallback.test.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/agents/bash-tools.exec-runtime.pty-fallback.test.ts b/src/agents/bash-tools.exec-runtime.pty-fallback.test.ts index 452e7f18690..3f258af15ab 100644 --- a/src/agents/bash-tools.exec-runtime.pty-fallback.test.ts +++ b/src/agents/bash-tools.exec-runtime.pty-fallback.test.ts @@ -80,6 +80,14 @@ function runPtyFallback(warnings: string[] = []) { }); } +function spawnInput(index: number): SpawnInput { + const call = supervisorSpawnMock.mock.calls[index] as [SpawnInput] | undefined; + if (!call) { + throw new Error(`expected supervisor spawn call ${index}`); + } + return call[0]; +} + test("exec falls back when PTY spawn fails", async () => { supervisorSpawnMock .mockRejectedValueOnce(new Error("pty spawn failed")) @@ -92,10 +100,8 @@ test("exec falls back when PTY spawn fails", async () => { expect(outcome.status).toBe("completed"); expect(outcome.aggregated).toContain("ok"); expect(warnings.join("\n")).toContain("PTY spawn failed"); - const firstSpawnInput = supervisorSpawnMock.mock.calls.at(0)?.[0] as SpawnInput | undefined; - const secondSpawnInput = supervisorSpawnMock.mock.calls.at(1)?.[0] as SpawnInput | undefined; - expect(firstSpawnInput?.mode).toBe("pty"); - expect(secondSpawnInput?.mode).toBe("child"); + expect(spawnInput(0).mode).toBe("pty"); + expect(spawnInput(1).mode).toBe("child"); }); test("exec cleans session state when PTY fallback spawn also fails", async () => {