修复前端登录权限边界问题
This commit is contained in:
@@ -85,4 +85,32 @@ describe('reservation router', () => {
|
||||
name: 'unauthorized',
|
||||
})
|
||||
})
|
||||
|
||||
it('redirects the root route to the restored first backend menu', async () => {
|
||||
let restored = false
|
||||
let authenticated = false
|
||||
let firstMenuPath: string | null = null
|
||||
const authStore = {
|
||||
restoreAttempted: false,
|
||||
get isAuthenticated() {
|
||||
return authenticated
|
||||
},
|
||||
get firstMenuPath() {
|
||||
return firstMenuPath
|
||||
},
|
||||
hasStoredToken: () => true,
|
||||
restoreFromSession: async () => {
|
||||
restored = true
|
||||
authStore.restoreAttempted = true
|
||||
authenticated = true
|
||||
firstMenuPath = '/reservation/tasks'
|
||||
return true
|
||||
},
|
||||
hasPermission: () => true,
|
||||
} as unknown as AuthStoreForGuard
|
||||
const guard = createAuthGuard(() => authStore)
|
||||
|
||||
await expect(guard(createRoute('/'))).resolves.toBe('/reservation/tasks')
|
||||
expect(restored).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user