fix(settings): case sync asks and merges only while it is on

- session-ui.js: no GET /api/settings on a tab return unless this device's cached syncCaseState is true
- system-routes.ts: caseSettings is merged only while syncCaseState is true (as stored or set by the same PUT)
- sync-case-state tests cover both; wiki notes the stored options stay when sync is turned off
This commit is contained in:
Devvyn committed 2026-11-09 10:03:08 +08:00
1 parent a50d0db283
commit f8ff431d30
5 files changed
+24 -6

No files matched your search

+11
View File
@@ -64,6 +64,17 @@ describe('shared case options', () => {
expect(readSettings().caseSettings).toEqual({ alpha: on, beta: off, gamma: on });
});
it('ignores a caseSettings PUT while syncCaseState is off, and takes one that turns it on', async () => {
seed({ syncCaseState: false, caseSettings: { kept: off } });
expect((await send('PUT', '/api/settings', { caseSettings: { alpha: on } })).status).toBe(200);
expect(readSettings().caseSettings).toEqual({ kept: off });
seed({});
await send('PUT', '/api/settings', { caseSettings: { alpha: on } });
expect(readSettings().caseSettings).toBeUndefined();
await send('PUT', '/api/settings', { syncCaseState: true, caseSettings: { alpha: on } });
expect(readSettings().caseSettings).toEqual({ alpha: on });
});
it('keeps the other cases when one is saved again, and every other setting', async () => {
seed({ syncCaseState: true, lastUsedCase: 'x', caseSettings: { alpha: on, beta: off } });
await send('PUT', '/api/settings', { caseSettings: { alpha: off } });
+4 -4
View File
@@ -188,11 +188,11 @@ describe('returning to the tab', () => {
expect(app._caseStateSyncOn()).toBe(false);
});
it('starts following when another device turned sync on', async () => {
const { app, select, settings } = makeApp({}, () => env({ syncCaseState: true, lastUsedCase: 'beta' }));
it('asks for nothing on a tab return while this device has sync off', async () => {
const { app, select, calls } = makeApp({}, () => env({ syncCaseState: true, lastUsedCase: 'beta' }));
await app._syncCaseStateFromServer();
expect(settings.syncCaseState).toBe(true);
expect(select.value).toBe('beta');
expect(calls).toEqual([]);
expect(select.value).toBe('alpha');
});
it('does nothing for a read-only identity', async () => {