fix test:ci

This commit is contained in:
koalazf.99
2025-08-03 21:15:34 +08:00
parent 5cfb727ec6
commit 05238b4f90
4 changed files with 29 additions and 19 deletions

View File

@@ -98,6 +98,7 @@ describe('Settings Loading and Merging', () => {
expect(settings.merged).toEqual({
customThemes: {},
mcpServers: {},
openaiConfig: {},
});
expect(settings.errors.length).toBe(0);
});
@@ -131,6 +132,7 @@ describe('Settings Loading and Merging', () => {
...systemSettingsContent,
customThemes: {},
mcpServers: {},
openaiConfig: {},
});
});
@@ -164,6 +166,7 @@ describe('Settings Loading and Merging', () => {
...userSettingsContent,
customThemes: {},
mcpServers: {},
openaiConfig: {},
});
});
@@ -195,6 +198,7 @@ describe('Settings Loading and Merging', () => {
...workspaceSettingsContent,
customThemes: {},
mcpServers: {},
openaiConfig: {},
});
});
@@ -232,6 +236,7 @@ describe('Settings Loading and Merging', () => {
contextFileName: 'WORKSPACE_CONTEXT.md',
customThemes: {},
mcpServers: {},
openaiConfig: {},
});
});
@@ -281,6 +286,7 @@ describe('Settings Loading and Merging', () => {
allowMCPServers: ['server1', 'server2'],
customThemes: {},
mcpServers: {},
openaiConfig: {},
});
});
@@ -560,6 +566,7 @@ describe('Settings Loading and Merging', () => {
expect(settings.merged).toEqual({
customThemes: {},
mcpServers: {},
openaiConfig: {},
});
// Check that error objects are populated in settings.errors
@@ -954,6 +961,7 @@ describe('Settings Loading and Merging', () => {
...systemSettingsContent,
customThemes: {},
mcpServers: {},
openaiConfig: {},
});
});
});

View File

@@ -92,7 +92,7 @@ export function AuthDialog({
setOpenAIApiKey(apiKey);
setOpenAIBaseUrl(baseUrl);
setOpenAIModel(model);
// Save OpenAI configuration to user settings as fallback
// Priority order: .env > workspace settings.json > ~/.qwen/settings.json
try {
@@ -100,14 +100,14 @@ export function AuthDialog({
if (apiKey.trim()) openAIConfig.OPENAI_API_KEY = apiKey.trim();
if (baseUrl.trim()) openAIConfig.OPENAI_BASE_URL = baseUrl.trim();
if (model.trim()) openAIConfig.OPENAI_MODEL = model.trim();
// Save to user settings as environment variables for next time
settings.setValue(SettingScope.User, 'openaiConfig' as any, openAIConfig);
settings.setValue(SettingScope.User, 'openaiConfig', openAIConfig);
} catch (error) {
// Don't block authentication if saving fails
console.warn('Failed to save OpenAI config to settings:', error);
}
setShowOpenAIKeyPrompt(false);
onSelect(AuthType.USE_OPENAI, SettingScope.User);
};
@@ -142,9 +142,18 @@ export function AuthDialog({
if (showOpenAIKeyPrompt) {
// Load default values from settings
const defaultValues = {
apiKey: process.env.OPENAI_API_KEY || settings.merged.openaiConfig?.OPENAI_API_KEY || '',
baseUrl: process.env.OPENAI_BASE_URL || settings.merged.openaiConfig?.OPENAI_BASE_URL || '',
model: process.env.OPENAI_MODEL || settings.merged.openaiConfig?.OPENAI_MODEL || '',
apiKey:
process.env.OPENAI_API_KEY ||
settings.merged.openaiConfig?.OPENAI_API_KEY ||
'',
baseUrl:
process.env.OPENAI_BASE_URL ||
settings.merged.openaiConfig?.OPENAI_BASE_URL ||
'',
model:
process.env.OPENAI_MODEL ||
settings.merged.openaiConfig?.OPENAI_MODEL ||
'',
};
return (
@@ -189,7 +198,7 @@ export function AuthDialog({
</Box>
<Box marginTop={1}>
<Text color={Colors.AccentBlue}>
{'https://github.com/QwenLM/Qwen3-Coder/blob/main/README.md'}
{'https://github.com/QwenLM/qwen-code/blob/main/README.md'}
</Text>
</Box>
</Box>

View File

@@ -17,8 +17,7 @@ describe('OpenAIKeyPrompt', () => {
<OpenAIKeyPrompt onSubmit={onSubmit} onCancel={onCancel} />,
);
expect(lastFrame()).toContain('OpenAI Configuration Required');
expect(lastFrame()).toContain('https://platform.openai.com/api-keys');
expect(lastFrame()).toContain('API Configuration Required');
expect(lastFrame()).toContain(
'Press Enter to continue, Tab/↑↓ to navigate, Esc to cancel',
);
@@ -33,7 +32,7 @@ describe('OpenAIKeyPrompt', () => {
);
const output = lastFrame();
expect(output).toContain('OpenAI Configuration Required');
expect(output).toContain('API Configuration Required');
expect(output).toContain('API Key:');
expect(output).toContain('Base URL:');
expect(output).toContain('Model:');

View File

@@ -31,7 +31,6 @@ export function OpenAIKeyPrompt({
>('apiKey');
useInput((input, key) => {
// Ignore control sequences like [I or [O from focus switching
if (input && (input === '[I' || input === '[O')) {
return;
@@ -147,15 +146,10 @@ export function OpenAIKeyPrompt({
width="100%"
>
<Text bold color={Colors.AccentBlue}>
OpenAI Configuration Required
API Configuration Required
</Text>
<Box marginTop={1}>
<Text>
Please enter your OpenAI configuration. You can get an API key from{' '}
<Text color={Colors.AccentBlue}>
https://platform.openai.com/api-keys
</Text>
</Text>
<Text>Please enter your API configuration.</Text>
</Box>
<Box marginTop={1} flexDirection="row">
<Box width={12}>