test(cli): compose Claude catalog expectations

This commit is contained in:
Mohamed Boudra
2026-07-25 22:22:38 +02:00
parent 6610dbdffe
commit b3bfec027f
+38 -26
View File
@@ -45,21 +45,6 @@ interface ProviderListRow {
}
const EXPECTED_CLAUDE_MODELS = [
{
id: "claude-opus-5[1m]",
model: "Opus 5 1M",
descriptionFragment: "1M context window",
},
{
id: "claude-opus-5",
model: "Opus 5",
descriptionFragment: "200K context window",
},
{
id: "claude-fable-5[1m]",
model: "Fable 5 1M",
descriptionFragment: "1M context window",
},
{
id: "claude-fable-5",
model: "Fable 5",
@@ -73,18 +58,13 @@ const EXPECTED_CLAUDE_MODELS = [
{
id: "claude-opus-4-8",
model: "Opus 4.8",
descriptionFragment: "Previous release",
descriptionFragment: "Latest release",
},
{
id: "claude-sonnet-5",
model: "Sonnet 5",
descriptionFragment: "Best for everyday tasks",
},
{
id: "claude-sonnet-5[1m]",
model: "Sonnet 5 1M",
descriptionFragment: "1M context window",
},
{
id: "claude-opus-4-7[1m]",
model: "Opus 4.7 1M",
@@ -122,6 +102,38 @@ const EXPECTED_CLAUDE_MODELS = [
},
] as const;
const EXPECTED_CLAUDE_CONTEXT_MODELS = [
{
id: "claude-opus-5[1m]",
model: "Opus 5 1M",
descriptionFragment: "1M context window",
},
{
id: "claude-opus-5",
model: "Opus 5",
descriptionFragment: "200K context window",
},
{
id: "claude-fable-5[1m]",
model: "Fable 5 1M",
descriptionFragment: "1M context window",
},
{
id: "claude-sonnet-5[1m]",
model: "Sonnet 5 1M",
descriptionFragment: "1M context window",
},
] as const;
const EXPECTED_CLAUDE_CATALOG_MODELS = [
...new Map(
[...EXPECTED_CLAUDE_MODELS, ...EXPECTED_CLAUDE_CONTEXT_MODELS].map((model) => [
model.id,
model,
]),
).values(),
];
let claudeModelIdsFromJson: string[] = [];
let claudeModelsFromJson: ProviderModel[] = [];
@@ -154,18 +166,18 @@ async function runProviderModelsJson(provider: string): Promise<ProviderModel[]>
function assertClaudeModels(data: ProviderModel[]): void {
assert.strictEqual(
data.length,
EXPECTED_CLAUDE_MODELS.length,
EXPECTED_CLAUDE_CATALOG_MODELS.length,
"claude output should match the current catalog size",
);
const byId = new Map(data.map((model) => [model.id, model]));
const ids = [...byId.keys()].sort();
const expectedIds = EXPECTED_CLAUDE_MODELS.map((model) => model.id).sort();
const expectedIds = EXPECTED_CLAUDE_CATALOG_MODELS.map((model) => model.id).sort();
assert.strictEqual(byId.size, data.length, "claude model IDs should be unique");
assert.deepStrictEqual(ids, expectedIds, "claude IDs should match the current catalog");
for (const expectedModel of EXPECTED_CLAUDE_MODELS) {
for (const expectedModel of EXPECTED_CLAUDE_CATALOG_MODELS) {
const actualModel = byId.get(expectedModel.id);
assert(actualModel, `claude output should include ${expectedModel.id}`);
assert.strictEqual(
@@ -403,7 +415,7 @@ try {
const lines = result.stdout.trim().split("\n").filter(Boolean);
assert.strictEqual(
lines.length,
EXPECTED_CLAUDE_MODELS.length,
EXPECTED_CLAUDE_CATALOG_MODELS.length,
"should have one line per Claude catalog model",
);
assert.deepStrictEqual(
@@ -413,7 +425,7 @@ try {
);
assert.deepStrictEqual(
[...lines].sort(),
EXPECTED_CLAUDE_MODELS.map((model) => model.id).sort(),
EXPECTED_CLAUDE_CATALOG_MODELS.map((model) => model.id).sort(),
"--quiet should print the current Claude catalog IDs",
);
assert(