From 9b83e462cff1502edcd902dab29862c1f2b3a7f6 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Fri, 3 Apr 2026 22:57:09 +0900 Subject: [PATCH] test(channels): use narrow active registries in sticky tests --- .../monitor/native-command.plugin-dispatch.test.ts | 5 +++-- extensions/line/src/bot-message-context.test.ts | 13 +++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/extensions/discord/src/monitor/native-command.plugin-dispatch.test.ts b/extensions/discord/src/monitor/native-command.plugin-dispatch.test.ts index be80161e193..37d676b060f 100644 --- a/extensions/discord/src/monitor/native-command.plugin-dispatch.test.ts +++ b/extensions/discord/src/monitor/native-command.plugin-dispatch.test.ts @@ -3,7 +3,8 @@ import type { NativeCommandSpec } from "openclaw/plugin-sdk/command-auth"; import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; import { clearPluginCommands, registerPluginCommand } from "openclaw/plugin-sdk/plugin-runtime"; import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { setDefaultChannelPluginRegistryForTests } from "../../../../src/commands/channel-test-helpers.js"; +import { setActivePluginRegistry } from "../../../../src/plugins/runtime.js"; +import { createTestRegistry } from "../../../../src/test-utils/channel-plugins.js"; import { createMockCommandInteraction, type MockCommandInteraction, @@ -338,7 +339,7 @@ describe("Discord native plugin command dispatch", () => { beforeEach(async () => { vi.clearAllMocks(); clearPluginCommands(); - setDefaultChannelPluginRegistryForTests(); + setActivePluginRegistry(createTestRegistry()); const actualPluginRuntime = await vi.importActual< typeof import("openclaw/plugin-sdk/plugin-runtime") >("openclaw/plugin-sdk/plugin-runtime"); diff --git a/extensions/line/src/bot-message-context.test.ts b/extensions/line/src/bot-message-context.test.ts index 092abe741c8..748e87aaea7 100644 --- a/extensions/line/src/bot-message-context.test.ts +++ b/extensions/line/src/bot-message-context.test.ts @@ -6,7 +6,8 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; import { getSessionBindingService } from "openclaw/plugin-sdk/conversation-runtime"; import { __testing as sessionBindingTesting } from "openclaw/plugin-sdk/conversation-runtime"; import { afterEach, beforeEach, describe, expect, it } from "vitest"; -import { setDefaultChannelPluginRegistryForTests } from "../../../src/commands/channel-test-helpers.js"; +import { setActivePluginRegistry } from "../../../src/plugins/runtime.js"; +import { createTestRegistry } from "../../../src/test-utils/channel-plugins.js"; import { buildLineMessageContext, buildLinePostbackContext } from "./bot-message-context.js"; import { linePlugin } from "./channel.js"; import type { ResolvedLineAccount } from "./types.js"; @@ -59,7 +60,15 @@ describe("buildLineMessageContext", () => { }) as PostbackEvent; beforeEach(async () => { - setDefaultChannelPluginRegistryForTests(); + setActivePluginRegistry( + createTestRegistry([ + { + pluginId: linePlugin.id, + plugin: linePlugin, + source: "test", + }, + ]), + ); sessionBindingTesting.resetSessionBindingAdaptersForTests(); tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-line-context-")); storePath = path.join(tmpDir, "sessions.json");