实现系统管理后台 V1
This commit is contained in:
@@ -53,6 +53,15 @@ describe('reservation router', () => {
|
||||
expect(router.resolve('/debug/eml-superagent').name).toBe('debug-eml-superagent')
|
||||
})
|
||||
|
||||
it('exposes the System Admin V1 routes', () => {
|
||||
expect(router.resolve('/system/users').name).toBe('system-users')
|
||||
expect(router.resolve('/system/roles').name).toBe('system-roles')
|
||||
expect(router.resolve('/system/menus').name).toBe('system-menus')
|
||||
expect(router.resolve('/system/hotels').name).toBe('system-hotels')
|
||||
expect(router.resolve('/system/audits').name).toBe('system-audits')
|
||||
expect(router.resolve('/system/not-ready').name).toBe('not-found')
|
||||
})
|
||||
|
||||
it('declares permissions for protected P0 routes', () => {
|
||||
expect(router.resolve('/reservation/orders').meta.permission).toBe('RESERVATION_ORDER_READ')
|
||||
expect(router.resolve('/reservation/orders/20001').meta.permission).toBe('RESERVATION_ORDER_READ')
|
||||
@@ -62,6 +71,11 @@ describe('reservation router', () => {
|
||||
'SOURCE_MESSAGE_ORIGINAL_READ',
|
||||
)
|
||||
expect(router.resolve('/debug/eml-superagent').meta.permission).toBe('SYSTEM_DEBUG_EML_RUN')
|
||||
expect(router.resolve('/system/users').meta.permission).toBe('SYSTEM_USER_MANAGE')
|
||||
expect(router.resolve('/system/roles').meta.permission).toBe('SYSTEM_ROLE_MANAGE')
|
||||
expect(router.resolve('/system/menus').meta.permission).toBe('SYSTEM_MENU_MANAGE')
|
||||
expect(router.resolve('/system/hotels').meta.permission).toBe('HOTEL_MANAGE')
|
||||
expect(router.resolve('/system/audits').meta.permission).toBe('SYSTEM_ADMIN_CONSOLE_ACCESS')
|
||||
})
|
||||
|
||||
it('redirects anonymous users to login with the protected target as redirect', async () => {
|
||||
@@ -119,6 +133,19 @@ describe('reservation router', () => {
|
||||
expect(restored).toBe(true)
|
||||
})
|
||||
|
||||
it('redirects the System Admin entry to the first allowed management page', async () => {
|
||||
const guard = createAuthGuard(() =>
|
||||
createAuthStoreForGuard({
|
||||
hasPermission: (permission: string) =>
|
||||
permission === 'SYSTEM_ADMIN_CONSOLE_ACCESS' || permission === 'HOTEL_MANAGE',
|
||||
}),
|
||||
)
|
||||
|
||||
await expect(guard(createRoute('/system', { permission: 'SYSTEM_ADMIN_CONSOLE_ACCESS' }))).resolves.toBe(
|
||||
'/system/hotels',
|
||||
)
|
||||
})
|
||||
|
||||
it('redirects the root route to the default page when the backend menu points to root', async () => {
|
||||
const guard = createAuthGuard(() =>
|
||||
createAuthStoreForGuard({
|
||||
|
||||
Reference in New Issue
Block a user