mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-26 04:54:25 -07:00
refactor(cli): fix settings merging so that settings using the new json format take priority over ones using the old format (#15116)
This commit is contained in:
@@ -371,6 +371,37 @@ describe('Settings Loading and Merging', () => {
|
||||
expect((settings.merged as TestSettings)['allowedTools']).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should allow V2 settings to override V1 settings when both are present (zombie setting fix)', () => {
|
||||
(mockFsExistsSync as Mock).mockImplementation(
|
||||
(p: fs.PathLike) => p === USER_SETTINGS_PATH,
|
||||
);
|
||||
const mixedSettingsContent = {
|
||||
// V1 setting (migrates to ui.accessibility.screenReader = true)
|
||||
accessibility: {
|
||||
screenReader: true,
|
||||
},
|
||||
// V2 setting (explicitly set to false)
|
||||
ui: {
|
||||
accessibility: {
|
||||
screenReader: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
(fs.readFileSync as Mock).mockImplementation(
|
||||
(p: fs.PathOrFileDescriptor) => {
|
||||
if (p === USER_SETTINGS_PATH)
|
||||
return JSON.stringify(mixedSettingsContent);
|
||||
return '{}';
|
||||
},
|
||||
);
|
||||
|
||||
const settings = loadSettings(MOCK_WORKSPACE_DIR);
|
||||
|
||||
// We expect the V2 setting (false) to win, NOT the migrated V1 setting (true)
|
||||
expect(settings.merged.ui?.accessibility?.screenReader).toBe(false);
|
||||
});
|
||||
|
||||
it('should correctly merge and migrate legacy array properties from multiple scopes', () => {
|
||||
(mockFsExistsSync as Mock).mockReturnValue(true);
|
||||
const legacyUserSettings = {
|
||||
|
||||
Reference in New Issue
Block a user