From 40dbc7a65a8af246e7098e643a3bf2b15189fe3a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 9 Aug 2026 11:44:18 -0700 Subject: [PATCH] test(plugin-sdk): remove repo-local test helper fossils (#121190) --- docs/plugins/sdk-testing.md | 1 - extensions/discord/index.test.ts | 14 ------- extensions/irc/index.test.ts | 14 ------- extensions/matrix/index.test.ts | 3 -- extensions/slack/index.test.ts | 10 +---- extensions/telegram/index.test.ts | 19 --------- extensions/twitch/index.test.ts | 14 ------- extensions/whatsapp/index.test.ts | 10 ----- extensions/zalo/index.test.ts | 16 -------- src/plugin-sdk/channel-test-helpers.ts | 1 - src/plugin-sdk/plugin-test-contracts.ts | 6 +-- src/plugin-sdk/provider-test-contracts.ts | 1 - .../test-helpers/bundled-channel-entry.ts | 41 ------------------- .../test-helpers/provider-catalog.ts | 5 +-- .../test-helpers/public-surface-loader.ts | 40 ------------------ .../contracts/plugin-sdk-subpaths.test.ts | 1 - test/scripts/lint-suppressions.test.ts | 1 - 17 files changed, 3 insertions(+), 194 deletions(-) delete mode 100644 extensions/discord/index.test.ts delete mode 100644 extensions/irc/index.test.ts delete mode 100644 extensions/telegram/index.test.ts delete mode 100644 extensions/twitch/index.test.ts delete mode 100644 extensions/zalo/index.test.ts delete mode 100644 src/plugin-sdk/test-helpers/bundled-channel-entry.ts diff --git a/docs/plugins/sdk-testing.md b/docs/plugins/sdk-testing.md index ef295e10a710..4326f3171b84 100644 --- a/docs/plugins/sdk-testing.md +++ b/docs/plugins/sdk-testing.md @@ -72,7 +72,6 @@ the focused test subpaths above. | `installChannelSetupContractSuite` | Install generic channel setup contract cases. Import from `plugin-sdk/channel-test-helpers` | | `installChannelStatusContractSuite` | Install generic channel status contract cases. Import from `plugin-sdk/channel-test-helpers` | | `expectDirectoryIds` | Assert channel directory ids from a directory-list function. Import from `plugin-sdk/channel-test-helpers` | -| `assertBundledChannelEntries` | Assert bundled channel entrypoints expose the expected public contract. Import from `plugin-sdk/channel-test-helpers` | | `formatEnvelopeTimestamp` | Format deterministic envelope timestamps. Import from `plugin-sdk/channel-test-helpers` | | `expectPairingReplyText` | Assert channel pairing reply text and extract its code. Import from `plugin-sdk/channel-test-helpers` | | `describePluginRegistrationContract` | Install plugin registration contract checks. Import from `plugin-sdk/plugin-test-contracts` | diff --git a/extensions/discord/index.test.ts b/extensions/discord/index.test.ts deleted file mode 100644 index ad7973803108..000000000000 --- a/extensions/discord/index.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Discord tests cover index plugin behavior. -import { assertBundledChannelEntries } from "openclaw/plugin-sdk/channel-test-helpers"; -import { describe } from "vitest"; -import entry from "./index.js"; -import setupEntry from "./setup-entry.js"; - -describe("discord bundled entries", () => { - assertBundledChannelEntries({ - entry, - expectedId: "discord", - expectedName: "Discord", - setupEntry, - }); -}); diff --git a/extensions/irc/index.test.ts b/extensions/irc/index.test.ts deleted file mode 100644 index f5625e0ad980..000000000000 --- a/extensions/irc/index.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Irc tests cover index plugin behavior. -import { assertBundledChannelEntries } from "openclaw/plugin-sdk/channel-test-helpers"; -import { describe } from "vitest"; -import entry from "./index.js"; -import setupEntry from "./setup-entry.js"; - -describe("irc bundled entries", () => { - assertBundledChannelEntries({ - entry, - expectedId: "irc", - expectedName: "IRC", - setupEntry, - }); -}); diff --git a/extensions/matrix/index.test.ts b/extensions/matrix/index.test.ts index 0364701932a8..eb74060e7862 100644 --- a/extensions/matrix/index.test.ts +++ b/extensions/matrix/index.test.ts @@ -77,9 +77,6 @@ describe("matrix plugin", () => { }); it("keeps runtime bootstrap and CLI metadata out of setup-only registration", () => { - expect(entry.kind).toBe("bundled-channel-entry"); - expect(entry.id).toBe("matrix"); - expect(entry.name).toBe("Matrix"); if (!entry.setChannelRuntime) { throw new Error("expected Matrix runtime setter"); } diff --git a/extensions/slack/index.test.ts b/extensions/slack/index.test.ts index 606abdacb06c..d1a2e0005cdb 100644 --- a/extensions/slack/index.test.ts +++ b/extensions/slack/index.test.ts @@ -1,9 +1,8 @@ // Slack tests cover index plugin behavior. -import { assertBundledChannelEntries } from "openclaw/plugin-sdk/channel-test-helpers"; import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry"; import { createTestPluginApi } from "openclaw/plugin-sdk/plugin-test-api"; import { describe, expect, it, vi } from "vitest"; -import entry from "./index.js"; +import "./index.js"; import setupEntry from "./setup-entry.js"; const httpRegistryMocks = vi.hoisted(() => ({ @@ -32,13 +31,6 @@ vi.mock("./src/http/registry.js", () => ({ })); describe("slack bundled entries", () => { - assertBundledChannelEntries({ - entry, - expectedId: "slack", - expectedName: "Slack", - setupEntry, - }); - it("does not register webhook routes during tool discovery", () => { const registerHttpRoute = vi.fn(); entryContractMocks.registerFull?.( diff --git a/extensions/telegram/index.test.ts b/extensions/telegram/index.test.ts deleted file mode 100644 index d2014a47905f..000000000000 --- a/extensions/telegram/index.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Telegram tests cover index plugin behavior. -import { assertBundledChannelEntries } from "openclaw/plugin-sdk/channel-test-helpers"; -import { beforeEach, describe, vi } from "vitest"; -import entry from "./index.js"; -import setupEntry from "./setup-entry.js"; - -describe("telegram bundled entries", () => { - beforeEach(() => { - vi.useRealTimers(); - }); - - assertBundledChannelEntries({ - entry, - expectedId: "telegram", - expectedName: "Telegram", - setupEntry, - channelMessage: "declares the channel entry without importing the broad api barrel", - }); -}); diff --git a/extensions/twitch/index.test.ts b/extensions/twitch/index.test.ts deleted file mode 100644 index c92aa77f3fdd..000000000000 --- a/extensions/twitch/index.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Twitch tests cover index plugin behavior. -import { assertBundledChannelEntries } from "openclaw/plugin-sdk/channel-test-helpers"; -import { describe } from "vitest"; -import entry from "./index.js"; -import setupEntry from "./setup-entry.js"; - -describe("twitch bundled entries", () => { - assertBundledChannelEntries({ - entry, - expectedId: "twitch", - expectedName: "Twitch", - setupEntry, - }); -}); diff --git a/extensions/whatsapp/index.test.ts b/extensions/whatsapp/index.test.ts index 19ff908372dc..da9a5e70bb0e 100644 --- a/extensions/whatsapp/index.test.ts +++ b/extensions/whatsapp/index.test.ts @@ -1,18 +1,8 @@ // Whatsapp tests cover index plugin behavior. -import { assertBundledChannelEntries } from "openclaw/plugin-sdk/channel-test-helpers"; import { describe, expect, it } from "vitest"; import { whatsappPlugin } from "./channel-plugin-api.js"; -import entry from "./index.js"; -import setupEntry from "./setup-entry.js"; describe("whatsapp bundled entries", () => { - assertBundledChannelEntries({ - entry, - expectedId: "whatsapp", - expectedName: "WhatsApp", - setupEntry, - }); - it("declares account config as channel-restart reload metadata", () => { expect(whatsappPlugin.reload).toEqual({ configPrefixes: [ diff --git a/extensions/zalo/index.test.ts b/extensions/zalo/index.test.ts deleted file mode 100644 index ec6f1ddf3603..000000000000 --- a/extensions/zalo/index.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Zalo tests cover index plugin behavior. -import { assertBundledChannelEntries } from "openclaw/plugin-sdk/channel-test-helpers"; -import { describe } from "vitest"; -import entry from "./index.js"; -import setupEntry from "./setup-entry.js"; - -describe("zalo bundled entries", () => { - assertBundledChannelEntries({ - entry, - expectedId: "zalo", - expectedName: "Zalo", - setupEntry, - channelMessage: "declares the channel plugin without a runtime-barrel cycle", - setupMessage: "declares the setup plugin without a runtime-barrel cycle", - }); -}); diff --git a/src/plugin-sdk/channel-test-helpers.ts b/src/plugin-sdk/channel-test-helpers.ts index f7741ce4bf67..5f5d1537a505 100644 --- a/src/plugin-sdk/channel-test-helpers.ts +++ b/src/plugin-sdk/channel-test-helpers.ts @@ -45,7 +45,6 @@ export { getRequiredHookHandler, registerHookHandlersForTest, } from "./test-helpers/subagent-hooks.js"; -export { assertBundledChannelEntries } from "./test-helpers/bundled-channel-entry.js"; export { escapeRegExp, formatEnvelopeTimestamp, diff --git a/src/plugin-sdk/plugin-test-contracts.ts b/src/plugin-sdk/plugin-test-contracts.ts index 625085583131..0f32d5e79bc6 100644 --- a/src/plugin-sdk/plugin-test-contracts.ts +++ b/src/plugin-sdk/plugin-test-contracts.ts @@ -19,8 +19,4 @@ export { BUNDLED_RUNTIME_SIDECAR_BASENAMES, getPublicArtifactBasename, } from "./test-helpers/public-artifacts.js"; -export { - loadBundledPluginPublicSurface, - loadBundledPluginPublicSurfaceSync, - resolveWorkspacePackagePublicModuleUrl, -} from "./test-helpers/public-surface-loader.js"; +export { loadBundledPluginPublicSurface } from "./test-helpers/public-surface-loader.js"; diff --git a/src/plugin-sdk/provider-test-contracts.ts b/src/plugin-sdk/provider-test-contracts.ts index 7d6fc8be1753..61eb8fa68bfd 100644 --- a/src/plugin-sdk/provider-test-contracts.ts +++ b/src/plugin-sdk/provider-test-contracts.ts @@ -13,7 +13,6 @@ export { expectCodexMissingAuthHint, importProviderRuntimeCatalogModule, loadBundledPluginPublicSurface, - loadBundledPluginPublicSurfaceSync, type ProviderPlugin, } from "./test-helpers/provider-catalog.js"; export { describeProviderContracts } from "./test-helpers/provider-contract.js"; diff --git a/src/plugin-sdk/test-helpers/bundled-channel-entry.ts b/src/plugin-sdk/test-helpers/bundled-channel-entry.ts deleted file mode 100644 index 4e1635b1737c..000000000000 --- a/src/plugin-sdk/test-helpers/bundled-channel-entry.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Contract helper for bundled channel public entrypoint assertions. - */ -import { expect, it } from "vitest"; - -type BundledChannelEntry = { - id: string; - kind?: string; - name: string; -}; - -type BundledChannelSetupEntry = { - kind?: string; - loadSetupPlugin?: unknown; -}; - -export function assertBundledChannelEntries(params: { - entry: BundledChannelEntry; - expectedId: string; - expectedName: string; - setupEntry: BundledChannelSetupEntry; - channelMessage?: string; - setupMessage?: string; -}) { - it( - params.channelMessage ?? "declares the channel plugin without importing the broad api barrel", - () => { - expect(params.entry.kind).toBe("bundled-channel-entry"); - expect(params.entry.id).toBe(params.expectedId); - expect(params.entry.name).toBe(params.expectedName); - }, - ); - - it( - params.setupMessage ?? "declares the setup plugin without importing the broad api barrel", - () => { - expect(params.setupEntry.kind).toBe("bundled-channel-setup-entry"); - expect(typeof params.setupEntry.loadSetupPlugin).toBe("function"); - }, - ); -} diff --git a/src/plugin-sdk/test-helpers/provider-catalog.ts b/src/plugin-sdk/test-helpers/provider-catalog.ts index 85546cf6d66d..affe502c96b4 100644 --- a/src/plugin-sdk/test-helpers/provider-catalog.ts +++ b/src/plugin-sdk/test-helpers/provider-catalog.ts @@ -8,10 +8,7 @@ export { expectCodexMissingAuthHint, } from "../../plugins/provider-runtime.test-support.js"; export type { ProviderPlugin } from "../provider-model-shared.js"; -export { - loadBundledPluginPublicSurface, - loadBundledPluginPublicSurfaceSync, -} from "./public-surface-loader.js"; +export { loadBundledPluginPublicSurface } from "./public-surface-loader.js"; type ProviderRuntimeCatalogModule = Pick< typeof import("openclaw/plugin-sdk/provider-catalog-runtime"), diff --git a/src/plugin-sdk/test-helpers/public-surface-loader.ts b/src/plugin-sdk/test-helpers/public-surface-loader.ts index fdb6377f557d..8642d36b453d 100644 --- a/src/plugin-sdk/test-helpers/public-surface-loader.ts +++ b/src/plugin-sdk/test-helpers/public-surface-loader.ts @@ -39,36 +39,11 @@ function resolveExtensionDirByManifestId(pluginId: string): string { throw new Error(`Unknown bundled plugin id: ${pluginId}`); } -function resolveWorkspacePackageDir(packageName: string): string { - for (const rootName of ["extensions", "packages"]) { - const rootDir = path.resolve(repoRoot, rootName); - for (const entry of fs.readdirSync(rootDir, { withFileTypes: true })) { - if (!entry.isDirectory()) { - continue; - } - const packageDir = path.join(rootDir, entry.name); - const manifest = readJson(path.join(packageDir, "package.json")) as - | { name?: unknown } - | undefined; - if (manifest?.name === packageName) { - return packageDir; - } - } - } - throw new Error(`Unknown workspace package: ${packageName}`); -} - type AsyncBundledPluginPublicSurfaceLoader = (params: { pluginId: string; artifactBasename: string; }) => Promise; -// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Test loaders use caller-supplied module surface types. -type BundledPluginPublicSurfaceLoader = (params: { - pluginId: string; - artifactBasename: string; -}) => T; - export const loadBundledPluginPublicSurface: AsyncBundledPluginPublicSurfaceLoader = async ( params, ) => { @@ -78,18 +53,3 @@ export const loadBundledPluginPublicSurface: AsyncBundledPluginPublicSurfaceLoad ); return await import(pathToFileURL(artifactPath).href); }; - -export const loadBundledPluginPublicSurfaceSync: BundledPluginPublicSurfaceLoader = (_params) => { - throw new Error("Synchronous bundled plugin public-surface loading is not available here"); -}; - -export function resolveWorkspacePackagePublicModuleUrl(params: { - packageName: string; - artifactBasename: string; -}): string { - const artifactPath = resolveSourceArtifactPath( - resolveWorkspacePackageDir(params.packageName), - params.artifactBasename, - ); - return pathToFileURL(artifactPath).href; -} diff --git a/src/plugins/contracts/plugin-sdk-subpaths.test.ts b/src/plugins/contracts/plugin-sdk-subpaths.test.ts index eb90526191b2..f830fc00bf5e 100644 --- a/src/plugins/contracts/plugin-sdk-subpaths.test.ts +++ b/src/plugins/contracts/plugin-sdk-subpaths.test.ts @@ -829,7 +829,6 @@ describe("plugin-sdk subpath exports", () => { "QUEUED_USER_MESSAGE_MARKER", ]); expectSourceMentions("channel-test-helpers", [ - "assertBundledChannelEntries", "formatEnvelopeTimestamp", "expectPairingReplyText", ]); diff --git a/test/scripts/lint-suppressions.test.ts b/test/scripts/lint-suppressions.test.ts index 9124dea0219d..0b4199983f77 100644 --- a/test/scripts/lint-suppressions.test.ts +++ b/test/scripts/lint-suppressions.test.ts @@ -223,7 +223,6 @@ describe("production lint suppressions", () => { "src/plugin-sdk/facade-runtime.ts|typescript/no-unnecessary-type-parameters|3", "src/plugin-sdk/json-store.ts|typescript-eslint/no-unnecessary-type-parameters|1", "src/plugin-sdk/qa-runner-runtime.ts|typescript/no-unnecessary-type-parameters|1", - "src/plugin-sdk/test-helpers/public-surface-loader.ts|typescript/no-unnecessary-type-parameters|1", "src/plugin-sdk/test-helpers/subagent-hooks.ts|typescript/no-unnecessary-type-parameters|1", "src/plugins/hooks.ts|typescript/no-unnecessary-type-parameters|1", "src/plugins/host-hooks.ts|typescript/no-unnecessary-type-parameters|1",