diff --git a/src/agents/chutes-oauth.test.ts b/src/agents/chutes-oauth.test.ts index 5ac270699c9..70721bff752 100644 --- a/src/agents/chutes-oauth.test.ts +++ b/src/agents/chutes-oauth.test.ts @@ -6,10 +6,17 @@ import { refreshChutesTokens, } from "./chutes-oauth.js"; +const urlToString = (url: Request | URL | string): string => { + if (typeof url === "string") { + return url; + } + return "url" in url ? url.url : String(url); +}; + describe("chutes-oauth", () => { it("exchanges code for tokens and stores username as email", async () => { const fetchFn: typeof fetch = async (input, init) => { - const url = String(input); + const url = urlToString(input); if (url === CHUTES_TOKEN_ENDPOINT) { expect(init?.method).toBe("POST"); expect( @@ -59,7 +66,7 @@ describe("chutes-oauth", () => { it("refreshes tokens using stored client id and falls back to old refresh token", async () => { const fetchFn: typeof fetch = async (input, init) => { - const url = String(input); + const url = urlToString(input); if (url !== CHUTES_TOKEN_ENDPOINT) { return new Response("not found", { status: 404 }); } diff --git a/src/agents/openai-responses.reasoning-replay.test.ts b/src/agents/openai-responses.reasoning-replay.test.ts index d5e1e2cf585..de4b10cd62d 100644 --- a/src/agents/openai-responses.reasoning-replay.test.ts +++ b/src/agents/openai-responses.reasoning-replay.test.ts @@ -37,7 +37,7 @@ function installFailingFetchCapture() { if (rawBody instanceof ArrayBuffer) { return Buffer.from(new Uint8Array(rawBody)).toString("utf8"); } - return String(rawBody); + return null; })(); lastBody = bodyText ? (JSON.parse(bodyText) as unknown) : undefined; throw new Error("intentional fetch abort (test)"); diff --git a/src/agents/session-write-lock.test.ts b/src/agents/session-write-lock.test.ts index 16c28ae7aa8..bbe26cb7096 100644 --- a/src/agents/session-write-lock.test.ts +++ b/src/agents/session-write-lock.test.ts @@ -103,7 +103,7 @@ describe("acquireSessionWriteLock", () => { }); it("cleans up locks on SIGINT without removing other handlers", async () => { const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-lock-")); - const originalKill = process.kill.bind(process) as typeof process.kill; + const originalKill = process.kill.bind(process); const killCalls: Array = []; let otherHandlerCalled = false; diff --git a/src/commands/chutes-oauth.test.ts b/src/commands/chutes-oauth.test.ts index 9a0e49d0f6c..f958d1acc67 100644 --- a/src/commands/chutes-oauth.test.ts +++ b/src/commands/chutes-oauth.test.ts @@ -19,13 +19,20 @@ async function getFreePort(): Promise { }); } +const urlToString = (url: Request | URL | string): string => { + if (typeof url === "string") { + return url; + } + return "url" in url ? url.url : String(url); +}; + describe("loginChutes", () => { it("captures local redirect and exchanges code for tokens", async () => { const port = await getFreePort(); const redirectUri = `http://127.0.0.1:${port}/oauth-callback`; const fetchFn: typeof fetch = async (input, init) => { - const url = String(input); + const url = urlToString(input); if (url === CHUTES_TOKEN_ENDPOINT) { return new Response( JSON.stringify({ @@ -68,7 +75,7 @@ describe("loginChutes", () => { it("supports manual flow with pasted code", async () => { const fetchFn: typeof fetch = async (input) => { - const url = String(input); + const url = urlToString(input); if (url === CHUTES_TOKEN_ENDPOINT) { return new Response( JSON.stringify({ @@ -107,7 +114,7 @@ describe("loginChutes", () => { it("does not reuse code_verifier as state", async () => { const fetchFn: typeof fetch = async (input) => { - const url = String(input); + const url = urlToString(input); if (url === CHUTES_TOKEN_ENDPOINT) { return new Response( JSON.stringify({ diff --git a/src/infra/warning-filter.test.ts b/src/infra/warning-filter.test.ts index bd3ff1247c2..f16c17ba1d2 100644 --- a/src/infra/warning-filter.test.ts +++ b/src/infra/warning-filter.test.ts @@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { installProcessWarningFilter, shouldIgnoreWarning } from "./warning-filter.js"; const warningFilterKey = Symbol.for("openclaw.warning-filter"); -const baseEmitWarning = process.emitWarning.bind(process) as typeof process.emitWarning; +const baseEmitWarning = process.emitWarning.bind(process); function resetWarningFilterInstallState(): void { const globalState = globalThis as typeof globalThis & {