mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 22:31:25 +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:
@@ -16,7 +16,7 @@ const urlToString = (url: Request | URL | string): string => {
|
||||
|
||||
describe("chutes-oauth", () => {
|
||||
it("exchanges code for tokens and stores username as email", async () => {
|
||||
const fetchFn = withFetchPreconnect(async (input, init) => {
|
||||
const fetchFn = withFetchPreconnect(async (input: RequestInfo | URL, init?: RequestInit) => {
|
||||
const url = urlToString(input);
|
||||
if (url === CHUTES_TOKEN_ENDPOINT) {
|
||||
expect(init?.method).toBe("POST");
|
||||
@@ -66,7 +66,7 @@ describe("chutes-oauth", () => {
|
||||
});
|
||||
|
||||
it("refreshes tokens using stored client id and falls back to old refresh token", async () => {
|
||||
const fetchFn = withFetchPreconnect(async (input, init) => {
|
||||
const fetchFn = withFetchPreconnect(async (input: RequestInfo | URL, init?: RequestInit) => {
|
||||
const url = urlToString(input);
|
||||
if (url !== CHUTES_TOKEN_ENDPOINT) {
|
||||
return new Response("not found", { status: 404 });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import * as ssrf from "../../infra/net/ssrf.js";
|
||||
import { withFetchPreconnect } from "../../test-utils/fetch-mock.js";
|
||||
import { type FetchMock, withFetchPreconnect } from "../../test-utils/fetch-mock.js";
|
||||
|
||||
const lookupMock = vi.fn();
|
||||
const resolvePinnedHostname = ssrf.resolvePinnedHostname;
|
||||
@@ -29,8 +29,10 @@ function textResponse(body: string): Response {
|
||||
} as unknown as Response;
|
||||
}
|
||||
|
||||
function setMockFetch(impl?: (...args: unknown[]) => unknown) {
|
||||
const fetchSpy = vi.fn(impl);
|
||||
function setMockFetch(
|
||||
impl: FetchMock = async (_input: RequestInfo | URL, _init?: RequestInit) => textResponse(""),
|
||||
) {
|
||||
const fetchSpy = vi.fn<FetchMock>(impl);
|
||||
global.fetch = withFetchPreconnect(fetchSpy);
|
||||
return fetchSpy;
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ describe("web_search external content wrapping", () => {
|
||||
|
||||
it("wraps Brave result descriptions", async () => {
|
||||
vi.stubEnv("BRAVE_API_KEY", "test-key");
|
||||
const mockFetch = vi.fn(() =>
|
||||
const mockFetch = vi.fn(async (_input: RequestInfo | URL, _init?: RequestInit) =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
json: () =>
|
||||
@@ -233,7 +233,7 @@ describe("web_search external content wrapping", () => {
|
||||
}),
|
||||
} as Response),
|
||||
);
|
||||
global.fetch = mockFetch;
|
||||
global.fetch = withFetchPreconnect(mockFetch);
|
||||
|
||||
const tool = createWebSearchTool({ config: undefined, sandboxed: true });
|
||||
const result = await tool?.execute?.("call-1", { query: "test" });
|
||||
@@ -254,7 +254,7 @@ describe("web_search external content wrapping", () => {
|
||||
it("does not wrap Brave result urls (raw for tool chaining)", async () => {
|
||||
vi.stubEnv("BRAVE_API_KEY", "test-key");
|
||||
const url = "https://example.com/some-page";
|
||||
const mockFetch = vi.fn(() =>
|
||||
const mockFetch = vi.fn(async (_input: RequestInfo | URL, _init?: RequestInit) =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
json: () =>
|
||||
@@ -271,7 +271,7 @@ describe("web_search external content wrapping", () => {
|
||||
}),
|
||||
} as Response),
|
||||
);
|
||||
global.fetch = mockFetch;
|
||||
global.fetch = withFetchPreconnect(mockFetch);
|
||||
|
||||
const tool = createWebSearchTool({ config: undefined, sandboxed: true });
|
||||
const result = await tool?.execute?.("call-1", { query: "unique-test-url-not-wrapped" });
|
||||
@@ -284,7 +284,7 @@ describe("web_search external content wrapping", () => {
|
||||
|
||||
it("does not wrap Brave site names", async () => {
|
||||
vi.stubEnv("BRAVE_API_KEY", "test-key");
|
||||
const mockFetch = vi.fn(() =>
|
||||
const mockFetch = vi.fn(async (_input: RequestInfo | URL, _init?: RequestInit) =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
json: () =>
|
||||
@@ -301,7 +301,7 @@ describe("web_search external content wrapping", () => {
|
||||
}),
|
||||
} as Response),
|
||||
);
|
||||
global.fetch = mockFetch;
|
||||
global.fetch = withFetchPreconnect(mockFetch);
|
||||
|
||||
const tool = createWebSearchTool({ config: undefined, sandboxed: true });
|
||||
const result = await tool?.execute?.("call-1", { query: "unique-test-site-name-wrapping" });
|
||||
@@ -313,7 +313,7 @@ describe("web_search external content wrapping", () => {
|
||||
|
||||
it("does not wrap Brave published ages", async () => {
|
||||
vi.stubEnv("BRAVE_API_KEY", "test-key");
|
||||
const mockFetch = vi.fn(() =>
|
||||
const mockFetch = vi.fn(async (_input: RequestInfo | URL, _init?: RequestInit) =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
json: () =>
|
||||
@@ -331,7 +331,7 @@ describe("web_search external content wrapping", () => {
|
||||
}),
|
||||
} as Response),
|
||||
);
|
||||
global.fetch = mockFetch;
|
||||
global.fetch = withFetchPreconnect(mockFetch);
|
||||
|
||||
const tool = createWebSearchTool({ config: undefined, sandboxed: true });
|
||||
const result = await tool?.execute?.("call-1", {
|
||||
@@ -345,7 +345,7 @@ describe("web_search external content wrapping", () => {
|
||||
|
||||
it("wraps Perplexity content", async () => {
|
||||
vi.stubEnv("PERPLEXITY_API_KEY", "pplx-test");
|
||||
const mockFetch = vi.fn(() =>
|
||||
const mockFetch = vi.fn(async (_input: RequestInfo | URL, _init?: RequestInit) =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
json: () =>
|
||||
@@ -355,7 +355,7 @@ describe("web_search external content wrapping", () => {
|
||||
}),
|
||||
} as Response),
|
||||
);
|
||||
global.fetch = mockFetch;
|
||||
global.fetch = withFetchPreconnect(mockFetch);
|
||||
|
||||
const tool = createWebSearchTool({
|
||||
config: { tools: { web: { search: { provider: "perplexity" } } } },
|
||||
@@ -371,7 +371,7 @@ describe("web_search external content wrapping", () => {
|
||||
it("does not wrap Perplexity citations (raw for tool chaining)", async () => {
|
||||
vi.stubEnv("PERPLEXITY_API_KEY", "pplx-test");
|
||||
const citation = "https://example.com/some-article";
|
||||
const mockFetch = vi.fn((_input?: unknown, _init?: unknown) =>
|
||||
const mockFetch = vi.fn(async (_input: RequestInfo | URL, _init?: RequestInit) =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
json: () =>
|
||||
@@ -381,7 +381,7 @@ describe("web_search external content wrapping", () => {
|
||||
}),
|
||||
} as Response),
|
||||
);
|
||||
global.fetch = mockFetch;
|
||||
global.fetch = withFetchPreconnect(mockFetch);
|
||||
|
||||
const tool = createWebSearchTool({
|
||||
config: { tools: { web: { search: { provider: "perplexity" } } } },
|
||||
|
||||
Reference in New Issue
Block a user