This commit is contained in:
Stephen Zhou 2026-03-19 11:28:28 +08:00
parent 4dc965aebf
commit b1ff105e8c
No known key found for this signature in database
2 changed files with 5 additions and 2 deletions

View File

@ -41,7 +41,7 @@ describe('RoleRouteGuard', () => {
setAppContext()
})
it('should keep rendering children while workspace is loading', () => {
it('should hide guarded content while workspace is loading', () => {
setAppContext({
isLoadingCurrentWorkspace: true,
})
@ -52,7 +52,7 @@ describe('RoleRouteGuard', () => {
</RoleRouteGuard>
))
expect(screen.getByTestId('guarded-content')).toBeInTheDocument()
expect(screen.queryByTestId('guarded-content')).not.toBeInTheDocument()
expect(mockReplace).not.toHaveBeenCalled()
})

View File

@ -21,6 +21,9 @@ export default function RoleRouteGuard({ children }: { children: ReactNode }) {
router.replace('/datasets')
}, [shouldRedirect, router])
if (shouldGuardRoute && isLoadingCurrentWorkspace)
return null
if (shouldRedirect)
return null