test: harden windows ci coverage

This commit is contained in:
Peter Steinberger 2026-04-03 22:08:27 +01:00
parent 361efd28c9
commit 267b6f595c
No known key found for this signature in database
2 changed files with 16 additions and 2 deletions

View File

@ -751,6 +751,7 @@ describe("update-cli", () => {
const brewRoot = path.join(brewPrefix, "lib", "node_modules");
const pkgRoot = path.join(brewRoot, "openclaw");
const brewNpm = path.join(brewPrefix, "bin", "npm");
const win32PrefixNpm = path.join(brewPrefix, "npm.cmd");
const pathNpmRoot = createCaseDir("nvm-root");
mockPackageInstallStatus(pkgRoot);
pathExists.mockResolvedValue(false);
@ -808,7 +809,9 @@ describe("update-cli", () => {
.mock.calls.find(
([argv]) =>
Array.isArray(argv) &&
path.normalize(String(argv[0] ?? "")) === path.normalize(brewNpm) &&
[path.normalize(brewNpm), path.normalize(win32PrefixNpm)].includes(
path.normalize(String(argv[0] ?? "")),
) &&
argv[1] === "i" &&
argv[2] === "-g" &&
argv[3] === "openclaw@latest",

View File

@ -4,6 +4,7 @@ import type { AddressInfo } from "node:net";
import os from "node:os";
import path from "node:path";
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { withEnvAsync } from "../test-utils/env.js";
const mocks = vi.hoisted(() => ({
readFileWithinRoot: vi.fn(),
@ -27,9 +28,19 @@ vi.mock("./server.runtime.js", () => {
let startMediaServer: typeof import("./server.js").startMediaServer;
let realFetch: typeof import("undici").fetch;
const LOOPBACK_FETCH_ENV = {
HTTP_PROXY: undefined,
HTTPS_PROXY: undefined,
ALL_PROXY: undefined,
http_proxy: undefined,
https_proxy: undefined,
all_proxy: undefined,
NO_PROXY: "127.0.0.1,localhost",
no_proxy: "127.0.0.1,localhost",
} as const;
async function expectOutsideWorkspaceServerResponse(url: string) {
const response = await realFetch(url);
const response = await withEnvAsync(LOOPBACK_FETCH_ENV, () => realFetch(url));
expect(response.status).toBe(400);
expect(await response.text()).toBe("file is outside workspace root");
}