test(models): use worker-visible catalog fixtures

This commit is contained in:
joshavant
2026-08-12 15:34:30 -05:00
parent 7cf4981ef7
commit f7db53c855
@@ -174,6 +174,27 @@ const minimaxProviderConfig = () => ({
models: [{ id: "MiniMax-M2.7-highspeed", name: "MiniMax M2.7 Highspeed" }],
});
const fullCatalogProviderConfig = () => ({
models: {
providers: Object.fromEntries(
["anthropic", "openai"].map((provider) => [
provider,
{
baseUrl: `https://${provider}.example.com/v1`,
apiKey: {
source: "env",
provider: "default",
id: "MODEL_CATALOG_TEST_MISSING_KEY",
},
models: buildAgentCatalogFixture()
.filter((entry) => entry.provider === provider)
.map(({ provider: _provider, ...model }) => model),
},
]),
),
},
});
type ConfiguredProviderModelFixture = {
provider: string;
modelId: string;
@@ -461,18 +482,20 @@ describe("gateway server models + voicewake", () => {
});
test("models.list all view returns model catalog", async () => {
await seedAgentModelCatalog();
await withModelsConfig(fullCatalogProviderConfig(), async () => {
await seedAgentModelCatalog();
const res1 = await listModels({ view: "all" });
const res2 = await listModels({ view: "all" });
const res1 = await listModels({ view: "all" });
const res2 = await listModels({ view: "all" });
expect(res1.ok).toBe(true);
expect(res2.ok).toBe(true);
expect(res1.ok).toBe(true);
expect(res2.ok).toBe(true);
const models = res1.payload?.models ?? [];
expect(models).toEqual(expectedSortedCatalog());
const models = res1.payload?.models ?? [];
expect(models).toEqual(expectedSortedCatalog());
expect(agentDiscoveryMock.discoverCalls).toBe(1);
expect(agentDiscoveryMock.discoverCalls).toBe(1);
});
});
test("models.list default view uses configured providers instead of the full catalog", async () => {
@@ -585,6 +608,7 @@ describe("gateway server models + voicewake", () => {
test("models.list all view bypasses the explicit model policy", async () => {
await withModelsConfig(
{
...fullCatalogProviderConfig(),
agents: {
defaults: {
model: { primary: "openai/gpt-test-z" },