From 97f9e2552567e2300c33b9abad20441ff9246a67 Mon Sep 17 00:00:00 2001 From: Altay Date: Sat, 7 Mar 2026 23:13:13 +0300 Subject: [PATCH] fix(ci): restore strip-ansi and typecheck fixtures (#39146) * fix: restore strip-ansi and typecheck fixtures * test: normalize windows install path assertions --- package.json | 1 + pnpm-lock.yaml | 3 +++ ...ssing-provider-apikey-from-env-var.test.ts | 1 + ...ls-config.providers.normalize-keys.test.ts | 1 + src/infra/install-package-dir.test.ts | 19 +++++++++++++++++-- src/test-utils/exec-assertions.ts | 18 +++++++++++++++--- ui/src/ui/app-view-state.ts | 1 + ui/src/ui/views/chat.test.ts | 1 + 8 files changed, 40 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 287456d97be..1caca8dc2a8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0dee1e3ba6f..3d3c952482a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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 diff --git a/src/agents/models-config.fills-missing-provider-apikey-from-env-var.test.ts b/src/agents/models-config.fills-missing-provider-apikey-from-env-var.test.ts index 06d7448c78a..0705f597e71 100644 --- a/src/agents/models-config.fills-missing-provider-apikey-from-env-var.test.ts +++ b/src/agents/models-config.fills-missing-provider-apikey-from-env-var.test.ts @@ -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: [ diff --git a/src/agents/models-config.providers.normalize-keys.test.ts b/src/agents/models-config.providers.normalize-keys.test.ts index 95f504ef221..f529ee610bf 100644 --- a/src/agents/models-config.providers.normalize-keys.test.ts +++ b/src/agents/models-config.providers.normalize-keys.test.ts @@ -81,6 +81,7 @@ describe("normalizeProviders", () => { try { const providers: NonNullable["providers"]> = { openai: { + baseUrl: "https://api.openai.com/v1", apiKey: "sk-test-secret-value-12345", // simulates resolved ${OPENAI_API_KEY} api: "openai-completions", models: [ diff --git a/src/infra/install-package-dir.test.ts b/src/infra/install-package-dir.test.ts index cc0abac1b3c..1386f6074fa 100644 --- a/src/infra/install-package-dir.test.ts +++ b/src/infra/install-package-dir.test.ts @@ -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(params: { rebindAtCall: number; run: () => Promise; }): Promise { - 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) => { - const filePath = normalizeDarwinTmpPath(path.resolve(String(args[0]))); + const filePath = normalizeComparablePath(String(args[0])); if (filePath === installBasePath) { installBaseRealpathCalls += 1; if (installBaseRealpathCalls === params.rebindAtCall) { diff --git a/src/test-utils/exec-assertions.ts b/src/test-utils/exec-assertions.ts index 99907a1ad74..58b77f9f730 100644 --- a/src/test-utils/exec-assertions.ts +++ b/src/test-utils/exec-assertions.ts @@ -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-/); } diff --git a/ui/src/ui/app-view-state.ts b/ui/src/ui/app-view-state.ts index c5cf3573ac4..2029bd8f8f4 100644 --- a/ui/src/ui/app-view-state.ts +++ b/ui/src/ui/app-view-state.ts @@ -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; diff --git a/ui/src/ui/views/chat.test.ts b/ui/src/ui/views/chat.test.ts index 8c3828a133a..7fb329aead4 100644 --- a/ui/src/ui/views/chat.test.ts +++ b/ui/src/ui/views/chat.test.ts @@ -26,6 +26,7 @@ function createProps(overrides: Partial = {}): ChatProps { fallbackStatus: null, messages: [], toolMessages: [], + streamSegments: [], stream: null, streamStartedAt: null, assistantAvatarUrl: null,