diff --git a/extensions/qqbot/src/engine/api/media-chunked.test.ts b/extensions/qqbot/src/engine/api/media-chunked.test.ts index 1b2f764af88..a51aea87d99 100644 --- a/extensions/qqbot/src/engine/api/media-chunked.test.ts +++ b/extensions/qqbot/src/engine/api/media-chunked.test.ts @@ -20,6 +20,12 @@ import type { UploadCacheAdapter } from "./media.js"; import { UPLOAD_PREPARE_FALLBACK_CODE } from "./retry.js"; import type { TokenManager } from "./token.js"; +const fetchWithSsrFGuardMock = vi.hoisted(() => vi.fn()); + +vi.mock("openclaw/plugin-sdk/ssrf-runtime", () => ({ + fetchWithSsrFGuard: fetchWithSsrFGuardMock, +})); + // ============ Test doubles ============ /** Build a minimal ApiClient stub whose `request` is fully mockable. */ @@ -82,18 +88,17 @@ const FIXTURE_BUFFER = Buffer.from("0123456789abcdefghij"); // 20 bytes let originalFetch: typeof globalThis.fetch; function stubFetchOk(): ReturnType { - const spy = vi.fn( - async () => - new Response("", { - status: 200, - headers: { - ETag: '"etag-value"', - "x-cos-request-id": "req-id", - }, - }), - ); - globalThis.fetch = spy as unknown as typeof globalThis.fetch; - return spy; + fetchWithSsrFGuardMock.mockImplementation(async () => ({ + response: new Response("", { + status: 200, + headers: { + ETag: '"etag-value"', + "x-cos-request-id": "req-id", + }, + }), + release: vi.fn(), + })); + return fetchWithSsrFGuardMock; } // ============ Tests ============ @@ -122,6 +127,7 @@ describe("media-chunked: ChunkedMediaApi.uploadChunked", () => { afterEach(() => { globalThis.fetch = originalFetch; + fetchWithSsrFGuardMock.mockReset(); vi.restoreAllMocks(); }); @@ -235,7 +241,7 @@ describe("media-chunked: ChunkedMediaApi.uploadChunked", () => { // 3 COS PUTs, one per part, each to the presigned URL. expect(fetchSpy).toHaveBeenCalledTimes(3); - const putUrls = fetchSpy.mock.calls.map((c) => c[0]); + const putUrls = fetchSpy.mock.calls.map((c) => (c[0] as { url: string }).url); expect(putUrls).toEqual( expect.arrayContaining([ "https://cos.example.com/part-1", diff --git a/extensions/voice-call/src/runtime.test.ts b/extensions/voice-call/src/runtime.test.ts index bdb4490938a..b0e6371a340 100644 --- a/extensions/voice-call/src/runtime.test.ts +++ b/extensions/voice-call/src/runtime.test.ts @@ -88,6 +88,10 @@ vi.mock("openclaw/plugin-sdk/memory-host-search", () => ({ getActiveMemorySearchManager: mocks.getActiveMemorySearchManager, })); +vi.mock("../../../src/plugins/memory-runtime.js", () => ({ + getActiveMemorySearchManager: mocks.getActiveMemorySearchManager, +})); + vi.mock("./tunnel.js", () => ({ startTunnel: mocks.startTunnel, }));