import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import MaterialLibraryAccessShell from './MaterialLibraryAccessShell' const signOut = jest.fn() jest.mock('next-auth/react', () => ({ signOut: (...args: unknown[]) => signOut(...args), })) jest.mock('@/components/department-dashboard/DepartmentShell', () => ({ __esModule: true, default: ({ children }: { children: React.ReactNode }) =>
{children}
, })) describe('MaterialLibraryAccessShell', () => { beforeEach(() => signOut.mockClear()) test('品牌中心人员保留部门工作台导航', () => { render(

素材列表

) expect(screen.getByTestId('department-shell')).toBeInTheDocument() expect(screen.queryByRole('banner', { name: '素材资产库顶栏' })).not.toBeInTheDocument() }) test('品牌中心外人员只看到独立素材库壳且可以退出', async () => { render(

素材列表

) expect(screen.queryByTestId('department-shell')).not.toBeInTheDocument() expect(screen.getByRole('banner', { name: '素材资产库顶栏' })).toBeInTheDocument() expect(screen.getByText('素材资产库')).toBeInTheDocument() expect(screen.queryByRole('link')).not.toBeInTheDocument() await userEvent.click(screen.getByRole('button', { name: '退出登录' })) expect(signOut).toHaveBeenCalledWith({ callbackUrl: '/login' }) }) })