From f4855baf35897d689d81fc2d8ed7305c7d2bcc91 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 4 Apr 2026 09:28:34 +0100 Subject: [PATCH] fix(ci): await async provider test registration --- extensions/amazon-bedrock/index.test.ts | 40 ++++++++++--------- extensions/anthropic-vertex/index.test.ts | 10 ++--- extensions/anthropic/index.test.ts | 16 ++++---- extensions/deepseek/index.test.ts | 6 +-- extensions/google/index.test.ts | 6 +-- extensions/minimax/index.test.ts | 12 +++--- extensions/moonshot/index.test.ts | 4 +- extensions/openai/index.test.ts | 12 +++--- extensions/openai/openai.live.test.ts | 12 +++--- .../provider-catalog.contract-test-support.ts | 12 +++--- extensions/openrouter/index.test.ts | 4 +- extensions/openrouter/openrouter.live.test.ts | 4 +- extensions/xai/index.test.ts | 4 +- extensions/zai/index.test.ts | 8 ++-- src/agents/cache-trace.test.ts | 2 +- src/test-utils/plugin-registration.ts | 16 ++++---- .../helpers/plugins/provider-auth-contract.ts | 6 +-- .../plugins/provider-discovery-contract.ts | 32 +++++++-------- test/helpers/plugins/provider-registration.ts | 8 ++-- .../plugins/provider-runtime-contract.ts | 12 +++--- 20 files changed, 116 insertions(+), 110 deletions(-) diff --git a/extensions/amazon-bedrock/index.test.ts b/extensions/amazon-bedrock/index.test.ts index f337a4080db..dda76f60869 100644 --- a/extensions/amazon-bedrock/index.test.ts +++ b/extensions/amazon-bedrock/index.test.ts @@ -7,10 +7,12 @@ import type { PluginRuntime } from "../../src/plugins/runtime/types.js"; import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-registration.js"; import amazonBedrockPlugin from "./index.js"; -type RegisteredProviderPlugin = ReturnType; +type RegisteredProviderPlugin = Awaited>; /** Register the amazon-bedrock plugin with an optional pluginConfig override. */ -function registerWithConfig(pluginConfig?: Record): RegisteredProviderPlugin { +async function registerWithConfig( + pluginConfig?: Record, +): Promise { const providers: RegisteredProviderPlugin[] = []; const noopLogger = { info() {}, warn() {}, error() {}, debug() {} }; const api = buildPluginApi({ @@ -29,7 +31,7 @@ function registerWithConfig(pluginConfig?: Record): RegisteredP }, }, }); - amazonBedrockPlugin.register(api); + await amazonBedrockPlugin.register(api); const provider = providers[0]; if (!provider) throw new Error("provider registration missing"); return provider; @@ -88,8 +90,8 @@ function callWrappedStream( } describe("amazon-bedrock provider plugin", () => { - it("marks Claude 4.6 Bedrock models as adaptive by default", () => { - const provider = registerSingleProviderPlugin(amazonBedrockPlugin); + it("marks Claude 4.6 Bedrock models as adaptive by default", async () => { + const provider = await registerSingleProviderPlugin(amazonBedrockPlugin); expect( provider.resolveDefaultThinkingLevel?.({ @@ -105,8 +107,8 @@ describe("amazon-bedrock provider plugin", () => { ).toBeUndefined(); }); - it("owns Anthropic-style replay policy for Claude Bedrock models", () => { - const provider = registerSingleProviderPlugin(amazonBedrockPlugin); + it("owns Anthropic-style replay policy for Claude Bedrock models", async () => { + const provider = await registerSingleProviderPlugin(amazonBedrockPlugin); expect( provider.buildReplayPolicy?.({ @@ -126,8 +128,8 @@ describe("amazon-bedrock provider plugin", () => { }); }); - it("disables prompt caching for non-Anthropic Bedrock models", () => { - const provider = registerSingleProviderPlugin(amazonBedrockPlugin); + it("disables prompt caching for non-Anthropic Bedrock models", async () => { + const provider = await registerSingleProviderPlugin(amazonBedrockPlugin); const wrapped = provider.wrapStreamFn?.({ provider: "amazon-bedrock", modelId: "amazon.nova-micro-v1:0", @@ -180,8 +182,8 @@ describe("amazon-bedrock provider plugin", () => { }); describe("guardrail payload injection", () => { - it("does not inject guardrailConfig when guardrail is absent from plugin config", () => { - const provider = registerWithConfig(undefined); + it("does not inject guardrailConfig when guardrail is absent from plugin config", async () => { + const provider = await registerWithConfig(undefined); const result = callWrappedStream(provider, NON_ANTHROPIC_MODEL, MODEL_DESCRIPTOR); expect(result).not.toHaveProperty("_capturedPayload"); @@ -189,8 +191,8 @@ describe("amazon-bedrock provider plugin", () => { expect(result).toMatchObject({ cacheRetention: "none" }); }); - it("injects all four fields when guardrail config includes optional fields", () => { - const provider = registerWithConfig({ + it("injects all four fields when guardrail config includes optional fields", async () => { + const provider = await registerWithConfig({ guardrail: { guardrailIdentifier: "my-guardrail-id", guardrailVersion: "1", @@ -210,8 +212,8 @@ describe("amazon-bedrock provider plugin", () => { }); }); - it("injects only required fields when optional fields are omitted", () => { - const provider = registerWithConfig({ + it("injects only required fields when optional fields are omitted", async () => { + const provider = await registerWithConfig({ guardrail: { guardrailIdentifier: "abc123", guardrailVersion: "DRAFT", @@ -227,8 +229,8 @@ describe("amazon-bedrock provider plugin", () => { }); }); - it("injects guardrailConfig for Anthropic models without cacheRetention: none", () => { - const provider = registerWithConfig({ + it("injects guardrailConfig for Anthropic models without cacheRetention: none", async () => { + const provider = await registerWithConfig({ guardrail: { guardrailIdentifier: "guardrail-anthropic", guardrailVersion: "2", @@ -251,8 +253,8 @@ describe("amazon-bedrock provider plugin", () => { expect(result).not.toHaveProperty("cacheRetention", "none"); }); - it("injects guardrailConfig for non-Anthropic models with cacheRetention: none", () => { - const provider = registerWithConfig({ + it("injects guardrailConfig for non-Anthropic models with cacheRetention: none", async () => { + const provider = await registerWithConfig({ guardrail: { guardrailIdentifier: "guardrail-nova", guardrailVersion: "3", diff --git a/extensions/anthropic-vertex/index.test.ts b/extensions/anthropic-vertex/index.test.ts index 66637dc494d..af2fde917d6 100644 --- a/extensions/anthropic-vertex/index.test.ts +++ b/extensions/anthropic-vertex/index.test.ts @@ -3,8 +3,8 @@ import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin- import anthropicVertexPlugin from "./index.js"; describe("anthropic-vertex provider plugin", () => { - it("resolves the ADC marker through the provider hook", () => { - const provider = registerSingleProviderPlugin(anthropicVertexPlugin); + it("resolves the ADC marker through the provider hook", async () => { + const provider = await registerSingleProviderPlugin(anthropicVertexPlugin); expect( provider.resolveConfigApiKey?.({ @@ -17,7 +17,7 @@ describe("anthropic-vertex provider plugin", () => { }); it("merges the implicit Vertex catalog into explicit provider overrides", async () => { - const provider = registerSingleProviderPlugin(anthropicVertexPlugin); + const provider = await registerSingleProviderPlugin(anthropicVertexPlugin); const result = await provider.catalog?.run({ config: { @@ -57,8 +57,8 @@ describe("anthropic-vertex provider plugin", () => { }); }); - it("owns Anthropic-style replay policy", () => { - const provider = registerSingleProviderPlugin(anthropicVertexPlugin); + it("owns Anthropic-style replay policy", async () => { + const provider = await registerSingleProviderPlugin(anthropicVertexPlugin); expect( provider.buildReplayPolicy?.({ diff --git a/extensions/anthropic/index.test.ts b/extensions/anthropic/index.test.ts index 339aef8ec35..2383a047253 100644 --- a/extensions/anthropic/index.test.ts +++ b/extensions/anthropic/index.test.ts @@ -3,8 +3,8 @@ import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin- import anthropicPlugin from "./index.js"; describe("anthropic provider replay hooks", () => { - it("owns native reasoning output mode for Claude transports", () => { - const provider = registerSingleProviderPlugin(anthropicPlugin); + it("owns native reasoning output mode for Claude transports", async () => { + const provider = await registerSingleProviderPlugin(anthropicPlugin); expect( provider.resolveReasoningOutputMode?.({ @@ -15,8 +15,8 @@ describe("anthropic provider replay hooks", () => { ).toBe("native"); }); - it("owns replay policy for Claude transports", () => { - const provider = registerSingleProviderPlugin(anthropicPlugin); + it("owns replay policy for Claude transports", async () => { + const provider = await registerSingleProviderPlugin(anthropicPlugin); expect( provider.buildReplayPolicy?.({ @@ -36,8 +36,8 @@ describe("anthropic provider replay hooks", () => { }); }); - it("defaults provider api through plugin config normalization", () => { - const provider = registerSingleProviderPlugin(anthropicPlugin); + it("defaults provider api through plugin config normalization", async () => { + const provider = await registerSingleProviderPlugin(anthropicPlugin); expect( provider.normalizeConfig?.({ @@ -51,8 +51,8 @@ describe("anthropic provider replay hooks", () => { }); }); - it("applies Anthropic pruning defaults through plugin hooks", () => { - const provider = registerSingleProviderPlugin(anthropicPlugin); + it("applies Anthropic pruning defaults through plugin hooks", async () => { + const provider = await registerSingleProviderPlugin(anthropicPlugin); const next = provider.applyConfigDefaults?.({ provider: "anthropic", diff --git a/extensions/deepseek/index.test.ts b/extensions/deepseek/index.test.ts index 1cb71a6125c..961e1ecf8ad 100644 --- a/extensions/deepseek/index.test.ts +++ b/extensions/deepseek/index.test.ts @@ -4,8 +4,8 @@ import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin- import deepseekPlugin from "./index.js"; describe("deepseek provider plugin", () => { - it("registers DeepSeek with api-key auth wizard metadata", () => { - const provider = registerSingleProviderPlugin(deepseekPlugin); + it("registers DeepSeek with api-key auth wizard metadata", async () => { + const provider = await registerSingleProviderPlugin(deepseekPlugin); const resolved = resolveProviderPluginChoice({ providers: [provider], choice: "deepseek-api-key", @@ -21,7 +21,7 @@ describe("deepseek provider plugin", () => { }); it("builds the static DeepSeek model catalog", async () => { - const provider = registerSingleProviderPlugin(deepseekPlugin); + const provider = await registerSingleProviderPlugin(deepseekPlugin); expect(provider.catalog).toBeDefined(); const catalog = await provider.catalog!.run({ diff --git a/extensions/google/index.test.ts b/extensions/google/index.test.ts index d526a20b369..5f28be487ae 100644 --- a/extensions/google/index.test.ts +++ b/extensions/google/index.test.ts @@ -11,7 +11,7 @@ import googlePlugin from "./index.js"; describe("google provider plugin hooks", () => { it("owns replay policy and reasoning mode for the direct Gemini provider", async () => { - const { providers } = registerProviderPlugin({ + const { providers } = await registerProviderPlugin({ plugin: googlePlugin, id: "google", name: "Google Provider", @@ -81,8 +81,8 @@ describe("google provider plugin hooks", () => { expect(customEntries[0]?.customType).toBe("google-turn-ordering-bootstrap"); }); - it("owns Gemini CLI tool schema normalization", () => { - const { providers } = registerProviderPlugin({ + it("owns Gemini CLI tool schema normalization", async () => { + const { providers } = await registerProviderPlugin({ plugin: googlePlugin, id: "google", name: "Google Provider", diff --git a/extensions/minimax/index.test.ts b/extensions/minimax/index.test.ts index 89a125cb1b1..3d4a8881a79 100644 --- a/extensions/minimax/index.test.ts +++ b/extensions/minimax/index.test.ts @@ -8,8 +8,8 @@ import { import minimaxPlugin from "./index.js"; describe("minimax provider hooks", () => { - it("keeps native reasoning mode for MiniMax transports", () => { - const { providers } = registerProviderPlugin({ + it("keeps native reasoning mode for MiniMax transports", async () => { + const { providers } = await registerProviderPlugin({ plugin: minimaxPlugin, id: "minimax", name: "MiniMax Provider", @@ -36,8 +36,8 @@ describe("minimax provider hooks", () => { ).toBe("native"); }); - it("owns replay policy for Anthropic and OpenAI-compatible MiniMax transports", () => { - const { providers } = registerProviderPlugin({ + it("owns replay policy for Anthropic and OpenAI-compatible MiniMax transports", async () => { + const { providers } = await registerProviderPlugin({ plugin: minimaxPlugin, id: "minimax", name: "MiniMax Provider", @@ -73,8 +73,8 @@ describe("minimax provider hooks", () => { }); }); - it("owns fast-mode stream wrapping for MiniMax transports", () => { - const { providers } = registerProviderPlugin({ + it("owns fast-mode stream wrapping for MiniMax transports", async () => { + const { providers } = await registerProviderPlugin({ plugin: minimaxPlugin, id: "minimax", name: "MiniMax Provider", diff --git a/extensions/moonshot/index.test.ts b/extensions/moonshot/index.test.ts index 7d56733aafb..2a244d0c9fd 100644 --- a/extensions/moonshot/index.test.ts +++ b/extensions/moonshot/index.test.ts @@ -3,8 +3,8 @@ import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin- import plugin from "./index.js"; describe("moonshot provider plugin", () => { - it("owns replay policy for OpenAI-compatible Moonshot transports", () => { - const provider = registerSingleProviderPlugin(plugin); + it("owns replay policy for OpenAI-compatible Moonshot transports", async () => { + const provider = await registerSingleProviderPlugin(plugin); expect( provider.buildReplayPolicy?.({ diff --git a/extensions/openai/index.test.ts b/extensions/openai/index.test.ts index 4a67ad685a8..eced1162c68 100644 --- a/extensions/openai/index.test.ts +++ b/extensions/openai/index.test.ts @@ -31,16 +31,16 @@ vi.mock("@mariozechner/pi-ai/oauth", async () => { import { refreshOpenAICodexToken } from "./openai-codex-provider.runtime.js"; -const registerOpenAIPlugin = () => +const registerOpenAIPlugin = async () => registerProviderPlugin({ plugin, id: "openai", name: "OpenAI Provider", }); -function registerOpenAIPluginWithHook(params?: { pluginConfig?: Record }) { +async function registerOpenAIPluginWithHook(params?: { pluginConfig?: Record }) { const on = vi.fn(); - plugin.register( + await plugin.register( createTestPluginApi({ id: "openai", name: "OpenAI Provider", @@ -241,7 +241,7 @@ describe("openai plugin", () => { }); it("registers the friendly prompt overlay by default and scopes it to OpenAI providers", async () => { - const { on } = registerOpenAIPluginWithHook(); + const { on } = await registerOpenAIPluginWithHook(); expect(on).toHaveBeenCalledWith("before_prompt_build", expect.any(Function)); const beforePromptBuild = on.mock.calls.find((call) => call[0] === "before_prompt_build")?.[1]; @@ -268,8 +268,8 @@ describe("openai plugin", () => { expect(nonOpenAIResult).toBeUndefined(); }); - it("supports opting out of the prompt overlay via plugin config", () => { - const { on } = registerOpenAIPluginWithHook({ + it("supports opting out of the prompt overlay via plugin config", async () => { + const { on } = await registerOpenAIPluginWithHook({ pluginConfig: { personalityOverlay: "off" }, }); diff --git a/extensions/openai/openai.live.test.ts b/extensions/openai/openai.live.test.ts index a422796860b..b599b89c231 100644 --- a/extensions/openai/openai.live.test.ts +++ b/extensions/openai/openai.live.test.ts @@ -142,7 +142,7 @@ async function createTempAgentDir(): Promise { describeLive("openai plugin live", () => { it("registers an OpenAI provider that can complete a live request", async () => { - const { providers } = registerOpenAIPlugin(); + const { providers } = await registerOpenAIPlugin(); const provider = requireRegisteredProvider(providers, "openai"); const resolved = provider.resolveDynamicModel?.({ @@ -182,7 +182,7 @@ describeLive("openai plugin live", () => { }, 30_000); it("lists voices and synthesizes audio through the registered speech provider", async () => { - const { speechProviders } = registerOpenAIPlugin(); + const { speechProviders } = await registerOpenAIPlugin(); const speechProvider = requireRegisteredProvider(speechProviders, "openai"); const voices = await speechProvider.listVoices?.({}); @@ -217,7 +217,7 @@ describeLive("openai plugin live", () => { }, 45_000); it("transcribes synthesized speech through the registered media provider", async () => { - const { speechProviders, mediaProviders } = registerOpenAIPlugin(); + const { speechProviders, mediaProviders } = await registerOpenAIPlugin(); const speechProvider = requireRegisteredProvider(speechProviders, "openai"); const mediaProvider = requireRegisteredProvider(mediaProviders, "openai"); @@ -247,7 +247,7 @@ describeLive("openai plugin live", () => { }, 45_000); it("generates an image through the registered image provider", async () => { - const { imageProviders } = registerOpenAIPlugin(); + const { imageProviders } = await registerOpenAIPlugin(); const imageProvider = requireRegisteredProvider(imageProviders, "openai"); const cfg = createLiveConfig(); @@ -275,7 +275,7 @@ describeLive("openai plugin live", () => { }, 60_000); it("edits a reference image through the registered image provider", async () => { - const { imageProviders } = registerOpenAIPlugin(); + const { imageProviders } = await registerOpenAIPlugin(); const imageProvider = requireRegisteredProvider(imageProviders, "openai"); const cfg = createLiveConfig(); @@ -311,7 +311,7 @@ describeLive("openai plugin live", () => { }, 60_000); it("describes a deterministic image through the registered media provider", async () => { - const { mediaProviders } = registerOpenAIPlugin(); + const { mediaProviders } = await registerOpenAIPlugin(); const mediaProvider = requireRegisteredProvider(mediaProviders, "openai"); const cfg = createLiveConfig(); diff --git a/extensions/openai/test-support/provider-catalog.contract-test-support.ts b/extensions/openai/test-support/provider-catalog.contract-test-support.ts index 2f861c0f480..81aaf16db81 100644 --- a/extensions/openai/test-support/provider-catalog.contract-test-support.ts +++ b/extensions/openai/test-support/provider-catalog.contract-test-support.ts @@ -62,11 +62,13 @@ export function describeOpenAIProviderCatalogContract() { pluginId: "openai", artifactBasename: "index.js", }); - openaiProviders = registerProviderPlugin({ - plugin: openaiPlugin.default, - id: "openai", - name: "OpenAI", - }).providers; + openaiProviders = ( + await registerProviderPlugin({ + plugin: openaiPlugin.default, + id: "openai", + name: "OpenAI", + }) + ).providers; openaiProvider = requireRegisteredProvider(openaiProviders, "openai", "provider"); ({ augmentModelCatalogWithProviderPlugins, diff --git a/extensions/openrouter/index.test.ts b/extensions/openrouter/index.test.ts index 3bb0ad4cfb0..a0d63058c27 100644 --- a/extensions/openrouter/index.test.ts +++ b/extensions/openrouter/index.test.ts @@ -3,8 +3,8 @@ import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin- import openrouterPlugin from "./index.js"; describe("openrouter provider hooks", () => { - it("owns native reasoning output mode", () => { - const provider = registerSingleProviderPlugin(openrouterPlugin); + it("owns native reasoning output mode", async () => { + const provider = await registerSingleProviderPlugin(openrouterPlugin); expect( provider.resolveReasoningOutputMode?.({ diff --git a/extensions/openrouter/openrouter.live.test.ts b/extensions/openrouter/openrouter.live.test.ts index 87914bc2af9..f3f92bdb1a3 100644 --- a/extensions/openrouter/openrouter.live.test.ts +++ b/extensions/openrouter/openrouter.live.test.ts @@ -16,7 +16,7 @@ const ModelRegistryCtor = ModelRegistry as unknown as { new (authStorage: AuthStorage, modelsJsonPath?: string): ModelRegistry; }; -const registerOpenRouterPlugin = () => +const registerOpenRouterPlugin = async () => registerProviderPlugin({ plugin, id: "openrouter", @@ -25,7 +25,7 @@ const registerOpenRouterPlugin = () => describeLive("openrouter plugin live", () => { it("registers an OpenRouter provider that can complete a live request", async () => { - const { providers } = registerOpenRouterPlugin(); + const { providers } = await registerOpenRouterPlugin(); const provider = requireRegisteredProvider(providers, "openrouter"); const resolved = provider.resolveDynamicModel?.({ diff --git a/extensions/xai/index.test.ts b/extensions/xai/index.test.ts index a536ab382df..73b9a50042b 100644 --- a/extensions/xai/index.test.ts +++ b/extensions/xai/index.test.ts @@ -3,8 +3,8 @@ import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin- import plugin from "./index.js"; describe("xai provider plugin", () => { - it("owns replay policy for xAI OpenAI-compatible transports", () => { - const provider = registerSingleProviderPlugin(plugin); + it("owns replay policy for xAI OpenAI-compatible transports", async () => { + const provider = await registerSingleProviderPlugin(plugin); expect( provider.buildReplayPolicy?.({ diff --git a/extensions/zai/index.test.ts b/extensions/zai/index.test.ts index 24102776ad4..7c7191575cb 100644 --- a/extensions/zai/index.test.ts +++ b/extensions/zai/index.test.ts @@ -3,8 +3,8 @@ import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin- import plugin from "./index.js"; describe("zai provider plugin", () => { - it("owns replay policy for OpenAI-compatible Z.ai transports", () => { - const provider = registerSingleProviderPlugin(plugin); + it("owns replay policy for OpenAI-compatible Z.ai transports", async () => { + const provider = await registerSingleProviderPlugin(plugin); expect( provider.buildReplayPolicy?.({ @@ -35,8 +35,8 @@ describe("zai provider plugin", () => { }); }); - it("resolves persisted GLM-5 family models with provider-owned metadata", () => { - const provider = registerSingleProviderPlugin(plugin); + it("resolves persisted GLM-5 family models with provider-owned metadata", async () => { + const provider = await registerSingleProviderPlugin(plugin); const template = { id: "glm-4.7", name: "GLM-4.7", diff --git a/src/agents/cache-trace.test.ts b/src/agents/cache-trace.test.ts index 5fffea03f62..aa3e5620b13 100644 --- a/src/agents/cache-trace.test.ts +++ b/src/agents/cache-trace.test.ts @@ -93,7 +93,7 @@ describe("createCacheTrace", () => { options, })) as never); - wrapped?.( + void wrapped?.( { id: "gpt-5.4", provider: "openai", diff --git a/src/test-utils/plugin-registration.ts b/src/test-utils/plugin-registration.ts index e773e6848df..8742c28402e 100644 --- a/src/test-utils/plugin-registration.ts +++ b/src/test-utils/plugin-registration.ts @@ -4,14 +4,14 @@ import type { OpenClawPluginApi, ProviderPlugin } from "../plugins/types.js"; export { createCapturedPluginRegistration }; type RegistrablePlugin = { - register(api: OpenClawPluginApi): void; + register(api: OpenClawPluginApi): void | Promise; }; -export function registerSingleProviderPlugin(params: { - register(api: OpenClawPluginApi): void; -}): ProviderPlugin { +export async function registerSingleProviderPlugin(params: { + register(api: OpenClawPluginApi): void | Promise; +}): Promise { const captured = createCapturedPluginRegistration(); - params.register(captured.api); + await params.register(captured.api); const provider = captured.providers[0]; if (!provider) { throw new Error("provider registration missing"); @@ -19,10 +19,12 @@ export function registerSingleProviderPlugin(params: { return provider; } -export function registerProviderPlugins(...plugins: RegistrablePlugin[]): ProviderPlugin[] { +export async function registerProviderPlugins( + ...plugins: RegistrablePlugin[] +): Promise { const captured = createCapturedPluginRegistration(); for (const plugin of plugins) { - plugin.register(captured.api); + await plugin.register(captured.api); } return captured.providers; } diff --git a/test/helpers/plugins/provider-auth-contract.ts b/test/helpers/plugins/provider-auth-contract.ts index 2aeee2164a4..266649b9f15 100644 --- a/test/helpers/plugins/provider-auth-contract.ts +++ b/test/helpers/plugins/provider-auth-contract.ts @@ -170,7 +170,7 @@ export function describeOpenAICodexProviderAuthContract() { const { default: openAIPlugin } = await importBundledProviderPlugin<{ default: Parameters[0]; }>(providerAuthContractModules.openAIIndexModuleUrl); - const provider = requireProvider(registerProviders(openAIPlugin), "openai-codex"); + const provider = requireProvider(await registerProviders(openAIPlugin), "openai-codex"); loginOpenAICodexOAuthMock.mockResolvedValueOnce({ refresh: "refresh-token", access: params.access, @@ -191,7 +191,7 @@ export function describeOpenAICodexProviderAuthContract() { const { default: openAIPlugin } = await importBundledProviderPlugin<{ default: Parameters[0]; }>(providerAuthContractModules.openAIIndexModuleUrl); - return requireProvider(registerProviders(openAIPlugin), "openai-codex"); + return requireProvider(await registerProviders(openAIPlugin), "openai-codex"); } it("keeps OAuth auth results provider-owned", async () => { @@ -323,7 +323,7 @@ export function describeGithubCopilotProviderAuthContract() { const { default: githubCopilotPlugin } = await importBundledProviderPlugin<{ default: Parameters[0]; }>(providerAuthContractModules.githubCopilotIndexModuleUrl); - return requireProvider(registerProviders(githubCopilotPlugin), "github-copilot"); + return requireProvider(await registerProviders(githubCopilotPlugin), "github-copilot"); } it("keeps device auth results provider-owned", async () => { diff --git a/test/helpers/plugins/provider-discovery-contract.ts b/test/helpers/plugins/provider-discovery-contract.ts index aa4e9b3650f..f3b07d7eec1 100644 --- a/test/helpers/plugins/provider-discovery-contract.ts +++ b/test/helpers/plugins/provider-discovery-contract.ts @@ -217,24 +217,22 @@ function installDiscoveryHooks(state: DiscoveryState) { default: Parameters[0]; }>(bundledProviderModules.cloudflareAiGatewayIndexModuleUrl), ]); - state.githubCopilotProvider = requireProvider( - registerProviders(githubCopilotPlugin), - "github-copilot", - ); - state.ollamaProvider = requireProvider(registerProviders(ollamaPlugin), "ollama"); - state.vllmProvider = requireProvider(registerProviders(vllmPlugin), "vllm"); - state.sglangProvider = requireProvider(registerProviders(sglangPlugin), "sglang"); - state.minimaxProvider = requireProvider(registerProviders(minimaxPlugin), "minimax"); - state.minimaxPortalProvider = requireProvider( - registerProviders(minimaxPlugin), - "minimax-portal", - ); - state.modelStudioProvider = requireProvider( - registerProviders(modelStudioPlugin), - "modelstudio", - ); + const githubCopilotProviders = await registerProviders(githubCopilotPlugin); + const ollamaProviders = await registerProviders(ollamaPlugin); + const vllmProviders = await registerProviders(vllmPlugin); + const sglangProviders = await registerProviders(sglangPlugin); + const minimaxProviders = await registerProviders(minimaxPlugin); + const modelStudioProviders = await registerProviders(modelStudioPlugin); + const cloudflareAiGatewayProviders = await registerProviders(cloudflareAiGatewayPlugin); + state.githubCopilotProvider = requireProvider(githubCopilotProviders, "github-copilot"); + state.ollamaProvider = requireProvider(ollamaProviders, "ollama"); + state.vllmProvider = requireProvider(vllmProviders, "vllm"); + state.sglangProvider = requireProvider(sglangProviders, "sglang"); + state.minimaxProvider = requireProvider(minimaxProviders, "minimax"); + state.minimaxPortalProvider = requireProvider(minimaxProviders, "minimax-portal"); + state.modelStudioProvider = requireProvider(modelStudioProviders, "modelstudio"); state.cloudflareAiGatewayProvider = requireProvider( - registerProviders(cloudflareAiGatewayPlugin), + cloudflareAiGatewayProviders, "cloudflare-ai-gateway", ); setRuntimeAuthStore(); diff --git a/test/helpers/plugins/provider-registration.ts b/test/helpers/plugins/provider-registration.ts index 37c267d6e9a..3561ac6f55c 100644 --- a/test/helpers/plugins/provider-registration.ts +++ b/test/helpers/plugins/provider-registration.ts @@ -14,20 +14,20 @@ type RegisteredProviderCollections = { }; type ProviderPluginModule = { - register(api: ReturnType): void; + register(api: ReturnType): void | Promise; }; -export function registerProviderPlugin(params: { +export async function registerProviderPlugin(params: { plugin: ProviderPluginModule; id: string; name: string; -}): RegisteredProviderCollections { +}): Promise { const providers: ProviderPlugin[] = []; const speechProviders: SpeechProviderPlugin[] = []; const mediaProviders: MediaUnderstandingProviderPlugin[] = []; const imageProviders: ImageGenerationProviderPlugin[] = []; - params.plugin.register( + await params.plugin.register( createTestPluginApi({ id: params.id, name: params.name, diff --git a/test/helpers/plugins/provider-runtime-contract.ts b/test/helpers/plugins/provider-runtime-contract.ts index da7b992583f..e2360995fb3 100644 --- a/test/helpers/plugins/provider-runtime-contract.ts +++ b/test/helpers/plugins/provider-runtime-contract.ts @@ -173,11 +173,13 @@ function installRuntimeHooks() { const plugin = await fixture.load(); return { fixture, - providers: registerProviderPlugin({ - plugin: plugin.default, - id: fixture.pluginId, - name: fixture.name, - }).providers, + providers: ( + await registerProviderPlugin({ + plugin: plugin.default, + id: fixture.pluginId, + name: fixture.name, + }) + ).providers, }; }), );