peregrine/web/src/views/settings/SettingsView.test.ts
pyr0ball 05a737572e feat(settings): foundation — appConfig store, settings shell, nested router
- Add useAppConfigStore (isCloud, isDevMode, tier, contractedClient, inferenceProfile)
- Add GET /api/config/app endpoint to dev-api.py (reads env vars)
- Replace flat /settings route with nested children (9 tabs) + redirect to my-profile
- Add global router.beforeEach guard for system/fine-tune/developer tab access control
- Add SettingsView.vue shell: desktop sidebar with group labels, mobile chip bar, RouterView
- Tab visibility driven reactively by store state (cloud mode hides system, GPU profile gates fine-tune, devMode gates developer)
- Tests: 3 store tests + 3 component tests, all passing
2026-03-21 02:19:43 -07:00

36 lines
1.4 KiB
TypeScript

import { describe, it, expect, beforeEach } from 'vitest'
import { mount } from '@vue/test-utils'
import { createPinia, setActivePinia } from 'pinia'
import { createRouter, createWebHistory } from 'vue-router'
import SettingsView from './SettingsView.vue'
import { useAppConfigStore } from '../../stores/appConfig'
function makeRouter() {
return createRouter({ history: createWebHistory(), routes: [{ path: '/:p*', component: { template: '<div/>' } }] })
}
describe('SettingsView sidebar', () => {
beforeEach(() => setActivePinia(createPinia()))
it('hides System group items in cloud mode', async () => {
const store = useAppConfigStore()
store.isCloud = true
const wrapper = mount(SettingsView, { global: { plugins: [makeRouter()] } })
expect(wrapper.find('[data-testid="nav-system"]').exists()).toBe(false)
})
it('shows System when not cloud', async () => {
const store = useAppConfigStore()
store.isCloud = false
const wrapper = mount(SettingsView, { global: { plugins: [makeRouter()] } })
expect(wrapper.find('[data-testid="nav-system"]').exists()).toBe(true)
})
it('hides Developer when neither devMode nor devTierOverride', () => {
const store = useAppConfigStore()
store.isDevMode = false
localStorage.removeItem('dev_tier_override')
const wrapper = mount(SettingsView, { global: { plugins: [makeRouter()] } })
expect(wrapper.find('[data-testid="nav-developer"]').exists()).toBe(false)
})
})