diff --git a/extensions/mattermost/src/channel.test.ts b/extensions/mattermost/src/channel.test.ts index 20bd467c2c..d746c51aa0 100644 --- a/extensions/mattermost/src/channel.test.ts +++ b/extensions/mattermost/src/channel.test.ts @@ -3,7 +3,7 @@ import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import type { OpenClawConfig } from "../runtime-api.js"; import { createChannelReplyPipeline } from "../runtime-api.js"; -vi.mock("../../../src/config/bundled-channel-config-runtime.js", () => ({ +vi.mock("../../../test/helpers/config/bundled-channel-config-runtime.js", () => ({ getBundledChannelRuntimeMap: () => new Map(), getBundledChannelConfigSchemaMap: () => new Map(), })); diff --git a/extensions/mattermost/src/setup.test.ts b/extensions/mattermost/src/setup.test.ts index 0b213fea16..56508f6b3c 100644 --- a/extensions/mattermost/src/setup.test.ts +++ b/extensions/mattermost/src/setup.test.ts @@ -3,7 +3,7 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite import { createTestPluginApi } from "../../../test/helpers/plugins/plugin-api.js"; import type { OpenClawConfig, OpenClawPluginApi } from "../runtime-api.js"; -vi.mock("../../../src/config/bundled-channel-config-runtime.js", () => ({ +vi.mock("../../../test/helpers/config/bundled-channel-config-runtime.js", () => ({ getBundledChannelRuntimeMap: () => new Map(), getBundledChannelConfigSchemaMap: () => new Map(), })); diff --git a/extensions/nextcloud-talk/src/channel.core.test.ts b/extensions/nextcloud-talk/src/channel.core.test.ts index 46ebda3df6..28d1eff084 100644 --- a/extensions/nextcloud-talk/src/channel.core.test.ts +++ b/extensions/nextcloud-talk/src/channel.core.test.ts @@ -1,7 +1,7 @@ import { beforeAll, describe, expect, it, vi } from "vitest"; import type { CoreConfig } from "./types.js"; -vi.mock("../../../src/config/bundled-channel-config-runtime.js", () => ({ +vi.mock("../../../test/helpers/config/bundled-channel-config-runtime.js", () => ({ getBundledChannelRuntimeMap: () => new Map(), getBundledChannelConfigSchemaMap: () => new Map(), })); diff --git a/extensions/nextcloud-talk/src/channel.lifecycle.test.ts b/extensions/nextcloud-talk/src/channel.lifecycle.test.ts index 2b0474f4d2..b22ce0b606 100644 --- a/extensions/nextcloud-talk/src/channel.lifecycle.test.ts +++ b/extensions/nextcloud-talk/src/channel.lifecycle.test.ts @@ -7,7 +7,7 @@ import { } from "../../../test/helpers/plugins/start-account-lifecycle.js"; import type { ResolvedNextcloudTalkAccount } from "./accounts.js"; -vi.mock("../../../src/config/bundled-channel-config-runtime.js", () => ({ +vi.mock("../../../test/helpers/config/bundled-channel-config-runtime.js", () => ({ getBundledChannelRuntimeMap: () => new Map(), getBundledChannelConfigSchemaMap: () => new Map(), })); diff --git a/src/config/bundled-channel-config-runtime.test.ts b/src/config/bundled-channel-config-runtime.test.ts index e67e62cee5..e375746e8c 100644 --- a/src/config/bundled-channel-config-runtime.test.ts +++ b/src/config/bundled-channel-config-runtime.test.ts @@ -12,8 +12,11 @@ describe("bundled channel config runtime", () => { })); const runtimeModule = await importFreshModule< - typeof import("./bundled-channel-config-runtime.js") - >(import.meta.url, "./bundled-channel-config-runtime.js?scope=missing-bundled-list"); + typeof import("../../test/helpers/config/bundled-channel-config-runtime.js") + >( + import.meta.url, + "../../test/helpers/config/bundled-channel-config-runtime.js?scope=missing-bundled-list", + ); expect(runtimeModule.getBundledChannelConfigSchemaMap().get("msteams")).toBeDefined(); expect(runtimeModule.getBundledChannelRuntimeMap().get("msteams")).toBeDefined(); @@ -28,9 +31,11 @@ describe("bundled channel config runtime", () => { }; }); - const runtime = await importFreshModule( + const runtime = await importFreshModule< + typeof import("../../test/helpers/config/bundled-channel-config-runtime.js") + >( import.meta.url, - "./bundled-channel-config-runtime.js?scope=tdz-reference-error", + "../../test/helpers/config/bundled-channel-config-runtime.js?scope=tdz-reference-error", ); const configSchemaMap = runtime.getBundledChannelConfigSchemaMap(); diff --git a/src/secrets/channel-contract-surface-guardrails.test.ts b/src/secrets/channel-contract-surface-guardrails.test.ts index 9be86cc480..dd04b65ac1 100644 --- a/src/secrets/channel-contract-surface-guardrails.test.ts +++ b/src/secrets/channel-contract-surface-guardrails.test.ts @@ -39,14 +39,6 @@ const CORE_SECRET_SURFACE_GUARDS = [ /\bformatWhatsAppConfigAllowFromEntries\b/, ], }, - { - path: "src/config/bundled-channel-config-runtime.ts", - forbiddenPatterns: [ - /\bstaticBundledChannelSchemas\b/, - /\bMSTeamsConfigSchema\b/, - /\bWhatsAppConfigSchema\b/, - ], - }, { path: "src/plugin-sdk/command-auth.ts", forbiddenPatterns: [/\bpluginId:\s*"telegram"/], diff --git a/src/config/bundled-channel-config-runtime.ts b/test/helpers/config/bundled-channel-config-runtime.ts similarity index 84% rename from src/config/bundled-channel-config-runtime.ts rename to test/helpers/config/bundled-channel-config-runtime.ts index fc0a56f646..6db0938e42 100644 --- a/src/config/bundled-channel-config-runtime.ts +++ b/test/helpers/config/bundled-channel-config-runtime.ts @@ -1,9 +1,9 @@ -import * as bundledChannelModule from "../channels/plugins/bundled.js"; +import * as bundledChannelModule from "../../../src/channels/plugins/bundled.js"; import type { ChannelConfigRuntimeSchema, ChannelConfigSchema, -} from "../channels/plugins/types.plugin.js"; -import { listBundledPluginMetadata } from "../plugins/bundled-plugin-metadata.js"; +} from "../../../src/channels/plugins/types.plugin.js"; +import { listBundledPluginMetadata } from "../../../src/plugins/bundled-plugin-metadata.js"; type BundledChannelRuntimeMap = ReadonlyMap; type BundledChannelConfigSchemaMap = ReadonlyMap; @@ -69,9 +69,6 @@ function readBundledChannelPlugins(): readonly BundledChannelPluginShape[] | und const plugins = bundledChannelModule.listBundledChannelPlugins(); return Array.isArray(plugins) ? (plugins as readonly BundledChannelPluginShape[]) : undefined; } catch (error) { - // Circular bundled channel imports can transiently hit TDZ during test/bootstrap - // initialization. Fall back to manifest-published contract surfaces until the - // bundled registry is ready. if (error instanceof ReferenceError) { return undefined; } @@ -86,8 +83,6 @@ function getBundledChannelMaps(): BundledChannelMaps { } const maps = buildBundledChannelMaps(plugins ?? []); - // Tests and some import cycles can temporarily expose an incomplete bundled list. - // Only cache once the exported plugin array is actually available. if (plugins) { cachedBundledChannelMaps = maps; }