mirror of
https://github.com/xpltdco/media-rip.git
synced 2026-04-03 02:53:58 -06:00
Admin Settings: - Theme section: pick Dark Theme, Light Theme, and Default Mode - 5 dark options (Cyberpunk/Dark/Midnight/Hacker/Neon) - 4 light options (Light/Paper/Arctic/Solarized) - Persisted in SQLite — survives container rebuilds - Served via /api/config/public so frontend loads admin defaults Visitor behavior: - Page loads with admin's chosen default (dark or light theme) - Sun/moon icon toggles between admin's dark and light pair - Preference stored in cookie — persists within browser session - No theme dropdown for visitors — admin controls the pair Header icon simplified back to clean dark/light toggle
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
|
import { setActivePinia, createPinia } from 'pinia'
|
|
import { useConfigStore } from '@/stores/config'
|
|
|
|
// Mock the api module
|
|
vi.mock('@/api/client', () => ({
|
|
api: {
|
|
getPublicConfig: vi.fn(),
|
|
},
|
|
}))
|
|
|
|
import { api } from '@/api/client'
|
|
|
|
describe('config store', () => {
|
|
beforeEach(() => {
|
|
setActivePinia(createPinia())
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
it('starts with null config', () => {
|
|
const store = useConfigStore()
|
|
expect(store.config).toBeNull()
|
|
expect(store.isLoading).toBe(false)
|
|
expect(store.error).toBeNull()
|
|
})
|
|
|
|
it('loads config successfully', async () => {
|
|
const mockConfig = {
|
|
session_mode: 'isolated',
|
|
default_theme: 'dark',
|
|
theme_dark: 'cyberpunk',
|
|
theme_light: 'light',
|
|
theme_default_mode: 'dark',
|
|
welcome_message: 'Test welcome',
|
|
purge_enabled: false,
|
|
max_concurrent_downloads: 3,
|
|
default_video_format: 'auto',
|
|
default_audio_format: 'auto',
|
|
privacy_mode: false,
|
|
privacy_retention_minutes: 1440,
|
|
admin_enabled: true,
|
|
admin_setup_complete: false,
|
|
}
|
|
vi.mocked(api.getPublicConfig).mockResolvedValue(mockConfig)
|
|
|
|
const store = useConfigStore()
|
|
await store.loadConfig()
|
|
|
|
expect(store.config).toEqual(mockConfig)
|
|
expect(store.isLoading).toBe(false)
|
|
expect(store.error).toBeNull()
|
|
})
|
|
|
|
it('handles load error', async () => {
|
|
vi.mocked(api.getPublicConfig).mockRejectedValue(new Error('Network error'))
|
|
|
|
const store = useConfigStore()
|
|
await store.loadConfig()
|
|
|
|
expect(store.config).toBeNull()
|
|
expect(store.error).toBe('Network error')
|
|
expect(store.isLoading).toBe(false)
|
|
})
|
|
})
|