mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 05:01:15 +00:00
fix: harden telegram and loader contracts
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { withBundledPluginAllowlistCompat } from "../bundled-compat.js";
|
||||
import { loadPluginManifestRegistry } from "../manifest-registry.js";
|
||||
import { __testing as providerTesting } from "../providers.js";
|
||||
import { resolvePluginWebSearchProviders } from "../web-search-providers.js";
|
||||
import { providerContractCompatPluginIds, webSearchProviderContractRegistry } from "./registry.js";
|
||||
import { uniqueSortedStrings } from "./testkit.js";
|
||||
|
||||
function resolveBundledManifestProviderPluginIds() {
|
||||
return uniqueSortedStrings(
|
||||
loadPluginManifestRegistry({})
|
||||
.plugins.filter((plugin) => plugin.origin === "bundled" && plugin.providers.length > 0)
|
||||
.map((plugin) => plugin.id),
|
||||
);
|
||||
}
|
||||
|
||||
describe("plugin loader contract", () => {
|
||||
beforeEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
@@ -12,6 +21,7 @@ describe("plugin loader contract", () => {
|
||||
|
||||
it("keeps bundled provider compatibility wired to the provider registry", () => {
|
||||
const providerPluginIds = uniqueSortedStrings(providerContractCompatPluginIds);
|
||||
const manifestProviderPluginIds = resolveBundledManifestProviderPluginIds();
|
||||
const compatPluginIds = providerTesting.resolveBundledProviderCompatPluginIds({
|
||||
config: {
|
||||
plugins: {
|
||||
@@ -29,18 +39,22 @@ describe("plugin loader contract", () => {
|
||||
pluginIds: compatPluginIds,
|
||||
});
|
||||
|
||||
expect(providerPluginIds).toEqual(manifestProviderPluginIds);
|
||||
expect(uniqueSortedStrings(compatPluginIds)).toEqual(manifestProviderPluginIds);
|
||||
expect(uniqueSortedStrings(compatPluginIds)).toEqual(expect.arrayContaining(providerPluginIds));
|
||||
expect(compatConfig?.plugins?.allow).toEqual(expect.arrayContaining(providerPluginIds));
|
||||
});
|
||||
|
||||
it("keeps vitest bundled provider enablement wired to the provider registry", () => {
|
||||
const providerPluginIds = uniqueSortedStrings(providerContractCompatPluginIds);
|
||||
const manifestProviderPluginIds = resolveBundledManifestProviderPluginIds();
|
||||
const compatConfig = providerTesting.withBundledProviderVitestCompat({
|
||||
config: undefined,
|
||||
pluginIds: providerPluginIds,
|
||||
env: { VITEST: "1" } as NodeJS.ProcessEnv,
|
||||
});
|
||||
|
||||
expect(providerPluginIds).toEqual(manifestProviderPluginIds);
|
||||
expect(compatConfig?.plugins).toMatchObject({
|
||||
enabled: true,
|
||||
allow: expect.arrayContaining(providerPluginIds),
|
||||
|
||||
Reference in New Issue
Block a user