import { fireEvent, render, screen, within } from '@testing-library/react' import AutomationWorkflowsDashboard from './AutomationWorkflowsDashboard' const replace = jest.fn() jest.mock('next-auth/react', () => ({ useSession: () => ({ data: { user: { name: '本地超级管理员' } } }), signOut: jest.fn(), })) jest.mock('next/navigation', () => ({ useRouter: () => ({ replace }), useSearchParams: () => new URLSearchParams(), })) describe('AutomationWorkflowsDashboard', () => { beforeEach(() => replace.mockClear()) it('通过二级边栏切换右侧已有业务操作界面', () => { render() expect(screen.queryByText('2 项业务已接入')).not.toBeInTheDocument() const secondaryNavigation = screen.getByRole('navigation', { name: '自动化工作流二级导航' }) const performanceSurvey = within(secondaryNavigation).getByRole('button', { name: /绩效考核调研/ }) const workReview = within(secondaryNavigation).getByRole('button', { name: /作品过稿看板/ }) expect(performanceSurvey).toHaveAttribute('aria-current', 'page') expect(performanceSurvey).toHaveClass('bg-[#e6f4ff]', 'text-[#0050cb]') expect(workReview).toHaveClass('hover:bg-[#eef2f6]') expect(screen.getByTitle('绩效考核调研操作界面')).toHaveAttribute('src', '/performance-survey') fireEvent.click(workReview) expect(workReview).toHaveAttribute('aria-current', 'page') expect(screen.getByTitle('作品过稿看板操作界面')).toHaveAttribute('src', '/work-review') expect(replace).toHaveBeenCalledWith( '/workspaces/assets/automation-workflows?workflow=work-review', { scroll: false }, ) }) })