chore(cli): enable deprecated settings removal by default (#20682)

This commit is contained in:
Yashodip More
2026-03-05 02:09:37 +05:30
committed by GitHub
parent c59ef74837
commit efec63658a
2 changed files with 35 additions and 21 deletions
+33 -18
View File
@@ -2162,7 +2162,7 @@ describe('Settings Loading and Merging', () => {
}
});
it('should prioritize new settings over deprecated ones and respect removeDeprecated flag', () => {
it('should remove deprecated settings by default and prioritize new ones', () => {
const userSettingsContent = {
general: {
disableAutoUpdate: true,
@@ -2177,27 +2177,11 @@ describe('Settings Loading and Merging', () => {
};
const loadedSettings = createMockSettings(userSettingsContent);
const setValueSpy = vi.spyOn(loadedSettings, 'setValue');
// 1. removeDeprecated = false (default)
// Default is now removeDeprecated = true
migrateDeprecatedSettings(loadedSettings);
// Should still have old settings
expect(
loadedSettings.forScope(SettingScope.User).settings.general,
).toHaveProperty('disableAutoUpdate');
expect(
(
loadedSettings.forScope(SettingScope.User).settings.context as {
fileFiltering: { disableFuzzySearch: boolean };
}
).fileFiltering,
).toHaveProperty('disableFuzzySearch');
// 2. removeDeprecated = true
migrateDeprecatedSettings(loadedSettings, true);
// Should remove disableAutoUpdate and trust enableAutoUpdate: true
expect(setValueSpy).toHaveBeenCalledWith(SettingScope.User, 'general', {
enableAutoUpdate: true,
@@ -2209,6 +2193,37 @@ describe('Settings Loading and Merging', () => {
});
});
it('should preserve deprecated settings when removeDeprecated is explicitly false', () => {
const userSettingsContent = {
general: {
disableAutoUpdate: true,
enableAutoUpdate: true,
},
context: {
fileFiltering: {
disableFuzzySearch: false,
enableFuzzySearch: false,
},
},
};
const loadedSettings = createMockSettings(userSettingsContent);
migrateDeprecatedSettings(loadedSettings, false);
// Should still have old settings since removeDeprecated = false
expect(
loadedSettings.forScope(SettingScope.User).settings.general,
).toHaveProperty('disableAutoUpdate');
expect(
(
loadedSettings.forScope(SettingScope.User).settings.context as {
fileFiltering: { disableFuzzySearch: boolean };
}
).fileFiltering,
).toHaveProperty('disableFuzzySearch');
});
it('should trigger migration automatically during loadSettings', () => {
mockFsExistsSync.mockImplementation(
(p: fs.PathLike) => p === USER_SETTINGS_PATH,