merge: 修复工作台导航首屏权限加载态
This commit is contained in:
commit
4f8d18f454
@ -195,7 +195,7 @@ function AppShellContent({ children, user }: AppShellProps) {
|
||||
)
|
||||
}
|
||||
|
||||
const currentUser = user === undefined ? fetchedUser ?? null : user
|
||||
const currentUser = user === undefined ? fetchedUser : user
|
||||
|
||||
// 移动端:workbench 路由使用底部 Tab Bar,顶部只显示简化的顶栏
|
||||
// 桌面端:保持原有布局
|
||||
|
||||
@ -11,8 +11,11 @@ jest.mock('next/navigation', () => ({
|
||||
}))
|
||||
|
||||
jest.mock('@/components/layout/AppTopNav', () => ({
|
||||
AppTopNav: ({ variant }: { variant?: string }) => (
|
||||
AppTopNav: ({ variant, user }: { variant?: string; user?: unknown | null }) => (
|
||||
<div data-testid="app-top-nav" data-variant={variant ?? 'default'}>
|
||||
<span data-testid="app-top-nav-user-state">
|
||||
{user === undefined ? 'loading' : user === null ? 'none' : 'ready'}
|
||||
</span>
|
||||
top nav
|
||||
</div>
|
||||
),
|
||||
@ -85,6 +88,24 @@ describe('AppShell', () => {
|
||||
expect(screen.getByText('home content')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('认证加载中保持用户态为 unknown,避免首屏导航误判为受限权限', () => {
|
||||
usePathnameMock.mockReturnValue('/')
|
||||
const originalFetch = global.fetch
|
||||
global.fetch = jest.fn(() => new Promise<Response>(() => undefined))
|
||||
|
||||
try {
|
||||
render(
|
||||
<AppShell>
|
||||
<div>home content</div>
|
||||
</AppShell>,
|
||||
)
|
||||
|
||||
expect(screen.getByTestId('app-top-nav-user-state')).toHaveTextContent('loading')
|
||||
} finally {
|
||||
global.fetch = originalFetch
|
||||
}
|
||||
})
|
||||
|
||||
it('辅助装配按资产中心工作台壳子渲染', () => {
|
||||
usePathnameMock.mockReturnValue('/assisted-assembly')
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user