mirror of
https://github.com/xpltdco/media-rip.git
synced 2026-04-03 02:53:58 -06:00
- PurgeConfig: max_age_hours→max_age_minutes (default 1440) - PurgeConfig: privacy_retention_hours→privacy_retention_minutes (default 1440) - PurgeConfig: enabled default False→True - PurgeConfig: cron default every minute (was daily 3am) - Purge scheduler runs every minute for minute-granularity testing - All API fields renamed: purge_max_age_minutes, privacy_retention_minutes - Frontend admin panel inputs show minutes with updated labels - Updated test assertions for new defaults
61 lines
1.6 KiB
TypeScript
61 lines
1.6 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',
|
|
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)
|
|
})
|
|
})
|