refactor(provider-tests): share codex catalog assertions
This commit is contained in:
parent
201964ce6c
commit
5747700b3c
@ -1,4 +1,9 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeEach, describe, it, vi } from "vitest";
|
||||
import {
|
||||
expectAugmentedCodexCatalog,
|
||||
expectCodexBuiltInSuppression,
|
||||
expectCodexMissingAuthHint,
|
||||
} from "../provider-runtime.test-support.js";
|
||||
import {
|
||||
providerContractPluginIds,
|
||||
resolveProviderContractProvidersForPluginIds,
|
||||
@ -45,57 +50,14 @@ describe("provider catalog contract", () => {
|
||||
});
|
||||
|
||||
it("keeps codex-only missing-auth hints wired through the provider runtime", () => {
|
||||
expect(
|
||||
buildProviderMissingAuthMessageWithPlugin({
|
||||
provider: "openai",
|
||||
env: process.env,
|
||||
context: {
|
||||
env: process.env,
|
||||
provider: "openai",
|
||||
listProfileIds: (providerId) => (providerId === "openai-codex" ? ["p1"] : []),
|
||||
},
|
||||
}),
|
||||
).toContain("openai-codex/gpt-5.4");
|
||||
expectCodexMissingAuthHint(buildProviderMissingAuthMessageWithPlugin);
|
||||
});
|
||||
|
||||
it("keeps built-in model suppression wired through the provider runtime", () => {
|
||||
expect(
|
||||
resolveProviderBuiltInModelSuppression({
|
||||
env: process.env,
|
||||
context: {
|
||||
env: process.env,
|
||||
provider: "azure-openai-responses",
|
||||
modelId: "gpt-5.3-codex-spark",
|
||||
},
|
||||
}),
|
||||
).toMatchObject({
|
||||
suppress: true,
|
||||
errorMessage: expect.stringContaining("openai-codex/gpt-5.3-codex-spark"),
|
||||
});
|
||||
expectCodexBuiltInSuppression(resolveProviderBuiltInModelSuppression);
|
||||
});
|
||||
|
||||
it("keeps bundled model augmentation wired through the provider runtime", async () => {
|
||||
await expect(
|
||||
augmentModelCatalogWithProviderPlugins({
|
||||
env: process.env,
|
||||
context: {
|
||||
env: process.env,
|
||||
entries: [
|
||||
{ provider: "openai", id: "gpt-5.2", name: "GPT-5.2" },
|
||||
{ provider: "openai", id: "gpt-5.2-pro", name: "GPT-5.2 Pro" },
|
||||
{ provider: "openai-codex", id: "gpt-5.3-codex", name: "GPT-5.3 Codex" },
|
||||
],
|
||||
},
|
||||
}),
|
||||
).resolves.toEqual([
|
||||
{ provider: "openai", id: "gpt-5.4", name: "gpt-5.4" },
|
||||
{ provider: "openai", id: "gpt-5.4-pro", name: "gpt-5.4-pro" },
|
||||
{ provider: "openai-codex", id: "gpt-5.4", name: "gpt-5.4" },
|
||||
{
|
||||
provider: "openai-codex",
|
||||
id: "gpt-5.3-codex-spark",
|
||||
name: "gpt-5.3-codex-spark",
|
||||
},
|
||||
]);
|
||||
await expectAugmentedCodexCatalog(augmentModelCatalogWithProviderPlugins);
|
||||
});
|
||||
});
|
||||
|
||||
87
src/plugins/provider-runtime.test-support.ts
Normal file
87
src/plugins/provider-runtime.test-support.ts
Normal file
@ -0,0 +1,87 @@
|
||||
import { expect } from "vitest";
|
||||
|
||||
export const openaiCodexCatalogEntries = [
|
||||
{ provider: "openai", id: "gpt-5.2", name: "GPT-5.2" },
|
||||
{ provider: "openai", id: "gpt-5.2-pro", name: "GPT-5.2 Pro" },
|
||||
{ provider: "openai-codex", id: "gpt-5.3-codex", name: "GPT-5.3 Codex" },
|
||||
];
|
||||
|
||||
export const expectedAugmentedOpenaiCodexCatalogEntries = [
|
||||
{ provider: "openai", id: "gpt-5.4", name: "gpt-5.4" },
|
||||
{ provider: "openai", id: "gpt-5.4-pro", name: "gpt-5.4-pro" },
|
||||
{ provider: "openai-codex", id: "gpt-5.4", name: "gpt-5.4" },
|
||||
{
|
||||
provider: "openai-codex",
|
||||
id: "gpt-5.3-codex-spark",
|
||||
name: "gpt-5.3-codex-spark",
|
||||
},
|
||||
];
|
||||
|
||||
export function expectCodexMissingAuthHint(
|
||||
buildProviderMissingAuthMessageWithPlugin: (params: {
|
||||
provider: string;
|
||||
env: NodeJS.ProcessEnv;
|
||||
context: {
|
||||
env: NodeJS.ProcessEnv;
|
||||
provider: string;
|
||||
listProfileIds: (providerId: string) => string[];
|
||||
};
|
||||
}) => string | undefined,
|
||||
) {
|
||||
expect(
|
||||
buildProviderMissingAuthMessageWithPlugin({
|
||||
provider: "openai",
|
||||
env: process.env,
|
||||
context: {
|
||||
env: process.env,
|
||||
provider: "openai",
|
||||
listProfileIds: (providerId) => (providerId === "openai-codex" ? ["p1"] : []),
|
||||
},
|
||||
}),
|
||||
).toContain("openai-codex/gpt-5.4");
|
||||
}
|
||||
|
||||
export function expectCodexBuiltInSuppression(
|
||||
resolveProviderBuiltInModelSuppression: (params: {
|
||||
env: NodeJS.ProcessEnv;
|
||||
context: {
|
||||
env: NodeJS.ProcessEnv;
|
||||
provider: string;
|
||||
modelId: string;
|
||||
};
|
||||
}) => unknown,
|
||||
) {
|
||||
expect(
|
||||
resolveProviderBuiltInModelSuppression({
|
||||
env: process.env,
|
||||
context: {
|
||||
env: process.env,
|
||||
provider: "azure-openai-responses",
|
||||
modelId: "gpt-5.3-codex-spark",
|
||||
},
|
||||
}),
|
||||
).toMatchObject({
|
||||
suppress: true,
|
||||
errorMessage: expect.stringContaining("openai-codex/gpt-5.3-codex-spark"),
|
||||
});
|
||||
}
|
||||
|
||||
export async function expectAugmentedCodexCatalog(
|
||||
augmentModelCatalogWithProviderPlugins: (params: {
|
||||
env: NodeJS.ProcessEnv;
|
||||
context: {
|
||||
env: NodeJS.ProcessEnv;
|
||||
entries: typeof openaiCodexCatalogEntries;
|
||||
};
|
||||
}) => Promise<unknown>,
|
||||
) {
|
||||
await expect(
|
||||
augmentModelCatalogWithProviderPlugins({
|
||||
env: process.env,
|
||||
context: {
|
||||
env: process.env,
|
||||
entries: openaiCodexCatalogEntries,
|
||||
},
|
||||
}),
|
||||
).resolves.toEqual(expectedAugmentedOpenaiCodexCatalogEntries);
|
||||
}
|
||||
@ -1,4 +1,9 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
expectAugmentedCodexCatalog,
|
||||
expectCodexBuiltInSuppression,
|
||||
expectCodexMissingAuthHint,
|
||||
} from "./provider-runtime.test-support.js";
|
||||
import type { ProviderPlugin, ProviderRuntimeModel } from "./types.js";
|
||||
|
||||
type ResolvePluginProviders = typeof import("./providers.js").resolvePluginProviders;
|
||||
@ -433,54 +438,9 @@ describe("provider-runtime", () => {
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
buildProviderMissingAuthMessageWithPlugin({
|
||||
provider: "openai",
|
||||
env: process.env,
|
||||
context: {
|
||||
env: process.env,
|
||||
provider: "openai",
|
||||
listProfileIds: (providerId) => (providerId === "openai-codex" ? ["p1"] : []),
|
||||
},
|
||||
}),
|
||||
).toContain("openai-codex/gpt-5.4");
|
||||
|
||||
expect(
|
||||
resolveProviderBuiltInModelSuppression({
|
||||
env: process.env,
|
||||
context: {
|
||||
env: process.env,
|
||||
provider: "azure-openai-responses",
|
||||
modelId: "gpt-5.3-codex-spark",
|
||||
},
|
||||
}),
|
||||
).toMatchObject({
|
||||
suppress: true,
|
||||
errorMessage: expect.stringContaining("openai-codex/gpt-5.3-codex-spark"),
|
||||
});
|
||||
|
||||
await expect(
|
||||
augmentModelCatalogWithProviderPlugins({
|
||||
env: process.env,
|
||||
context: {
|
||||
env: process.env,
|
||||
entries: [
|
||||
{ provider: "openai", id: "gpt-5.2", name: "GPT-5.2" },
|
||||
{ provider: "openai", id: "gpt-5.2-pro", name: "GPT-5.2 Pro" },
|
||||
{ provider: "openai-codex", id: "gpt-5.3-codex", name: "GPT-5.3 Codex" },
|
||||
],
|
||||
},
|
||||
}),
|
||||
).resolves.toEqual([
|
||||
{ provider: "openai", id: "gpt-5.4", name: "gpt-5.4" },
|
||||
{ provider: "openai", id: "gpt-5.4-pro", name: "gpt-5.4-pro" },
|
||||
{ provider: "openai-codex", id: "gpt-5.4", name: "gpt-5.4" },
|
||||
{
|
||||
provider: "openai-codex",
|
||||
id: "gpt-5.3-codex-spark",
|
||||
name: "gpt-5.3-codex-spark",
|
||||
},
|
||||
]);
|
||||
expectCodexMissingAuthHint(buildProviderMissingAuthMessageWithPlugin);
|
||||
expectCodexBuiltInSuppression(resolveProviderBuiltInModelSuppression);
|
||||
await expectAugmentedCodexCatalog(augmentModelCatalogWithProviderPlugins);
|
||||
|
||||
expect(prepareDynamicModel).toHaveBeenCalledTimes(1);
|
||||
expect(refreshOAuth).toHaveBeenCalledTimes(1);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user