






















1-import { describe, expect, it, vi } from "vitest";
1+import { afterEach, describe, expect, it, vi } from "vitest";
22import type { OpenClawConfig } from "../config/types.openclaw.js";
33import { loadModelCatalogForBrowse } from "./model-catalog-browse.js";
44import type { ModelCatalogEntry } from "./model-catalog.types.js";
@@ -23,6 +23,10 @@ function config(params: { providerWildcard?: boolean } = {}): OpenClawConfig {
2323}
24242525describe("loadModelCatalogForBrowse", () => {
26+afterEach(() => {
27+vi.useRealTimers();
28+});
29+2630it("uses the read-only catalog for default browse views", async () => {
2731const loadCatalog = vi.fn(async ({ readOnly }: { readOnly: boolean }) =>
2832readOnly ? readOnlyCatalog : fullCatalog,
@@ -79,4 +83,27 @@ describe("loadModelCatalogForBrowse", () => {
7983expect(onTimeout).toHaveBeenCalledExactlyOnceWith(5);
8084await new Promise((resolve) => setTimeout(resolve, 15));
8185});
86+87+it("uses the default timeout when timeoutMs is non-finite", async () => {
88+vi.useFakeTimers();
89+const onTimeout = vi.fn();
90+const loadCatalog = vi.fn(
91+() =>
92+new Promise<ModelCatalogEntry[]>((resolve) => {
93+setTimeout(() => resolve(readOnlyCatalog), 5);
94+}),
95+);
96+97+const resultPromise = loadModelCatalogForBrowse({
98+cfg: config(),
99+ loadCatalog,
100+timeoutMs: Number.NaN,
101+ onTimeout,
102+});
103+104+await vi.advanceTimersByTimeAsync(5);
105+106+await expect(resultPromise).resolves.toBe(readOnlyCatalog);
107+expect(onTimeout).not.toHaveBeenCalled();
108+});
82109});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。