



























@@ -35,21 +35,37 @@ const {
3535resolveBundledWebFetchProvidersFromPublicArtifactsMock: vi.fn(() => buildTestWebFetchProviders()),
3636}));
3737const {
38+ resolveManifestContractPluginIdsMock,
3839 resolveManifestContractPluginIdsByCompatibilityRuntimePathMock,
3940 resolveManifestContractOwnerPluginIdMock,
40- runtimeManifestActual,
4141} = vi.hoisted(() => ({
42+resolveManifestContractPluginIdsMock: vi.fn(() => [
43+"brave",
44+"duckduckgo",
45+"google",
46+"moonshot",
47+"perplexity",
48+"xai",
49+]),
4250resolveManifestContractPluginIdsByCompatibilityRuntimePathMock: vi.fn(() => ["brave"]),
43-resolveManifestContractOwnerPluginIdMock: vi.fn(),
44-runtimeManifestActual: {
45-resolveManifestContractOwnerPluginId: undefined as
46-| typeof import("./runtime-web-tools-manifest.runtime.js").resolveManifestContractOwnerPluginId
47-| undefined,
48-},
51+resolveManifestContractOwnerPluginIdMock: vi.fn(
52+({ value }: { value: string }) =>
53+(
54+({
55+brave: "brave",
56+firecrawl: "firecrawl",
57+gemini: "google",
58+grok: "xai",
59+kimi: "moonshot",
60+perplexity: "perplexity",
61+}) as Record<string, string | undefined>
62+)[value],
63+),
4964}));
5065let secretResolve: typeof import("./resolve.js");
5166let createResolverContext: typeof import("./runtime-shared.js").createResolverContext;
5267let resolveRuntimeWebTools: typeof import("./runtime-web-tools.js").resolveRuntimeWebTools;
68+let restoreResolveSecretRefValuesSpy: (() => void) | undefined;
53695470vi.mock("./runtime-web-tools-fallback.runtime.js", async () => {
5571const actual = await vi.importActual<typeof import("./runtime-web-tools-fallback.runtime.js")>(
@@ -79,22 +95,12 @@ vi.mock("./runtime-web-tools-public-artifacts.runtime.js", () => ({
7995resolveBundledWebFetchProvidersFromPublicArtifactsMock,
8096}));
819782-vi.mock("./runtime-web-tools-manifest.runtime.js", async () => {
83-const actual = await vi.importActual<typeof import("./runtime-web-tools-manifest.runtime.js")>(
84-"./runtime-web-tools-manifest.runtime.js",
85-);
86-runtimeManifestActual.resolveManifestContractOwnerPluginId =
87-actual.resolveManifestContractOwnerPluginId;
88-resolveManifestContractOwnerPluginIdMock.mockImplementation(
89-actual.resolveManifestContractOwnerPluginId,
90-);
91-return {
92- ...actual,
93-resolveManifestContractOwnerPluginId: resolveManifestContractOwnerPluginIdMock,
94-resolveManifestContractPluginIdsByCompatibilityRuntimePath:
95-resolveManifestContractPluginIdsByCompatibilityRuntimePathMock,
96-};
97-});
98+vi.mock("./runtime-web-tools-manifest.runtime.js", () => ({
99+resolveManifestContractPluginIds: resolveManifestContractPluginIdsMock,
100+resolveManifestContractOwnerPluginId: resolveManifestContractOwnerPluginIdMock,
101+resolveManifestContractPluginIdsByCompatibilityRuntimePath:
102+resolveManifestContractPluginIdsByCompatibilityRuntimePathMock,
103+}));
9810499105function asConfig(value: unknown): OpenClawConfig {
100106return value as OpenClawConfig;
@@ -313,16 +319,14 @@ describe("runtime web tools resolution", () => {
313319resolveBundledExplicitWebFetchProvidersFromPublicArtifactsMock.mockClear();
314320resolveBundledWebSearchProvidersFromPublicArtifactsMock.mockClear();
315321resolveBundledWebFetchProvidersFromPublicArtifactsMock.mockClear();
316-resolveManifestContractOwnerPluginIdMock.mockReset();
317-resolveManifestContractOwnerPluginIdMock.mockImplementation(
318-runtimeManifestActual.resolveManifestContractOwnerPluginId!,
319-);
320322resolveManifestContractOwnerPluginIdMock.mockClear();
323+resolveManifestContractPluginIdsMock.mockClear();
321324resolveManifestContractPluginIdsByCompatibilityRuntimePathMock.mockClear();
322325});
323326324327afterEach(() => {
325-vi.restoreAllMocks();
328+restoreResolveSecretRefValuesSpy?.();
329+restoreResolveSecretRefValuesSpy = undefined;
326330});
327331328332it("keeps web search inactive when only web fetch is configured", async () => {
@@ -925,6 +929,7 @@ describe("runtime web tools resolution", () => {
925929926930it("does not resolve web fetch provider SecretRef when web fetch is inactive", async () => {
927931const resolveSpy = vi.spyOn(secretResolve, "resolveSecretRefValues");
932+restoreResolveSecretRefValuesSpy = () => resolveSpy.mockRestore();
928933const { metadata, context } = await runRuntimeWebTools({
929934config: asConfig({
930935plugins: {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。