test(ui): cover autoSaveEnabled settings sync round-trip

Ensure the new persisted editor autosave flag applies from server
settings, autosaves through appearanceAutoSave, and resets to true when
omitted from an authoritative snapshot.

Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-07-30 06:39:57 +00:00
co-authored by Serhii Dziupin
parent 5b727ed53c
commit d79908cc9e
+43
View File
@@ -497,4 +497,47 @@ describe('updateDesktopSettings', () => {
expect(saveCalls.some((changes) => changes.terminalShell === 'zsh')).toBe(true);
expect(saveCalls.some((changes) => changes.terminalLoginShells?.includes('zsh'))).toBe(true);
});
test('applies persisted autoSaveEnabled from server settings', async () => {
getWindow();
invalidateSettingsCache();
useUIStore.getState().setAutoSaveEnabled(true);
registerSettingsApi(async () => ({}), async () => ({
settings: { autoSaveEnabled: false, draftStartersCraftGoalAdded: true, draftStartersScheduleTaskAdded: true },
source: 'web',
}));
await syncDesktopSettings();
expect(useUIStore.getState().autoSaveEnabled).toBe(false);
});
test('autosaves autoSaveEnabled changes to shared settings', async () => {
getWindow();
useUIStore.getState().setAutoSaveEnabled(true);
const saveCalls: Array<Partial<SettingsPayload>> = [];
registerSettingsSave(async (changes) => {
saveCalls.push(changes);
return changes as SettingsPayload;
});
startAppearanceAutoSave();
useUIStore.getState().setAutoSaveEnabled(false);
await delay(500);
expect(saveCalls.some((changes) => changes.autoSaveEnabled === false)).toBe(true);
});
test('resets omitted autoSaveEnabled to the default enabled state', async () => {
getWindow();
useUIStore.getState().setAutoSaveEnabled(false);
registerSettingsApi(async () => ({}), async () => ({
settings: { draftStartersCraftGoalAdded: true, draftStartersScheduleTaskAdded: true },
source: 'web',
}));
await syncDesktopSettings();
expect(useUIStore.getState().autoSaveEnabled).toBe(true);
});
});