fix(ci): restore strip-ansi and typecheck fixtures (#39146)

* fix: restore strip-ansi and typecheck fixtures

* test: normalize windows install path assertions
This commit is contained in:
Altay
2026-03-07 23:13:13 +03:00
committed by GitHub
parent 4682f3cace
commit 97f9e25525
8 changed files with 40 additions and 5 deletions

View File

@@ -413,6 +413,7 @@ describe("models-config", () => {
models: {
providers: {
openai: {
baseUrl: "https://api.openai.com/v1",
apiKey: "sk-plaintext-should-not-appear", // already resolved by loadConfig
api: "openai-completions",
models: [

View File

@@ -81,6 +81,7 @@ describe("normalizeProviders", () => {
try {
const providers: NonNullable<NonNullable<OpenClawConfig["models"]>["providers"]> = {
openai: {
baseUrl: "https://api.openai.com/v1",
apiKey: "sk-test-secret-value-12345", // simulates resolved ${OPENAI_API_KEY}
api: "openai-completions",
models: [

View File

@@ -1,3 +1,4 @@
import fsSync from "node:fs";
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
@@ -17,6 +18,20 @@ function normalizeDarwinTmpPath(filePath: string): string {
: filePath;
}
function normalizeComparablePath(filePath: string): string {
const resolved = normalizeDarwinTmpPath(path.resolve(filePath));
const parent = normalizeDarwinTmpPath(path.dirname(resolved));
let comparableParent = parent;
try {
comparableParent = normalizeDarwinTmpPath(fsSync.realpathSync.native(parent));
} catch {
comparableParent = parent;
}
const basename =
process.platform === "win32" ? path.basename(resolved).toLowerCase() : path.basename(resolved);
return path.join(comparableParent, basename);
}
async function rebindInstallBasePath(params: {
installBaseDir: string;
preservedDir: string;
@@ -37,13 +52,13 @@ async function withInstallBaseReboundOnRealpathCall<T>(params: {
rebindAtCall: number;
run: () => Promise<T>;
}): Promise<T> {
const installBasePath = normalizeDarwinTmpPath(path.resolve(params.installBaseDir));
const installBasePath = normalizeComparablePath(params.installBaseDir);
const realRealpath = fs.realpath.bind(fs);
let installBaseRealpathCalls = 0;
const realpathSpy = vi
.spyOn(fs, "realpath")
.mockImplementation(async (...args: Parameters<typeof fs.realpath>) => {
const filePath = normalizeDarwinTmpPath(path.resolve(String(args[0])));
const filePath = normalizeComparablePath(String(args[0]));
if (filePath === installBasePath) {
installBaseRealpathCalls += 1;
if (installBaseRealpathCalls === params.rebindAtCall) {

View File

@@ -1,3 +1,4 @@
import fs from "node:fs";
import path from "node:path";
import { expect } from "vitest";
@@ -7,6 +8,15 @@ function normalizeDarwinTmpPath(filePath: string): string {
: filePath;
}
function canonicalizeComparableDir(dirPath: string): string {
const normalized = normalizeDarwinTmpPath(path.resolve(dirPath));
try {
return normalizeDarwinTmpPath(fs.realpathSync.native(normalized));
} catch {
return normalized;
}
}
export function expectSingleNpmInstallIgnoreScriptsCall(params: {
calls: Array<[unknown, { cwd?: string } | undefined]>;
expectedTargetDir: string;
@@ -27,9 +37,11 @@ export function expectSingleNpmInstallIgnoreScriptsCall(params: {
"--ignore-scripts",
]);
expect(opts?.cwd).toBeTruthy();
const cwd = normalizeDarwinTmpPath(String(opts?.cwd));
const expectedTargetDir = normalizeDarwinTmpPath(params.expectedTargetDir);
expect(path.dirname(cwd)).toBe(path.dirname(expectedTargetDir));
const cwd = String(opts?.cwd);
const expectedTargetDir = params.expectedTargetDir;
expect(canonicalizeComparableDir(path.dirname(cwd))).toBe(
canonicalizeComparableDir(path.dirname(expectedTargetDir)),
);
expect(path.basename(cwd)).toMatch(/^\.openclaw-install-stage-/);
}