Skip to content

Commit 01870d5

Browse files
authored
fix(core): fix overrider (#980)
1 parent 2710212 commit 01870d5

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

packages/shared/src/env.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,11 @@ export const getAIConfig = (
217217
);
218218
}
219219

220-
return getGlobalConfig()[configKey]?.trim?.();
220+
const value = getGlobalConfig()[configKey];
221+
if (typeof value === 'string') {
222+
return value.trim();
223+
}
224+
return value;
221225
};
222226

223227
export const getAIConfigInBoolean = (
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { afterAll, describe, expect, it, vi } from 'vitest';
2+
import {
3+
MIDSCENE_USE_DOUBAO_VISION,
4+
overrideAIConfig,
5+
vlLocateMode,
6+
} from '../../src/env';
7+
8+
describe('env', () => {
9+
afterAll(() => {
10+
// Reset process.env before each test
11+
vi.resetModules();
12+
});
13+
14+
it('getAIConfigInBoolean', () => {
15+
overrideAIConfig({
16+
[MIDSCENE_USE_DOUBAO_VISION]: 'true',
17+
});
18+
19+
const vlMode = vlLocateMode();
20+
expect(vlMode).toBe('doubao-vision');
21+
});
22+
23+
it('getAIConfigInBoolean 2', () => {
24+
overrideAIConfig({
25+
[MIDSCENE_USE_DOUBAO_VISION]: 1 as any,
26+
});
27+
28+
const vlMode = vlLocateMode();
29+
expect(vlMode).toBe('doubao-vision');
30+
});
31+
});

0 commit comments

Comments
 (0)