More webui layout, navigation, preparations of user/roles/groups/security
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { parseLocation, pathFor } from './navigation'
|
||||
|
||||
describe('pathFor', () => {
|
||||
it('maps sections and config tabs to paths', () => {
|
||||
expect(pathFor('overview')).toBe('/')
|
||||
expect(pathFor('vms')).toBe('/vms')
|
||||
expect(pathFor('containers')).toBe('/containers')
|
||||
expect(pathFor('configuration')).toBe('/configuration')
|
||||
expect(pathFor('configuration', 'overview')).toBe('/configuration')
|
||||
expect(pathFor('configuration', 'groups')).toBe('/configuration/groups')
|
||||
expect(pathFor('configuration', 'roles')).toBe('/configuration/roles')
|
||||
})
|
||||
})
|
||||
|
||||
describe('parseLocation', () => {
|
||||
it('round-trips known paths', () => {
|
||||
for (const path of [
|
||||
'/',
|
||||
'/vms',
|
||||
'/containers',
|
||||
'/configuration',
|
||||
'/configuration/users',
|
||||
'/configuration/roles',
|
||||
'/configuration/groups',
|
||||
'/configuration/security',
|
||||
'/configuration/integrations',
|
||||
'/configuration/network',
|
||||
'/configuration/advanced',
|
||||
]) {
|
||||
const location = parseLocation(path)
|
||||
expect(pathFor(location.section, location.configTab)).toBe(path)
|
||||
}
|
||||
})
|
||||
|
||||
it('falls back to overview for unknown paths', () => {
|
||||
expect(parseLocation('/nope')).toEqual({
|
||||
section: 'overview',
|
||||
configTab: 'overview',
|
||||
})
|
||||
expect(parseLocation('/configuration/unknown')).toEqual({
|
||||
section: 'overview',
|
||||
configTab: 'overview',
|
||||
})
|
||||
expect(parseLocation('/vms/extra')).toEqual({
|
||||
section: 'overview',
|
||||
configTab: 'overview',
|
||||
})
|
||||
})
|
||||
|
||||
it('treats trailing slashes as the same path', () => {
|
||||
expect(parseLocation('/configuration/groups/')).toEqual({
|
||||
section: 'configuration',
|
||||
configTab: 'groups',
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user