From efadda4988b460e6da07be72994d4951d64239d0 Mon Sep 17 00:00:00 2001 From: Josh Lehman Date: Thu, 5 Mar 2026 17:53:57 -0800 Subject: [PATCH] test: stabilize prepare gate regressions --- src/cli/daemon-cli/install.test.ts | 10 +++++++++- src/infra/process-respawn.test.ts | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cli/daemon-cli/install.test.ts b/src/cli/daemon-cli/install.test.ts index bc488c3acab..cd03bddbedb 100644 --- a/src/cli/daemon-cli/install.test.ts +++ b/src/cli/daemon-cli/install.test.ts @@ -1,4 +1,5 @@ -import { beforeEach, describe, expect, it, vi } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { captureFullEnv } from "../../test-utils/env.js"; import type { DaemonActionResponse } from "./response.js"; const loadConfigMock = vi.hoisted(() => vi.fn()); @@ -118,6 +119,7 @@ vi.mock("../../runtime.js", () => ({ })); const { runDaemonInstall } = await import("./install.js"); +const envSnapshot = captureFullEnv(); describe("runDaemonInstall", () => { beforeEach(() => { @@ -162,6 +164,12 @@ describe("runDaemonInstall", () => { isGatewayDaemonRuntimeMock.mockReturnValue(true); installDaemonServiceAndEmitMock.mockResolvedValue(undefined); service.isLoaded.mockResolvedValue(false); + delete process.env.OPENCLAW_GATEWAY_TOKEN; + delete process.env.CLAWDBOT_GATEWAY_TOKEN; + }); + + afterEach(() => { + envSnapshot.restore(); }); it("fails install when token auth requires an unresolved token SecretRef", async () => { diff --git a/src/infra/process-respawn.test.ts b/src/infra/process-respawn.test.ts index 188b942ebef..06591711c81 100644 --- a/src/infra/process-respawn.test.ts +++ b/src/infra/process-respawn.test.ts @@ -68,6 +68,7 @@ describe("restartGatewayProcessWithFreshPid", () => { }); it("returns supervised when launchd/systemd hints are present", () => { + clearSupervisorHints(); process.env.LAUNCH_JOB_LABEL = "ai.openclaw.gateway"; const result = restartGatewayProcessWithFreshPid(); expect(result.mode).toBe("supervised");