修复前端登录权限边界问题

This commit is contained in:
andy
2026-07-10 09:35:47 +08:00
parent e49b2ccc1d
commit 25efcccf72
11 changed files with 282 additions and 15 deletions

View File

@@ -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)
})
})