mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 21:51:24 +00:00
revert: fix models set catalog validation (#19194)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 7e3b2ff7af
Co-authored-by: sebslight <19554889+sebslight@users.noreply.github.com>
Co-authored-by: sebslight <19554889+sebslight@users.noreply.github.com>
Reviewed-by: @sebslight
This commit is contained in:
@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import * as ssrf from "../../infra/net/ssrf.js";
|
||||
import type { SavedMedia } from "../../media/store.js";
|
||||
import * as mediaStore from "../../media/store.js";
|
||||
import { withFetchPreconnect } from "../../test-utils/fetch-mock.js";
|
||||
import { type FetchMock, withFetchPreconnect } from "../../test-utils/fetch-mock.js";
|
||||
import {
|
||||
fetchWithSlackAuth,
|
||||
resolveSlackAttachmentContent,
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
|
||||
// Store original fetch
|
||||
const originalFetch = globalThis.fetch;
|
||||
let mockFetch: ReturnType<typeof vi.fn>;
|
||||
let mockFetch: ReturnType<typeof vi.fn<FetchMock>>;
|
||||
const createSavedMedia = (filePath: string, contentType: string): SavedMedia => ({
|
||||
id: "saved-media-id",
|
||||
path: filePath,
|
||||
@@ -23,7 +23,9 @@ const createSavedMedia = (filePath: string, contentType: string): SavedMedia =>
|
||||
describe("fetchWithSlackAuth", () => {
|
||||
beforeEach(() => {
|
||||
// Create a new mock for each test
|
||||
mockFetch = vi.fn();
|
||||
mockFetch = vi.fn<FetchMock>(
|
||||
async (_input: RequestInfo | URL, _init?: RequestInit) => new Response(),
|
||||
);
|
||||
globalThis.fetch = withFetchPreconnect(mockFetch);
|
||||
});
|
||||
|
||||
@@ -366,8 +368,9 @@ describe("resolveSlackMedia", () => {
|
||||
return createSavedMedia("/tmp/unknown", "application/octet-stream");
|
||||
});
|
||||
|
||||
mockFetch.mockImplementation(async (input) => {
|
||||
const url = String(input);
|
||||
mockFetch.mockImplementation(async (input: RequestInfo | URL) => {
|
||||
const url =
|
||||
typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
||||
if (url.includes("/a.jpg")) {
|
||||
return new Response(Buffer.from("image a"), {
|
||||
status: 200,
|
||||
|
||||
Reference in New Issue
Block a user