test: simplify provider thinking level scans · openclaw/openclaw@f4d5f99
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -23,6 +23,16 @@ function createModel(id: string, name: string): ModelDefinitionConfig {
|
23 | 23 | }; |
24 | 24 | } |
25 | 25 | |
| 26 | +function collectLegacyExtendedLevelIds(levels: readonly { id: string }[] | undefined): string[] { |
| 27 | +const ids: string[] = []; |
| 28 | +for (const level of levels ?? []) { |
| 29 | +if (level.id === "xhigh" || level.id === "max") { |
| 30 | +ids.push(level.id); |
| 31 | +} |
| 32 | +} |
| 33 | +return ids; |
| 34 | +} |
| 35 | + |
26 | 36 | describe("anthropic provider policy public artifact", () => { |
27 | 37 | it("normalizes Anthropic provider config", () => { |
28 | 38 | expect( |
@@ -117,9 +127,7 @@ describe("anthropic provider policy public artifact", () => {
|
117 | 127 | if (!profile) { |
118 | 128 | throw new Error("Expected Anthropic policy profile"); |
119 | 129 | } |
120 | | -expect( |
121 | | -profile.levels.map((level) => level.id).filter((id) => id === "xhigh" || id === "max"), |
122 | | -).toEqual([]); |
| 130 | +expect(collectLegacyExtendedLevelIds(profile.levels)).toEqual([]); |
123 | 131 | }); |
124 | 132 | |
125 | 133 | it("does not expose Anthropic thinking profiles for unrelated providers", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { describe, expect, it } from "vitest"; |
2 | 2 | import { resolveThinkingProfile } from "./provider-policy-api.js"; |
3 | 3 | |
| 4 | +function collectLegacyExtendedLevelIds(levels: readonly { id: string }[] | undefined): string[] { |
| 5 | +const ids: string[] = []; |
| 6 | +for (const level of levels ?? []) { |
| 7 | +if (level.id === "xhigh" || level.id === "max") { |
| 8 | +ids.push(level.id); |
| 9 | +} |
| 10 | +} |
| 11 | +return ids; |
| 12 | +} |
| 13 | + |
4 | 14 | describe("opencode provider policy public artifact", () => { |
5 | 15 | it("exposes Claude Opus 4.7 thinking levels without loading the full provider plugin", () => { |
6 | 16 | expect( |
@@ -24,8 +34,6 @@ describe("opencode provider policy public artifact", () => {
|
24 | 34 | levels: expect.arrayContaining([{ id: "adaptive" }]), |
25 | 35 | defaultLevel: "adaptive", |
26 | 36 | }); |
27 | | -expect( |
28 | | -profile.levels.map((level) => level.id).filter((id) => id === "xhigh" || id === "max"), |
29 | | -).toEqual([]); |
| 37 | +expect(collectLegacyExtendedLevelIds(profile.levels)).toEqual([]); |
30 | 38 | }); |
31 | 39 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5,6 +5,16 @@ import {
|
5 | 5 | import { describe, expect, it } from "vitest"; |
6 | 6 | import plugin from "./index.js"; |
7 | 7 | |
| 8 | +function collectLegacyExtendedLevelIds(levels: readonly { id: string }[] | undefined): string[] { |
| 9 | +const ids: string[] = []; |
| 10 | +for (const level of levels ?? []) { |
| 11 | +if (level.id === "xhigh" || level.id === "max") { |
| 12 | +ids.push(level.id); |
| 13 | +} |
| 14 | +} |
| 15 | +return ids; |
| 16 | +} |
| 17 | + |
8 | 18 | describe("vercel ai gateway thinking profile", () => { |
9 | 19 | async function getProvider() { |
10 | 20 | const { providers } = await registerProviderPlugin({ |
@@ -49,9 +59,7 @@ describe("vercel ai gateway thinking profile", () => {
|
49 | 59 | levels: expect.arrayContaining([{ id: "adaptive" }]), |
50 | 60 | defaultLevel: "adaptive", |
51 | 61 | }); |
52 | | -expect( |
53 | | -profile?.levels.map((level) => level.id).filter((id) => id === "xhigh" || id === "max"), |
54 | | -).toEqual([]); |
| 62 | +expect(collectLegacyExtendedLevelIds(profile?.levels)).toEqual([]); |
55 | 63 | }); |
56 | 64 | |
57 | 65 | it("falls through for unsupported OpenAI or untrusted namespaced refs", async () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。