test: stabilize prepare gate regressions

This commit is contained in:
Josh Lehman
2026-03-05 17:53:57 -08:00
parent f92702b309
commit efadda4988
2 changed files with 10 additions and 1 deletions

View File

@@ -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 () => {

View File

@@ -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");