mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-22 22:52:03 +00:00
test: harden contract registry fixtures
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { beforeEach, describe } from "vitest";
|
||||
import { __testing as bluebubblesBindingTesting } from "../../../../extensions/bluebubbles/api.js";
|
||||
import { __testing as iMessageBindingTesting } from "../../../../extensions/imessage/api.js";
|
||||
import { __testing as sessionBindingTesting } from "../../../infra/outbound/session-binding-service.js";
|
||||
import { discordThreadBindingTesting } from "../../../plugin-sdk/discord.js";
|
||||
import { feishuThreadBindingTesting } from "../../../plugin-sdk/feishu-conversation.js";
|
||||
@@ -93,6 +95,8 @@ for (const entry of directoryContractRegistry) {
|
||||
|
||||
describe("session binding contract registry", () => {
|
||||
beforeEach(async () => {
|
||||
bluebubblesBindingTesting.resetBlueBubblesConversationBindingsForTests();
|
||||
iMessageBindingTesting.resetIMessageConversationBindingsForTests();
|
||||
sessionBindingTesting.resetSessionBindingAdaptersForTests();
|
||||
discordThreadBindingTesting.resetThreadBindingsForTests();
|
||||
feishuThreadBindingTesting.resetFeishuThreadBindingsForTests();
|
||||
|
||||
@@ -111,18 +111,16 @@ describe("provider auth-choice contract", () => {
|
||||
},
|
||||
];
|
||||
|
||||
await Promise.all(
|
||||
pluginFallbackScenarios.map(async (provider) => {
|
||||
resolvePluginProvidersMock.mockClear();
|
||||
resolvePluginProvidersMock.mockReturnValue([provider]);
|
||||
await expect(
|
||||
resolvePreferredProviderForAuthChoice({
|
||||
choice: buildProviderPluginMethodChoice(provider.id, provider.auth[0]?.id ?? "default"),
|
||||
}),
|
||||
).resolves.toBe(provider.id);
|
||||
expect(resolvePluginProvidersMock).toHaveBeenCalled();
|
||||
}),
|
||||
);
|
||||
for (const provider of pluginFallbackScenarios) {
|
||||
resolvePluginProvidersMock.mockClear();
|
||||
resolvePluginProvidersMock.mockReturnValue([provider]);
|
||||
await expect(
|
||||
resolvePreferredProviderForAuthChoice({
|
||||
choice: buildProviderPluginMethodChoice(provider.id, provider.auth[0]?.id ?? "default"),
|
||||
}),
|
||||
).resolves.toBe(provider.id);
|
||||
expect(resolvePluginProvidersMock).toHaveBeenCalled();
|
||||
}
|
||||
|
||||
resolvePluginProvidersMock.mockClear();
|
||||
await expect(resolvePreferredProviderForAuthChoice({ choice: "unknown" })).resolves.toBe(
|
||||
|
||||
@@ -92,23 +92,15 @@ describe("plugin loader contract", () => {
|
||||
expectPluginAllowlistContains(vitestCompatConfig?.plugins?.allow, providerPluginIds);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: "keeps bundled web search loading scoped to the web search registry",
|
||||
actual: bundledWebSearchPluginIds,
|
||||
expected: webSearchPluginIds,
|
||||
},
|
||||
{
|
||||
name: "keeps bundled web search allowlist compatibility wired to the web search registry",
|
||||
actual: webSearchAllowlistCompatConfig?.plugins?.allow,
|
||||
expected: webSearchPluginIds,
|
||||
extraEntry: demoAllowEntry,
|
||||
},
|
||||
] as const)("$name", ({ actual, expected, extraEntry }) => {
|
||||
if (Array.isArray(actual) && extraEntry == null) {
|
||||
expect(actual).toEqual(expected);
|
||||
return;
|
||||
}
|
||||
expectPluginAllowlistContains(actual, expected, extraEntry);
|
||||
it("keeps bundled web search loading scoped to the web search registry", () => {
|
||||
expect(bundledWebSearchPluginIds).toEqual(webSearchPluginIds);
|
||||
});
|
||||
|
||||
it("keeps bundled web search allowlist compatibility wired to the web search registry", () => {
|
||||
expectPluginAllowlistContains(
|
||||
webSearchAllowlistCompatConfig?.plugins?.allow,
|
||||
webSearchPluginIds,
|
||||
demoAllowEntry,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user