diff --git a/furniture-3d-system/src/components/layout/AppShell.tsx b/furniture-3d-system/src/components/layout/AppShell.tsx index aff6cdfe..7fc5fd52 100644 --- a/furniture-3d-system/src/components/layout/AppShell.tsx +++ b/furniture-3d-system/src/components/layout/AppShell.tsx @@ -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,顶部只显示简化的顶栏 // 桌面端:保持原有布局 diff --git a/furniture-3d-system/src/components/layout/__tests__/AppShell.test.tsx b/furniture-3d-system/src/components/layout/__tests__/AppShell.test.tsx index aa9b42b1..dc4d4baf 100644 --- a/furniture-3d-system/src/components/layout/__tests__/AppShell.test.tsx +++ b/furniture-3d-system/src/components/layout/__tests__/AppShell.test.tsx @@ -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 }) => (
+ + {user === undefined ? 'loading' : user === null ? 'none' : 'ready'} + top nav
), @@ -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(() => undefined)) + + try { + render( + +
home content
+
, + ) + + expect(screen.getByTestId('app-top-nav-user-state')).toHaveTextContent('loading') + } finally { + global.fetch = originalFetch + } + }) + it('辅助装配按资产中心工作台壳子渲染', () => { usePathnameMock.mockReturnValue('/assisted-assembly')