From 6676be413eea79cfa27fd42d441f1c2e0160f3a2 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 12 May 2026 23:49:46 +0100 Subject: [PATCH] test: dedupe doctor sandbox mock reads --- ...arns-sandbox-enabled-without-docker.test.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/commands/doctor-sandbox.warns-sandbox-enabled-without-docker.test.ts b/src/commands/doctor-sandbox.warns-sandbox-enabled-without-docker.test.ts index fc279832bbf..5b541c573fc 100644 --- a/src/commands/doctor-sandbox.warns-sandbox-enabled-without-docker.test.ts +++ b/src/commands/doctor-sandbox.warns-sandbox-enabled-without-docker.test.ts @@ -81,15 +81,20 @@ describe("maybeRepairSandboxImages", () => { await maybeRepairSandboxImages(createSandboxConfig(params.mode), mockRuntime, mockPrompter); } + function firstNoteCall() { + const noteCall = note.mock.calls[0]; + if (noteCall === undefined) { + throw new Error("expected sandbox warning note"); + } + return noteCall; + } + it("warns when sandbox mode is enabled but Docker is not available", async () => { await runSandboxRepair({ mode: "non-main", dockerAvailable: false }); // The warning should clearly indicate sandbox is enabled but won't work expect(note).toHaveBeenCalled(); - const noteCall = note.mock.calls.at(0); - if (noteCall === undefined) { - throw new Error("expected sandbox warning note"); - } + const noteCall = firstNoteCall(); const message = noteCall[0] as string; // The message should warn that sandbox mode won't function, not just "skipping checks" @@ -102,10 +107,7 @@ describe("maybeRepairSandboxImages", () => { await runSandboxRepair({ mode: "all", dockerAvailable: false }); expect(note).toHaveBeenCalled(); - const noteCall = note.mock.calls.at(0); - if (noteCall === undefined) { - throw new Error("expected sandbox warning note"); - } + const noteCall = firstNoteCall(); const message = noteCall[0] as string; // Should warn about the impact on sandbox functionality