From ab43bbd62bbf04d7f35baac2350b6de189ea6a60 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 30 Mar 2026 13:06:25 +0900 Subject: [PATCH] fix(test): use minimal outbound binding registries --- .../current-conversation-bindings.test.ts | 23 +++++++++++-- .../outbound/session-binding-service.test.ts | 33 +++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/infra/outbound/current-conversation-bindings.test.ts b/src/infra/outbound/current-conversation-bindings.test.ts index a9955c2c83f..297b1784ae3 100644 --- a/src/infra/outbound/current-conversation-bindings.test.ts +++ b/src/infra/outbound/current-conversation-bindings.test.ts @@ -2,7 +2,8 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it } from "vitest"; -import { setDefaultChannelPluginRegistryForTests } from "../../commands/channel-test-helpers.js"; +import { setActivePluginRegistry } from "../../plugins/runtime.js"; +import { createTestRegistry } from "../../test-utils/channel-plugins.js"; import { __testing, bindGenericCurrentConversation, @@ -11,6 +12,24 @@ import { unbindGenericCurrentConversationBindings, } from "./current-conversation-bindings.js"; +function setMinimalCurrentConversationRegistry(): void { + setActivePluginRegistry( + createTestRegistry([ + { + pluginId: "slack", + source: "test", + plugin: { + id: "slack", + meta: { aliases: [] }, + conversationBindings: { + supportsCurrentConversationBinding: true, + }, + }, + }, + ]), + ); +} + describe("generic current-conversation bindings", () => { let previousStateDir: string | undefined; let testStateDir = ""; @@ -19,7 +38,7 @@ describe("generic current-conversation bindings", () => { previousStateDir = process.env.OPENCLAW_STATE_DIR; testStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-current-bindings-")); process.env.OPENCLAW_STATE_DIR = testStateDir; - setDefaultChannelPluginRegistryForTests(); + setMinimalCurrentConversationRegistry(); __testing.resetCurrentConversationBindingsForTests({ deletePersistedFile: true, }); diff --git a/src/infra/outbound/session-binding-service.test.ts b/src/infra/outbound/session-binding-service.test.ts index 0f4036addc4..8083c4664ae 100644 --- a/src/infra/outbound/session-binding-service.test.ts +++ b/src/infra/outbound/session-binding-service.test.ts @@ -1,11 +1,11 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; -import { setDefaultChannelPluginRegistryForTests } from "../../commands/channel-test-helpers.js"; import { createEmptyPluginRegistry } from "../../plugins/registry-empty.js"; import { pinActivePluginChannelRegistry, releasePinnedPluginChannelRegistry, setActivePluginRegistry, } from "../../plugins/runtime.js"; +import { createTestRegistry } from "../../test-utils/channel-plugins.js"; import { __testing, getSessionBindingService, @@ -22,6 +22,35 @@ type SessionBindingServiceModule = typeof import("./session-binding-service.js") const sessionBindingServiceModuleUrl = new URL("./session-binding-service.ts", import.meta.url) .href; +function setMinimalCurrentConversationRegistry(): void { + setActivePluginRegistry( + createTestRegistry([ + { + pluginId: "slack", + source: "test", + plugin: { + id: "slack", + meta: { aliases: [] }, + conversationBindings: { + supportsCurrentConversationBinding: true, + }, + }, + }, + { + pluginId: "msteams", + source: "test", + plugin: { + id: "msteams", + meta: { aliases: [] }, + conversationBindings: { + supportsCurrentConversationBinding: true, + }, + }, + }, + ]), + ); +} + async function importSessionBindingServiceModule( cacheBust: string, ): Promise { @@ -53,7 +82,7 @@ function createRecord(input: SessionBindingBindInput): SessionBindingRecord { describe("session binding service", () => { beforeEach(() => { __testing.resetSessionBindingAdaptersForTests(); - setDefaultChannelPluginRegistryForTests(); + setMinimalCurrentConversationRegistry(); }); it("normalizes conversation refs and infers current placement", async () => {