Skip to content

Commit 86da24f

Browse files
Expand OpenAI model regression coverage
Add data-driven tests around OpenAI and compat model handling, including GPT-5 token parameter selection, mapped model values, and provider boundary behavior. Also extend predicate and model-name conversion coverage across completion, Claude, OpenRouter, and AI/ML model-key groups so future config and mapping regressions fail deterministically.
1 parent fade0ea commit 86da24f

File tree

4 files changed

+306
-78
lines changed

4 files changed

+306
-78
lines changed

tests/unit/config/config-predicates.test.mjs

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import { afterEach, beforeEach, describe, test } from 'node:test'
33
import {
44
getNavigatorLanguage,
55
getPreferredLanguageKey,
6+
chatgptApiModelKeys,
7+
gptApiModelKeys,
8+
claudeApiModelKeys,
9+
openRouterApiModelKeys,
10+
aimlApiModelKeys,
611
isUsingAimlApiModel,
712
isUsingAzureOpenAiApiModel,
813
isUsingBingWebModel,
@@ -19,6 +24,7 @@ import {
1924
isUsingMultiModeModel,
2025
isUsingOllamaApiModel,
2126
isUsingOpenAiApiModel,
27+
isUsingGptCompletionApiModel,
2228
isUsingOpenRouterApiModel,
2329
} from '../../../src/config/index.mjs'
2430

@@ -63,22 +69,42 @@ test('getNavigatorLanguage treats zh-Hant locale as zhHant', () => {
6369
assert.equal(getNavigatorLanguage(), 'zhHant')
6470
})
6571

66-
test('isUsingChatgptApiModel detects chatgpt API models and excludes custom model', () => {
72+
test('isUsingChatgptApiModel matches representative chatgpt API keys', () => {
6773
assert.equal(isUsingChatgptApiModel({ modelName: 'chatgptApi4oMini' }), true)
68-
assert.equal(isUsingChatgptApiModel({ modelName: 'chatgptApi5' }), true)
69-
assert.equal(isUsingChatgptApiModel({ modelName: 'chatgptApi5_1' }), true)
7074
assert.equal(isUsingChatgptApiModel({ modelName: 'chatgptApi5_2' }), true)
71-
assert.equal(isUsingChatgptApiModel({ modelName: 'chatgptApi5_4' }), true)
7275
assert.equal(isUsingChatgptApiModel({ modelName: 'customModel' }), false)
7376
})
7477

75-
test('isUsingOpenAiApiModel accepts both chat and completion API model groups', () => {
78+
test('isUsingChatgptApiModel accepts exported chatgpt API model keys', () => {
79+
for (const modelName of chatgptApiModelKeys) {
80+
assert.equal(isUsingChatgptApiModel({ modelName }), true)
81+
}
82+
})
83+
84+
test('isUsingOpenAiApiModel matches representative chat and completion API keys', () => {
7685
assert.equal(isUsingOpenAiApiModel({ modelName: 'chatgptApi4oMini' }), true)
7786
assert.equal(isUsingOpenAiApiModel({ modelName: 'gptApiInstruct' }), true)
87+
assert.equal(isUsingOpenAiApiModel({ modelName: 'customModel' }), false)
7888
})
7989

80-
test('isUsingOpenAiApiModel excludes custom model', () => {
81-
assert.equal(isUsingOpenAiApiModel({ modelName: 'customModel' }), false)
90+
test('isUsingOpenAiApiModel accepts exported chat and completion API model groups', () => {
91+
for (const modelName of chatgptApiModelKeys) {
92+
assert.equal(isUsingOpenAiApiModel({ modelName }), true)
93+
}
94+
for (const modelName of gptApiModelKeys) {
95+
assert.equal(isUsingOpenAiApiModel({ modelName }), true)
96+
}
97+
})
98+
99+
test('isUsingGptCompletionApiModel matches representative completion API keys', () => {
100+
assert.equal(isUsingGptCompletionApiModel({ modelName: 'gptApiInstruct' }), true)
101+
assert.equal(isUsingGptCompletionApiModel({ modelName: 'chatgptApi4oMini' }), false)
102+
})
103+
104+
test('isUsingGptCompletionApiModel accepts exported completion API model keys', () => {
105+
for (const modelName of gptApiModelKeys) {
106+
assert.equal(isUsingGptCompletionApiModel({ modelName }), true)
107+
}
82108
})
83109

84110
test('isUsingCustomModel works with modelName and apiMode forms', () => {
@@ -116,12 +142,17 @@ test('isUsingGeminiWebModel detects bard/gemini web models', () => {
116142
assert.equal(isUsingGeminiWebModel({ modelName: 'chatgptFree35' }), false)
117143
})
118144

119-
test('isUsingClaudeApiModel detects Claude API models', () => {
145+
test('isUsingClaudeApiModel matches representative Claude API keys', () => {
120146
assert.equal(isUsingClaudeApiModel({ modelName: 'claude37SonnetApi' }), true)
121-
assert.equal(isUsingClaudeApiModel({ modelName: 'claudeOpus4Api' }), true)
122147
assert.equal(isUsingClaudeApiModel({ modelName: 'claude2WebFree' }), false)
123148
})
124149

150+
test('isUsingClaudeApiModel accepts exported Claude API model keys', () => {
151+
for (const modelName of claudeApiModelKeys) {
152+
assert.equal(isUsingClaudeApiModel({ modelName }), true)
153+
}
154+
})
155+
125156
test('isUsingMoonshotApiModel detects moonshot API models', () => {
126157
assert.equal(isUsingMoonshotApiModel({ modelName: 'moonshot_v1_8k' }), true)
127158
assert.equal(isUsingMoonshotApiModel({ modelName: 'moonshot_k2' }), true)
@@ -134,20 +165,28 @@ test('isUsingDeepSeekApiModel detects DeepSeek models', () => {
134165
assert.equal(isUsingDeepSeekApiModel({ modelName: 'chatgptApi4oMini' }), false)
135166
})
136167

137-
test('isUsingOpenRouterApiModel detects OpenRouter models', () => {
138-
assert.equal(
139-
isUsingOpenRouterApiModel({ modelName: 'openRouter_anthropic_claude_sonnet4' }),
140-
true,
141-
)
168+
test('isUsingOpenRouterApiModel matches representative OpenRouter API keys', () => {
142169
assert.equal(isUsingOpenRouterApiModel({ modelName: 'openRouter_openai_o3' }), true)
143170
assert.equal(isUsingOpenRouterApiModel({ modelName: 'chatgptApi4oMini' }), false)
144171
})
145172

146-
test('isUsingAimlApiModel detects AI/ML models', () => {
173+
test('isUsingOpenRouterApiModel accepts exported OpenRouter API model keys', () => {
174+
for (const modelName of openRouterApiModelKeys) {
175+
assert.equal(isUsingOpenRouterApiModel({ modelName }), true)
176+
}
177+
})
178+
179+
test('isUsingAimlApiModel matches representative AI/ML API keys', () => {
147180
assert.equal(isUsingAimlApiModel({ modelName: 'aiml_claude_3_7_sonnet_20250219' }), true)
148181
assert.equal(isUsingAimlApiModel({ modelName: 'chatgptApi4oMini' }), false)
149182
})
150183

184+
test('isUsingAimlApiModel accepts exported AI/ML model keys', () => {
185+
for (const modelName of aimlApiModelKeys) {
186+
assert.equal(isUsingAimlApiModel({ modelName }), true)
187+
}
188+
})
189+
151190
test('isUsingChatGLMApiModel detects ChatGLM models', () => {
152191
assert.equal(isUsingChatGLMApiModel({ modelName: 'chatglmTurbo' }), true)
153192
assert.equal(isUsingChatGLMApiModel({ modelName: 'chatglm4' }), true)

0 commit comments

Comments
 (0)