import { beforeEach, describe, expect, it } from 'vitest' import { normalizeAppSettings } from '../../src/stores/settingsStore' import { isAppLanguage } from '../../src/i18n/detectLocale' describe('settings migration', () => { beforeEach(() => { // language default depends on navigator; tests assert explicit values }) it('keeps supported language and drops obsolete legacy settings', () => { const settings = normalizeAppSettings({ theme: 'light', timeout: 45, language: 'en', showNotifications: true, encryptPasswords: false, lockOnSleep: true, }) expect(settings.theme).toBe('light') expect(settings.timeout).toBe(45) expect(settings.language).toBe('en') expect(settings).not.toHaveProperty('showNotifications') expect(settings).not.toHaveProperty('encryptPasswords') expect(settings).not.toHaveProperty('lockOnSleep') }) it('falls back to a valid language when stored value is invalid', () => { const settings = normalizeAppSettings({ language: 'fr-FR' }) expect(isAppLanguage(settings.language)).toBe(true) }) it('rejects unsupported saved themes', () => { expect(normalizeAppSettings({ theme: 'invalid' }).theme).toBe('dark') expect(normalizeAppSettings({ theme: 'system' }).theme).toBe('system') }) })