mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-08 06:54:24 +00:00
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:
@@ -377,6 +377,7 @@
|
||||
"qrcode-terminal": "^0.12.0",
|
||||
"sharp": "^0.34.5",
|
||||
"sqlite-vec": "0.1.7-alpha.2",
|
||||
"strip-ansi": "^7.2.0",
|
||||
"tar": "7.5.10",
|
||||
"tslog": "^4.10.2",
|
||||
"undici": "^7.22.0",
|
||||
|
||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -163,6 +163,9 @@ importers:
|
||||
sqlite-vec:
|
||||
specifier: 0.1.7-alpha.2
|
||||
version: 0.1.7-alpha.2
|
||||
strip-ansi:
|
||||
specifier: ^7.2.0
|
||||
version: 7.2.0
|
||||
tar:
|
||||
specifier: 7.5.10
|
||||
version: 7.5.10
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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-/);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ export type AppViewState = {
|
||||
chatAttachments: ChatAttachment[];
|
||||
chatMessages: unknown[];
|
||||
chatToolMessages: unknown[];
|
||||
chatStreamSegments: Array<{ text: string; ts: number }>;
|
||||
chatStream: string | null;
|
||||
chatStreamStartedAt: number | null;
|
||||
chatRunId: string | null;
|
||||
|
||||
@@ -26,6 +26,7 @@ function createProps(overrides: Partial<ChatProps> = {}): ChatProps {
|
||||
fallbackStatus: null,
|
||||
messages: [],
|
||||
toolMessages: [],
|
||||
streamSegments: [],
|
||||
stream: null,
|
||||
streamStartedAt: null,
|
||||
assistantAvatarUrl: null,
|
||||
|
||||
Reference in New Issue
Block a user