From 88908d5ce61e3237cf424dc30bbd0aedf7a1a50a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 9 Jul 2026 19:32:03 -0400 Subject: [PATCH] perf(test): trim secrets and media setup --- src/secrets/runtime-core-snapshots.test.ts | 2 +- ...untime-provider-and-media-surfaces.test.ts | 2 +- src/secrets/runtime-web-tools.test.ts | 31 ++++++------------- src/secrets/runtime.fast-path.test.ts | 2 +- src/secrets/runtime.test-support.ts | 2 +- test/vitest-scoped-config.test.ts | 1 + .../vitest.media-understanding.config.ts | 1 + 7 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/secrets/runtime-core-snapshots.test.ts b/src/secrets/runtime-core-snapshots.test.ts index 67ee6bfdc6a4..4e68abd2ac06 100644 --- a/src/secrets/runtime-core-snapshots.test.ts +++ b/src/secrets/runtime-core-snapshots.test.ts @@ -6,7 +6,7 @@ import { clearConfigCache, clearRuntimeConfigSnapshot, } from "../config/config.js"; -import { createEmptyPluginRegistry } from "../plugins/registry.js"; +import { createEmptyPluginRegistry } from "../plugins/registry-empty.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { captureEnv, withEnvAsync } from "../test-utils/env.js"; import { diff --git a/src/secrets/runtime-provider-and-media-surfaces.test.ts b/src/secrets/runtime-provider-and-media-surfaces.test.ts index d2288d38db36..c3473b03b7d3 100644 --- a/src/secrets/runtime-provider-and-media-surfaces.test.ts +++ b/src/secrets/runtime-provider-and-media-surfaces.test.ts @@ -4,7 +4,7 @@ import os from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; -import { createEmptyPluginRegistry } from "../plugins/registry.js"; +import { createEmptyPluginRegistry } from "../plugins/registry-empty.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { asConfig, setupSecretsRuntimeSnapshotTestHooks } from "./runtime.test-support.ts"; diff --git a/src/secrets/runtime-web-tools.test.ts b/src/secrets/runtime-web-tools.test.ts index 3c0002af770c..871684582003 100644 --- a/src/secrets/runtime-web-tools.test.ts +++ b/src/secrets/runtime-web-tools.test.ts @@ -71,19 +71,12 @@ let createResolverContext: typeof import("./runtime-shared.js").createResolverCo let resolveRuntimeWebTools: typeof import("./runtime-web-tools.js").resolveRuntimeWebTools; let restoreResolveSecretRefValuesSpy: (() => void) | undefined; -vi.mock("./runtime-web-tools-fallback.runtime.js", async () => { - const actual = await vi.importActual( - "./runtime-web-tools-fallback.runtime.js", - ); - return { - ...actual, - runtimeWebToolsFallbackProviders: { - ...actual.runtimeWebToolsFallbackProviders, - resolvePluginWebSearchProviders: resolvePluginWebSearchProvidersMock, - resolvePluginWebFetchProviders: resolvePluginWebFetchProvidersMock, - }, - }; -}); +vi.mock("./runtime-web-tools-fallback.runtime.js", () => ({ + runtimeWebToolsFallbackProviders: { + resolvePluginWebSearchProviders: resolvePluginWebSearchProvidersMock, + resolvePluginWebFetchProviders: resolvePluginWebFetchProvidersMock, + }, +})); vi.mock("../plugins/web-provider-public-artifacts.explicit.js", () => ({ resolveBundledExplicitWebSearchProvidersFromPublicArtifacts: @@ -106,15 +99,9 @@ vi.mock("./runtime-web-tools-manifest.runtime.js", () => ({ resolveManifestContractPluginIdsByCompatibilityRuntimePathMock, })); -vi.mock("../plugins/installed-plugin-index-records.js", async () => { - const actual = await vi.importActual< - typeof import("../plugins/installed-plugin-index-records.js") - >("../plugins/installed-plugin-index-records.js"); - return { - ...actual, - loadInstalledPluginIndexInstallRecordsSync: loadInstalledPluginIndexInstallRecordsSyncMock, - }; -}); +vi.mock("../plugins/installed-plugin-index-records.js", () => ({ + loadInstalledPluginIndexInstallRecordsSync: loadInstalledPluginIndexInstallRecordsSyncMock, +})); function asConfig(value: unknown): OpenClawConfig { return value as OpenClawConfig; diff --git a/src/secrets/runtime.fast-path.test.ts b/src/secrets/runtime.fast-path.test.ts index f489ee8fcd82..c04835b5a0c6 100644 --- a/src/secrets/runtime.fast-path.test.ts +++ b/src/secrets/runtime.fast-path.test.ts @@ -8,7 +8,7 @@ import type { AuthProfileStore } from "../agents/auth-profiles.js"; import { saveAuthProfileStore } from "../agents/auth-profiles/store.js"; import { clearConfigCache, clearRuntimeConfigSnapshot } from "../config/config.js"; import { resolveOAuthPath } from "../config/paths.js"; -import { createEmptyPluginRegistry } from "../plugins/registry.js"; +import { createEmptyPluginRegistry } from "../plugins/registry-empty.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { closeOpenClawAgentDatabasesForTest } from "../state/openclaw-agent-db.js"; import { clearSecretsRuntimeSnapshot } from "./runtime.js"; diff --git a/src/secrets/runtime.test-support.ts b/src/secrets/runtime.test-support.ts index 1b4cae99fd63..9cfff60fc1a5 100644 --- a/src/secrets/runtime.test-support.ts +++ b/src/secrets/runtime.test-support.ts @@ -2,7 +2,7 @@ import { afterEach, beforeAll, beforeEach, vi } from "vitest"; import type { AuthProfileStore } from "../agents/auth-profiles.js"; import type { OpenClawConfig } from "../config/config.js"; -import { createEmptyPluginRegistry } from "../plugins/registry.js"; +import { createEmptyPluginRegistry } from "../plugins/registry-empty.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import type { PluginWebSearchProviderEntry } from "../plugins/types.js"; diff --git a/test/vitest-scoped-config.test.ts b/test/vitest-scoped-config.test.ts index 4aa6bd1385f0..226b0c779e00 100644 --- a/test/vitest-scoped-config.test.ts +++ b/test/vitest-scoped-config.test.ts @@ -975,6 +975,7 @@ describe("scoped vitest configs", () => { const testConfig = requireTestConfig(defaultMediaUnderstandingConfig); expect(testConfig.dir).toBe(path.join(process.cwd(), "src")); expect(testConfig.include).toEqual(["media-understanding/**/*.test.ts"]); + expect(normalizeConfigPaths(testConfig.setupFiles)).toEqual(["test/setup.ts"]); }); it("keeps tooling tests in their own lane", () => { diff --git a/test/vitest/vitest.media-understanding.config.ts b/test/vitest/vitest.media-understanding.config.ts index ce4a75ba1fac..a2e87b956679 100644 --- a/test/vitest/vitest.media-understanding.config.ts +++ b/test/vitest/vitest.media-understanding.config.ts @@ -5,6 +5,7 @@ export function createMediaUnderstandingVitestConfig(env?: Record