diff --git a/src/agents/agent-scope.test.ts b/src/agents/agent-scope.test.ts index 487c0a9492..8720d54d4c 100644 --- a/src/agents/agent-scope.test.ts +++ b/src/agents/agent-scope.test.ts @@ -208,22 +208,21 @@ describe("resolveAgentConfig", () => { expect(result?.workspace).toBe("~/openclaw"); }); - // Unix-style paths behave differently on Windows; skip there - it.skipIf(process.platform === "win32")("uses OPENCLAW_HOME for default agent workspace", () => { - vi.stubEnv("OPENCLAW_HOME", "/srv/openclaw-home"); + it("uses OPENCLAW_HOME for default agent workspace", () => { + const home = path.join(path.sep, "srv", "openclaw-home"); + vi.stubEnv("OPENCLAW_HOME", home); const workspace = resolveAgentWorkspaceDir({} as OpenClawConfig, "main"); - expect(workspace).toBe(path.join(path.resolve("/srv/openclaw-home"), ".openclaw", "workspace")); + expect(workspace).toBe(path.join(path.resolve(home), ".openclaw", "workspace")); }); - // Unix-style paths behave differently on Windows; skip there - it.skipIf(process.platform === "win32")("uses OPENCLAW_HOME for default agentDir", () => { - vi.stubEnv("OPENCLAW_HOME", "/srv/openclaw-home"); + it("uses OPENCLAW_HOME for default agentDir", () => { + const home = path.join(path.sep, "srv", "openclaw-home"); + vi.stubEnv("OPENCLAW_HOME", home); + // Clear state dir so it falls back to OPENCLAW_HOME vi.stubEnv("OPENCLAW_STATE_DIR", ""); const agentDir = resolveAgentDir({} as OpenClawConfig, "main"); - expect(agentDir).toBe( - path.join(path.resolve("/srv/openclaw-home"), ".openclaw", "agents", "main", "agent"), - ); + expect(agentDir).toBe(path.join(path.resolve(home), ".openclaw", "agents", "main", "agent")); }); }); diff --git a/src/agents/pi-embedded-runner.test.ts b/src/agents/pi-embedded-runner.test.ts index 698bc8466d..205524e1a2 100644 --- a/src/agents/pi-embedded-runner.test.ts +++ b/src/agents/pi-embedded-runner.test.ts @@ -173,7 +173,6 @@ const readSessionMessages = async (sessionFile: string) => { }; describe("runEmbeddedPiAgent", () => { - const itIfNotWin32 = process.platform === "win32" ? it.skip : it; it("writes models.json into the provided agentDir", async () => { const sessionFile = nextSessionFile(); @@ -288,39 +287,35 @@ describe("runEmbeddedPiAgent", () => { ).rejects.toThrow("Malformed agent session key"); }); - itIfNotWin32( - "persists the first user message before assistant output", - { timeout: 120_000 }, - async () => { - const sessionFile = nextSessionFile(); - const cfg = makeOpenAiConfig(["mock-1"]); - await ensureModels(cfg); + it("persists the first user message before assistant output", { timeout: 120_000 }, async () => { + const sessionFile = nextSessionFile(); + const cfg = makeOpenAiConfig(["mock-1"]); + await ensureModels(cfg); - await runEmbeddedPiAgent({ - sessionId: "session:test", - sessionKey: testSessionKey, - sessionFile, - workspaceDir, - config: cfg, - prompt: "hello", - provider: "openai", - model: "mock-1", - timeoutMs: 5_000, - agentDir, - enqueue: immediateEnqueue, - }); + await runEmbeddedPiAgent({ + sessionId: "session:test", + sessionKey: testSessionKey, + sessionFile, + workspaceDir, + config: cfg, + prompt: "hello", + provider: "openai", + model: "mock-1", + timeoutMs: 5_000, + agentDir, + enqueue: immediateEnqueue, + }); - const messages = await readSessionMessages(sessionFile); - const firstUserIndex = messages.findIndex( - (message) => message?.role === "user" && textFromContent(message.content) === "hello", - ); - const firstAssistantIndex = messages.findIndex((message) => message?.role === "assistant"); - expect(firstUserIndex).toBeGreaterThanOrEqual(0); - if (firstAssistantIndex !== -1) { - expect(firstUserIndex).toBeLessThan(firstAssistantIndex); - } - }, - ); + const messages = await readSessionMessages(sessionFile); + const firstUserIndex = messages.findIndex( + (message) => message?.role === "user" && textFromContent(message.content) === "hello", + ); + const firstAssistantIndex = messages.findIndex((message) => message?.role === "assistant"); + expect(firstUserIndex).toBeGreaterThanOrEqual(0); + if (firstAssistantIndex !== -1) { + expect(firstUserIndex).toBeLessThan(firstAssistantIndex); + } + }); it("persists the user message when prompt fails before assistant output", async () => { const sessionFile = nextSessionFile(); diff --git a/src/agents/workspace.defaults.test.ts b/src/agents/workspace.defaults.test.ts index 1c9ff7fff0..58bf14ccc9 100644 --- a/src/agents/workspace.defaults.test.ts +++ b/src/agents/workspace.defaults.test.ts @@ -7,15 +7,15 @@ afterEach(() => { }); describe("DEFAULT_AGENT_WORKSPACE_DIR", () => { - // Unix-style paths behave differently on Windows; skip there - it.skipIf(process.platform === "win32")("uses OPENCLAW_HOME at module import time", async () => { - vi.stubEnv("OPENCLAW_HOME", "/srv/openclaw-home"); - vi.stubEnv("HOME", "/home/other"); + it("uses OPENCLAW_HOME at module import time", async () => { + const home = path.join(path.sep, "srv", "openclaw-home"); + vi.stubEnv("OPENCLAW_HOME", home); + vi.stubEnv("HOME", path.join(path.sep, "home", "other")); vi.resetModules(); const mod = await import("./workspace.js"); expect(mod.DEFAULT_AGENT_WORKSPACE_DIR).toBe( - path.join(path.resolve("/srv/openclaw-home"), ".openclaw", "workspace"), + path.join(path.resolve(home), ".openclaw", "workspace"), ); }); }); diff --git a/src/config/config.nix-integration-u3-u5-u9.test.ts b/src/config/config.nix-integration-u3-u5-u9.test.ts index 499ddad36d..933f6c1e3b 100644 --- a/src/config/config.nix-integration-u3-u5-u9.test.ts +++ b/src/config/config.nix-integration-u3-u5-u9.test.ts @@ -49,37 +49,33 @@ describe("Nix integration (U3, U5, U9)", () => { }); }); - // Skip on Windows: these tests use Unix-style paths that only make sense on Nix/Unix - it.skipIf(process.platform === "win32")( - "STATE_DIR respects OPENCLAW_HOME when state override is unset", - async () => { - await withEnvOverride( - { OPENCLAW_HOME: "/custom/home", OPENCLAW_STATE_DIR: undefined }, - async () => { - const { STATE_DIR } = await import("./config.js"); - expect(STATE_DIR).toBe(path.resolve("/custom/home/.openclaw")); - }, - ); - }, - ); + it("STATE_DIR respects OPENCLAW_HOME when state override is unset", async () => { + const customHome = path.join(path.sep, "custom", "home"); + await withEnvOverride( + { OPENCLAW_HOME: customHome, OPENCLAW_STATE_DIR: undefined }, + async () => { + const { STATE_DIR } = await import("./config.js"); + expect(STATE_DIR).toBe(path.join(path.resolve(customHome), ".openclaw")); + }, + ); + }); - // Skip on Windows: these tests use Unix-style paths that only make sense on Nix/Unix - it.skipIf(process.platform === "win32")( - "CONFIG_PATH defaults to OPENCLAW_HOME/.openclaw/openclaw.json", - async () => { - await withEnvOverride( - { - OPENCLAW_HOME: "/custom/home", - OPENCLAW_CONFIG_PATH: undefined, - OPENCLAW_STATE_DIR: undefined, - }, - async () => { - const { CONFIG_PATH } = await import("./config.js"); - expect(CONFIG_PATH).toBe(path.resolve("/custom/home/.openclaw/openclaw.json")); - }, - ); - }, - ); + it("CONFIG_PATH defaults to OPENCLAW_HOME/.openclaw/openclaw.json", async () => { + const customHome = path.join(path.sep, "custom", "home"); + await withEnvOverride( + { + OPENCLAW_HOME: customHome, + OPENCLAW_CONFIG_PATH: undefined, + OPENCLAW_STATE_DIR: undefined, + }, + async () => { + const { CONFIG_PATH } = await import("./config.js"); + expect(CONFIG_PATH).toBe( + path.join(path.resolve(customHome), ".openclaw", "openclaw.json"), + ); + }, + ); + }); it("CONFIG_PATH defaults to ~/.openclaw/openclaw.json when env not set", async () => { await withEnvOverride(