test: add requiresModel and isModelAvailable tests
This commit is contained in:
parent
2c74f608f0
commit
0188d69233
@ -2,7 +2,7 @@ import { describe, it, expect, beforeEach, afterEach } from "bun:test"
|
|||||||
import { mkdtempSync, writeFileSync, rmSync } from "fs"
|
import { mkdtempSync, writeFileSync, rmSync } from "fs"
|
||||||
import { tmpdir } from "os"
|
import { tmpdir } from "os"
|
||||||
import { join } from "path"
|
import { join } from "path"
|
||||||
import { fetchAvailableModels, fuzzyMatchModel, getConnectedProviders, __resetModelCache } from "./model-availability"
|
import { fetchAvailableModels, fuzzyMatchModel, getConnectedProviders, __resetModelCache, isModelAvailable } from "./model-availability"
|
||||||
|
|
||||||
describe("fetchAvailableModels", () => {
|
describe("fetchAvailableModels", () => {
|
||||||
let tempDir: string
|
let tempDir: string
|
||||||
@ -610,3 +610,38 @@ describe("fetchAvailableModels with provider-models cache (whitelist-filtered)",
|
|||||||
expect(result.has("google/gemini-3-pro")).toBe(false)
|
expect(result.has("google/gemini-3-pro")).toBe(false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("isModelAvailable", () => {
|
||||||
|
it("returns true when model exists via fuzzy match", () => {
|
||||||
|
// #given
|
||||||
|
const available = new Set(["openai/gpt-5.2-codex", "anthropic/claude-opus-4-5"])
|
||||||
|
|
||||||
|
// #when
|
||||||
|
const result = isModelAvailable("gpt-5.2-codex", available)
|
||||||
|
|
||||||
|
// #then
|
||||||
|
expect(result).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("returns false when model not found", () => {
|
||||||
|
// #given
|
||||||
|
const available = new Set(["anthropic/claude-opus-4-5"])
|
||||||
|
|
||||||
|
// #when
|
||||||
|
const result = isModelAvailable("gpt-5.2-codex", available)
|
||||||
|
|
||||||
|
// #then
|
||||||
|
expect(result).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("returns false for empty available set", () => {
|
||||||
|
// #given
|
||||||
|
const available = new Set<string>()
|
||||||
|
|
||||||
|
// #when
|
||||||
|
const result = isModelAvailable("gpt-5.2-codex", available)
|
||||||
|
|
||||||
|
// #then
|
||||||
|
expect(result).toBe(false)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
@ -424,20 +424,38 @@ describe("ModelRequirement type", () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
test("all fallbackChain entries have non-empty providers array", () => {
|
test("all fallbackChain entries have non-empty providers array", () => {
|
||||||
// #given - all agent and category requirements
|
// #given - all agent and category requirements
|
||||||
const allRequirements = [
|
const allRequirements = [
|
||||||
...Object.values(AGENT_MODEL_REQUIREMENTS),
|
...Object.values(AGENT_MODEL_REQUIREMENTS),
|
||||||
...Object.values(CATEGORY_MODEL_REQUIREMENTS),
|
...Object.values(CATEGORY_MODEL_REQUIREMENTS),
|
||||||
]
|
]
|
||||||
|
|
||||||
// #when - checking each entry in fallbackChain
|
// #when - checking each entry in fallbackChain
|
||||||
// #then - all have non-empty providers array
|
// #then - all have non-empty providers array
|
||||||
for (const req of allRequirements) {
|
for (const req of allRequirements) {
|
||||||
for (const entry of req.fallbackChain) {
|
for (const entry of req.fallbackChain) {
|
||||||
expect(entry.providers).toBeArray()
|
expect(entry.providers).toBeArray()
|
||||||
expect(entry.providers.length).toBeGreaterThan(0)
|
expect(entry.providers.length).toBeGreaterThan(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("requiresModel field in categories", () => {
|
||||||
|
test("deep category has requiresModel set to gpt-5.2-codex", () => {
|
||||||
|
// #given
|
||||||
|
const deep = CATEGORY_MODEL_REQUIREMENTS["deep"]
|
||||||
|
|
||||||
|
// #when / #then
|
||||||
|
expect(deep.requiresModel).toBe("gpt-5.2-codex")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("artistry category has requiresModel set to gemini-3-pro", () => {
|
||||||
|
// #given
|
||||||
|
const artistry = CATEGORY_MODEL_REQUIREMENTS["artistry"]
|
||||||
|
|
||||||
|
// #when / #then
|
||||||
|
expect(artistry.requiresModel).toBe("gemini-3-pro")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user