mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-24 23:21:30 +00:00
test: cache provider discovery fixtures
This commit is contained in:
@@ -58,6 +58,21 @@ const modelStudioPlugin = (await import("../../../extensions/modelstudio/index.j
|
||||
const cloudflareAiGatewayPlugin = (
|
||||
await import("../../../extensions/cloudflare-ai-gateway/index.js")
|
||||
).default;
|
||||
const qwenPortalProvider = requireProvider(registerProviders(qwenPortalPlugin), "qwen-portal");
|
||||
const githubCopilotProvider = requireProvider(
|
||||
registerProviders(githubCopilotPlugin),
|
||||
"github-copilot",
|
||||
);
|
||||
const ollamaProvider = requireProvider(registerProviders(ollamaPlugin), "ollama");
|
||||
const vllmProvider = requireProvider(registerProviders(vllmPlugin), "vllm");
|
||||
const sglangProvider = requireProvider(registerProviders(sglangPlugin), "sglang");
|
||||
const minimaxProvider = requireProvider(registerProviders(minimaxPlugin), "minimax");
|
||||
const minimaxPortalProvider = requireProvider(registerProviders(minimaxPlugin), "minimax-portal");
|
||||
const modelStudioProvider = requireProvider(registerProviders(modelStudioPlugin), "modelstudio");
|
||||
const cloudflareAiGatewayProvider = requireProvider(
|
||||
registerProviders(cloudflareAiGatewayPlugin),
|
||||
"cloudflare-ai-gateway",
|
||||
);
|
||||
|
||||
function createModelConfig(id: string, name = id): ModelDefinitionConfig {
|
||||
return {
|
||||
@@ -76,14 +91,6 @@ function createModelConfig(id: string, name = id): ModelDefinitionConfig {
|
||||
};
|
||||
}
|
||||
|
||||
function requireQwenPortalProvider() {
|
||||
return requireProvider(registerProviders(qwenPortalPlugin), "qwen-portal");
|
||||
}
|
||||
|
||||
function requireGithubCopilotProvider() {
|
||||
return requireProvider(registerProviders(githubCopilotPlugin), "github-copilot");
|
||||
}
|
||||
|
||||
function setQwenPortalOauthSnapshot() {
|
||||
replaceRuntimeAuthProfileStoreSnapshots([
|
||||
{
|
||||
@@ -143,12 +150,11 @@ describe("provider discovery contract", () => {
|
||||
});
|
||||
|
||||
it("keeps qwen portal oauth marker fallback provider-owned", async () => {
|
||||
const provider = requireQwenPortalProvider();
|
||||
setQwenPortalOauthSnapshot();
|
||||
|
||||
await expect(
|
||||
runCatalog({
|
||||
provider,
|
||||
provider: qwenPortalProvider,
|
||||
}),
|
||||
).resolves.toEqual({
|
||||
provider: {
|
||||
@@ -164,12 +170,11 @@ describe("provider discovery contract", () => {
|
||||
});
|
||||
|
||||
it("keeps qwen portal env api keys higher priority than oauth markers", async () => {
|
||||
const provider = requireQwenPortalProvider();
|
||||
setQwenPortalOauthSnapshot();
|
||||
|
||||
await expect(
|
||||
runCatalog({
|
||||
provider,
|
||||
provider: qwenPortalProvider,
|
||||
env: { QWEN_PORTAL_API_KEY: "env-key" } as NodeJS.ProcessEnv,
|
||||
resolveProviderApiKey: () => ({ apiKey: "env-key" }),
|
||||
}),
|
||||
@@ -181,18 +186,15 @@ describe("provider discovery contract", () => {
|
||||
});
|
||||
|
||||
it("keeps GitHub Copilot catalog disabled without env tokens or profiles", async () => {
|
||||
const provider = requireGithubCopilotProvider();
|
||||
|
||||
await expect(runCatalog({ provider })).resolves.toBeNull();
|
||||
await expect(runCatalog({ provider: githubCopilotProvider })).resolves.toBeNull();
|
||||
});
|
||||
|
||||
it("keeps GitHub Copilot profile-only catalog fallback provider-owned", async () => {
|
||||
const provider = requireGithubCopilotProvider();
|
||||
setGithubCopilotProfileSnapshot();
|
||||
|
||||
await expect(
|
||||
runCatalog({
|
||||
provider,
|
||||
provider: githubCopilotProvider,
|
||||
}),
|
||||
).resolves.toEqual({
|
||||
provider: {
|
||||
@@ -203,7 +205,6 @@ describe("provider discovery contract", () => {
|
||||
});
|
||||
|
||||
it("keeps GitHub Copilot env-token base URL resolution provider-owned", async () => {
|
||||
const provider = requireGithubCopilotProvider();
|
||||
resolveCopilotApiTokenMock.mockResolvedValueOnce({
|
||||
token: "copilot-api-token",
|
||||
baseUrl: "https://copilot-proxy.example.com",
|
||||
@@ -212,7 +213,7 @@ describe("provider discovery contract", () => {
|
||||
|
||||
await expect(
|
||||
runCatalog({
|
||||
provider,
|
||||
provider: githubCopilotProvider,
|
||||
env: {
|
||||
GITHUB_TOKEN: "github-env-token",
|
||||
} as NodeJS.ProcessEnv,
|
||||
@@ -233,11 +234,9 @@ describe("provider discovery contract", () => {
|
||||
});
|
||||
|
||||
it("keeps Ollama explicit catalog normalization provider-owned", async () => {
|
||||
const provider = requireProvider(registerProviders(ollamaPlugin), "ollama");
|
||||
|
||||
await expect(
|
||||
runProviderCatalog({
|
||||
provider,
|
||||
provider: ollamaProvider,
|
||||
config: {
|
||||
models: {
|
||||
providers: {
|
||||
@@ -263,7 +262,6 @@ describe("provider discovery contract", () => {
|
||||
});
|
||||
|
||||
it("keeps Ollama empty autodiscovery disabled without keys or explicit config", async () => {
|
||||
const provider = requireProvider(registerProviders(ollamaPlugin), "ollama");
|
||||
buildOllamaProviderMock.mockResolvedValueOnce({
|
||||
baseUrl: "http://127.0.0.1:11434",
|
||||
api: "ollama",
|
||||
@@ -272,7 +270,7 @@ describe("provider discovery contract", () => {
|
||||
|
||||
await expect(
|
||||
runProviderCatalog({
|
||||
provider,
|
||||
provider: ollamaProvider,
|
||||
config: {},
|
||||
env: {} as NodeJS.ProcessEnv,
|
||||
resolveProviderApiKey: () => ({ apiKey: undefined }),
|
||||
@@ -282,7 +280,6 @@ describe("provider discovery contract", () => {
|
||||
});
|
||||
|
||||
it("keeps vLLM self-hosted discovery provider-owned", async () => {
|
||||
const provider = requireProvider(registerProviders(vllmPlugin), "vllm");
|
||||
buildVllmProviderMock.mockResolvedValueOnce({
|
||||
baseUrl: "http://127.0.0.1:8000/v1",
|
||||
api: "openai-completions",
|
||||
@@ -291,7 +288,7 @@ describe("provider discovery contract", () => {
|
||||
|
||||
await expect(
|
||||
runProviderCatalog({
|
||||
provider,
|
||||
provider: vllmProvider,
|
||||
config: {},
|
||||
env: {
|
||||
VLLM_API_KEY: "env-vllm-key",
|
||||
@@ -315,7 +312,6 @@ describe("provider discovery contract", () => {
|
||||
});
|
||||
|
||||
it("keeps SGLang self-hosted discovery provider-owned", async () => {
|
||||
const provider = requireProvider(registerProviders(sglangPlugin), "sglang");
|
||||
buildSglangProviderMock.mockResolvedValueOnce({
|
||||
baseUrl: "http://127.0.0.1:30000/v1",
|
||||
api: "openai-completions",
|
||||
@@ -324,7 +320,7 @@ describe("provider discovery contract", () => {
|
||||
|
||||
await expect(
|
||||
runProviderCatalog({
|
||||
provider,
|
||||
provider: sglangProvider,
|
||||
config: {},
|
||||
env: {
|
||||
SGLANG_API_KEY: "env-sglang-key",
|
||||
@@ -348,11 +344,9 @@ describe("provider discovery contract", () => {
|
||||
});
|
||||
|
||||
it("keeps MiniMax API catalog provider-owned", async () => {
|
||||
const provider = requireProvider(registerProviders(minimaxPlugin), "minimax");
|
||||
|
||||
await expect(
|
||||
runProviderCatalog({
|
||||
provider,
|
||||
provider: minimaxProvider,
|
||||
config: {},
|
||||
env: {
|
||||
MINIMAX_API_KEY: "minimax-key",
|
||||
@@ -374,7 +368,6 @@ describe("provider discovery contract", () => {
|
||||
});
|
||||
|
||||
it("keeps MiniMax portal oauth marker fallback provider-owned", async () => {
|
||||
const provider = requireProvider(registerProviders(minimaxPlugin), "minimax-portal");
|
||||
replaceRuntimeAuthProfileStoreSnapshots([
|
||||
{
|
||||
store: {
|
||||
@@ -394,7 +387,7 @@ describe("provider discovery contract", () => {
|
||||
|
||||
await expect(
|
||||
runProviderCatalog({
|
||||
provider,
|
||||
provider: minimaxPortalProvider,
|
||||
config: {},
|
||||
env: {} as NodeJS.ProcessEnv,
|
||||
resolveProviderApiKey: () => ({ apiKey: undefined }),
|
||||
@@ -411,11 +404,9 @@ describe("provider discovery contract", () => {
|
||||
});
|
||||
|
||||
it("keeps MiniMax portal explicit base URL override provider-owned", async () => {
|
||||
const provider = requireProvider(registerProviders(minimaxPlugin), "minimax-portal");
|
||||
|
||||
await expect(
|
||||
runProviderCatalog({
|
||||
provider,
|
||||
provider: minimaxPortalProvider,
|
||||
config: {
|
||||
models: {
|
||||
providers: {
|
||||
@@ -439,11 +430,9 @@ describe("provider discovery contract", () => {
|
||||
});
|
||||
|
||||
it("keeps Model Studio catalog provider-owned", async () => {
|
||||
const provider = requireProvider(registerProviders(modelStudioPlugin), "modelstudio");
|
||||
|
||||
await expect(
|
||||
runProviderCatalog({
|
||||
provider,
|
||||
provider: modelStudioProvider,
|
||||
config: {
|
||||
models: {
|
||||
providers: {
|
||||
@@ -473,14 +462,9 @@ describe("provider discovery contract", () => {
|
||||
});
|
||||
|
||||
it("keeps Cloudflare AI Gateway catalog disabled without stored metadata", async () => {
|
||||
const provider = requireProvider(
|
||||
registerProviders(cloudflareAiGatewayPlugin),
|
||||
"cloudflare-ai-gateway",
|
||||
);
|
||||
|
||||
await expect(
|
||||
runProviderCatalog({
|
||||
provider,
|
||||
provider: cloudflareAiGatewayProvider,
|
||||
config: {},
|
||||
env: {} as NodeJS.ProcessEnv,
|
||||
resolveProviderApiKey: () => ({ apiKey: undefined }),
|
||||
@@ -489,10 +473,6 @@ describe("provider discovery contract", () => {
|
||||
});
|
||||
|
||||
it("keeps Cloudflare AI Gateway env-managed catalog provider-owned", async () => {
|
||||
const provider = requireProvider(
|
||||
registerProviders(cloudflareAiGatewayPlugin),
|
||||
"cloudflare-ai-gateway",
|
||||
);
|
||||
replaceRuntimeAuthProfileStoreSnapshots([
|
||||
{
|
||||
store: {
|
||||
@@ -518,7 +498,7 @@ describe("provider discovery contract", () => {
|
||||
|
||||
await expect(
|
||||
runProviderCatalog({
|
||||
provider,
|
||||
provider: cloudflareAiGatewayProvider,
|
||||
config: {},
|
||||
env: {
|
||||
CLOUDFLARE_AI_GATEWAY_API_KEY: "secret-value",
|
||||
|
||||
Reference in New Issue
Block a user