test: simplify provider thinking level scans

This commit is contained in:
Peter Steinberger
2026-05-08 23:09:23 +01:00
parent 5104fd02c9
commit f4d5f9985b
3 changed files with 33 additions and 9 deletions

View File

@@ -23,6 +23,16 @@ function createModel(id: string, name: string): ModelDefinitionConfig {
};
}
function collectLegacyExtendedLevelIds(levels: readonly { id: string }[] | undefined): string[] {
const ids: string[] = [];
for (const level of levels ?? []) {
if (level.id === "xhigh" || level.id === "max") {
ids.push(level.id);
}
}
return ids;
}
describe("anthropic provider policy public artifact", () => {
it("normalizes Anthropic provider config", () => {
expect(
@@ -117,9 +127,7 @@ describe("anthropic provider policy public artifact", () => {
if (!profile) {
throw new Error("Expected Anthropic policy profile");
}
expect(
profile.levels.map((level) => level.id).filter((id) => id === "xhigh" || id === "max"),
).toEqual([]);
expect(collectLegacyExtendedLevelIds(profile.levels)).toEqual([]);
});
it("does not expose Anthropic thinking profiles for unrelated providers", () => {

View File

@@ -1,6 +1,16 @@
import { describe, expect, it } from "vitest";
import { resolveThinkingProfile } from "./provider-policy-api.js";
function collectLegacyExtendedLevelIds(levels: readonly { id: string }[] | undefined): string[] {
const ids: string[] = [];
for (const level of levels ?? []) {
if (level.id === "xhigh" || level.id === "max") {
ids.push(level.id);
}
}
return ids;
}
describe("opencode provider policy public artifact", () => {
it("exposes Claude Opus 4.7 thinking levels without loading the full provider plugin", () => {
expect(
@@ -24,8 +34,6 @@ describe("opencode provider policy public artifact", () => {
levels: expect.arrayContaining([{ id: "adaptive" }]),
defaultLevel: "adaptive",
});
expect(
profile.levels.map((level) => level.id).filter((id) => id === "xhigh" || id === "max"),
).toEqual([]);
expect(collectLegacyExtendedLevelIds(profile.levels)).toEqual([]);
});
});

View File

@@ -5,6 +5,16 @@ import {
import { describe, expect, it } from "vitest";
import plugin from "./index.js";
function collectLegacyExtendedLevelIds(levels: readonly { id: string }[] | undefined): string[] {
const ids: string[] = [];
for (const level of levels ?? []) {
if (level.id === "xhigh" || level.id === "max") {
ids.push(level.id);
}
}
return ids;
}
describe("vercel ai gateway thinking profile", () => {
async function getProvider() {
const { providers } = await registerProviderPlugin({
@@ -49,9 +59,7 @@ describe("vercel ai gateway thinking profile", () => {
levels: expect.arrayContaining([{ id: "adaptive" }]),
defaultLevel: "adaptive",
});
expect(
profile?.levels.map((level) => level.id).filter((id) => id === "xhigh" || id === "max"),
).toEqual([]);
expect(collectLegacyExtendedLevelIds(profile?.levels)).toEqual([]);
});
it("falls through for unsupported OpenAI or untrusted namespaced refs", async () => {