test: harden contract registry fixtures

This commit is contained in:
Peter Steinberger
2026-03-28 02:49:26 +00:00
parent c9c1e456d1
commit c69a70714c
3 changed files with 24 additions and 30 deletions

View File

@@ -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();

View File

@@ -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(

View File

@@ -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,
);
});
});