mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 02:34:21 +00:00
feat(mcp): let update_display_settings set the dashboard world clocks (#3044)
dashboard_timezones joins the display-preference allow-list as a list of IANA zone ids, each checked with Intl like the widget does, without repeats and capped at 24. The write goes through saveMany, so open tabs refresh, and both tool descriptions name the widget's fallback zones.
This commit is contained in:
@@ -15,7 +15,7 @@ import { Settings } from '../../../src/db/entities/Settings.entity';
|
||||
import { encrypt_api_key } from '../../../src/nest/common/crypto/apiKeyCrypto';
|
||||
import { MANAGED_LOCKED_SETTING_KEYS } from '../../../src/nest/common/managed';
|
||||
import { RealtimeService } from '../../../src/nest/realtime/realtime.service';
|
||||
import { DISPLAY_PREFERENCE_KEYS } from '../../../src/nest/settings/settings.mcp';
|
||||
import { DISPLAY_PREFERENCE_KEYS, MAX_DASHBOARD_TIMEZONES } from '../../../src/nest/settings/settings.mcp';
|
||||
import {
|
||||
isAdminOnlyEndpointSetting,
|
||||
ENCRYPTED_SETTING_KEYS,
|
||||
@@ -288,6 +288,44 @@ describe('Tool: update_display_settings', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('writes dashboard_timezones as the stored list and reads it back (#3044)', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
await withHarness(user.id, async (h) => {
|
||||
const data = parseToolResult(await update(h, { dashboard_timezones: ['Europe/Madrid', 'Africa/Cairo'] })) as {
|
||||
settings: Record<string, unknown>;
|
||||
};
|
||||
expect(data.settings.dashboard_timezones).toEqual(['Europe/Madrid', 'Africa/Cairo']);
|
||||
expect(await readSetting(user.id, 'dashboard_timezones')).toBe('["Europe/Madrid","Africa/Cairo"]');
|
||||
});
|
||||
});
|
||||
|
||||
it('accepts an empty dashboard_timezones list, which shows no clocks (#3044)', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
await withHarness(user.id, async (h) => {
|
||||
const data = parseToolResult(await update(h, { dashboard_timezones: [] })) as {
|
||||
settings: Record<string, unknown>;
|
||||
};
|
||||
expect(data.settings.dashboard_timezones).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
it('refuses dashboard_timezones that are unknown, repeated, not a list or too many (#3044)', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
const tooMany = Intl.supportedValuesOf('timeZone').slice(0, MAX_DASHBOARD_TIMEZONES + 1);
|
||||
await withHarness(user.id, async (h) => {
|
||||
const unknown = await update(h, { dashboard_timezones: ['Europe/Madrid', 'Mars/Olympus_Mons'] });
|
||||
expect(unknown.isError).toBe(true);
|
||||
expect(errorText(unknown)).toContain('IANA');
|
||||
expect((await update(h, { dashboard_timezones: [''] })).isError).toBe(true);
|
||||
expect((await update(h, { dashboard_timezones: ['Asia/Tokyo', 'Asia/Tokyo'] })).isError).toBe(true);
|
||||
expect((await update(h, { dashboard_timezones: 'Europe/Madrid' })).isError).toBe(true);
|
||||
const capped = await update(h, { dashboard_timezones: tooMany });
|
||||
expect(capped.isError).toBe(true);
|
||||
expect(errorText(capped)).toContain(`at most ${MAX_DASHBOARD_TIMEZONES}`);
|
||||
expect(await countSettings(user.id)).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('accepts every boolean display preference', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
await withHarness(user.id, async (h) => {
|
||||
|
||||
Reference in New Issue
Block a user