From 5fbec8a7c9ba16aeb67c5a0b35e9ba34ed7287d1 Mon Sep 17 00:00:00 2001 From: WuYongJie Date: Mon, 15 Jun 2026 10:37:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(layout):=20=E4=BF=AE=E5=A4=8D=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E5=8F=B0=E5=AF=BC=E8=88=AA=E9=A6=96=E5=B1=8F=E6=9D=83?= =?UTF-8?q?=E9=99=90=E5=8A=A0=E8=BD=BD=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/layout/AppShell.tsx | 2 +- .../layout/__tests__/AppShell.test.tsx | 23 ++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) 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')