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

View File

@@ -102,7 +102,7 @@ export function AuthDialog({
if (model.trim()) openAIConfig.OPENAI_MODEL = model.trim(); if (model.trim()) openAIConfig.OPENAI_MODEL = model.trim();
// Save to user settings as environment variables for next time // 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) { } catch (error) {
// Don't block authentication if saving fails // Don't block authentication if saving fails
console.warn('Failed to save OpenAI config to settings:', error); console.warn('Failed to save OpenAI config to settings:', error);
@@ -142,9 +142,18 @@ export function AuthDialog({
if (showOpenAIKeyPrompt) { if (showOpenAIKeyPrompt) {
// Load default values from settings // Load default values from settings
const defaultValues = { const defaultValues = {
apiKey: process.env.OPENAI_API_KEY || settings.merged.openaiConfig?.OPENAI_API_KEY || '', apiKey:
baseUrl: process.env.OPENAI_BASE_URL || settings.merged.openaiConfig?.OPENAI_BASE_URL || '', process.env.OPENAI_API_KEY ||
model: process.env.OPENAI_MODEL || settings.merged.openaiConfig?.OPENAI_MODEL || '', 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 ( return (
@@ -189,7 +198,7 @@ export function AuthDialog({
</Box> </Box>
<Box marginTop={1}> <Box marginTop={1}>
<Text color={Colors.AccentBlue}> <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> </Text>
</Box> </Box>
</Box> </Box>

View File

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

View File

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