mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
test(plugin-sdk): remove repo-local test helper fossils (#121190)
This commit is contained in:
committed by
GitHub
parent
65dc1d0220
commit
40dbc7a65a
@@ -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` |
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
});
|
||||
@@ -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,
|
||||
});
|
||||
});
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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?.(
|
||||
|
||||
@@ -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",
|
||||
});
|
||||
});
|
||||
@@ -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,
|
||||
});
|
||||
});
|
||||
@@ -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: [
|
||||
|
||||
@@ -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",
|
||||
});
|
||||
});
|
||||
@@ -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,
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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");
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -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"),
|
||||
|
||||
@@ -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 = <T extends object>(params: {
|
||||
pluginId: string;
|
||||
artifactBasename: string;
|
||||
}) => Promise<T>;
|
||||
|
||||
// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Test loaders use caller-supplied module surface types.
|
||||
type BundledPluginPublicSurfaceLoader = <T extends object>(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;
|
||||
}
|
||||
|
||||
@@ -829,7 +829,6 @@ describe("plugin-sdk subpath exports", () => {
|
||||
"QUEUED_USER_MESSAGE_MARKER",
|
||||
]);
|
||||
expectSourceMentions("channel-test-helpers", [
|
||||
"assertBundledChannelEntries",
|
||||
"formatEnvelopeTimestamp",
|
||||
"expectPairingReplyText",
|
||||
]);
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user