gongxiangp2/components/department-dashboard/BrandCenterDashboard.test.tsx
2026-09-01 17:03:41 +08:00

37 lines
2.3 KiB
TypeScript

import { render, screen, within } from '@testing-library/react'
import BrandCenterDashboard from './BrandCenterDashboard'
jest.mock('next-auth/react', () => ({
useSession: () => ({
status: 'authenticated',
data: { user: { name: '本地超级管理员', email: 'superadmin@local.test' } },
}),
signOut: jest.fn(),
}))
describe('BrandCenterDashboard', () => {
it('大板块不可点击,小项分别进入对应二级页面', () => {
render(<BrandCenterDashboard />)
const workspaces = screen.getByRole('region', { name: '五个工作板块' })
const dashboard = within(workspaces).getByRole('article', { name: '中心仪表盘' })
const assets = within(workspaces).getByRole('article', { name: '资产与AI自动化' })
expect(screen.getByRole('heading', { level: 1, name: '品牌中心部门看板' })).toBeInTheDocument()
expect(within(workspaces).queryByRole('link', { name: '中心仪表盘' })).not.toBeInTheDocument()
expect(within(dashboard).getByRole('link', { name: /核心指标/ })).toHaveAttribute('href', '/workspaces/dashboard/core-metrics')
expect(within(dashboard).getByRole('link', { name: /业务趋势/ })).toHaveAttribute('href', '/workspaces/dashboard/business-trends')
expect(within(assets).getByRole('link', { name: /素材资产库/ })).toHaveAttribute('href', '/assets/material-library')
expect(within(assets).getByRole('link', { name: /自动化工作流/ })).toHaveAttribute('href', '/workspaces/assets/automation-workflows')
expect(within(assets).getByText('2 项工作流已接入')).toBeInTheDocument()
expect(within(workspaces).getAllByRole('link')).toHaveLength(17)
expect(within(workspaces).queryByRole('link', { name: '新品上新' })).not.toBeInTheDocument()
expect(within(workspaces).queryByRole('link', { name: '创意生产' })).not.toBeInTheDocument()
expect(within(workspaces).queryByRole('link', { name: '项目协同' })).not.toBeInTheDocument()
expect(screen.queryByText('选择板块内的小项进入对应二级页面。')).not.toBeInTheDocument()
expect(screen.queryByText('18 个二级入口 · 1 个业务页面已接入')).not.toBeInTheDocument()
expect(screen.queryByRole('navigation', { name: '工作板块快速导航' })).not.toBeInTheDocument()
expect(screen.queryByText('当前选择')).not.toBeInTheDocument()
})
})