35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
import { render, screen, within } from '@testing-library/react'
|
|
import BrandHealthDashboard from './BrandHealthDashboard'
|
|
import {
|
|
BRAND_HEALTH_BRANDS,
|
|
BRAND_HEALTH_DIMENSIONS,
|
|
} from './brand-health'
|
|
|
|
jest.mock('next-auth/react', () => ({
|
|
useSession: () => ({ data: { user: { name: '本地超级管理员' } } }),
|
|
signOut: jest.fn(),
|
|
}))
|
|
|
|
describe('BrandHealthDashboard', () => {
|
|
it('为六个品牌展示统一的五项健康度框架且不虚构分数', () => {
|
|
render(<BrandHealthDashboard />)
|
|
|
|
expect(screen.getByRole('heading', { level: 1, name: '六品牌健康度' })).toBeInTheDocument()
|
|
expect(screen.queryByRole('complementary', { name: '健康度计算说明' })).not.toBeInTheDocument()
|
|
expect(screen.getAllByText('数据源待接入')).toHaveLength(6)
|
|
|
|
for (const brand of BRAND_HEALTH_BRANDS) {
|
|
const brandModule = screen.getByRole('article', { name: brand.name })
|
|
expect(within(brandModule).getByText(`${brand.team}负责品牌`)).toBeInTheDocument()
|
|
expect(within(brandModule).getByLabelText(`${brand.name}品牌健康分待接入`)).toHaveTextContent('—')
|
|
|
|
for (const dimension of BRAND_HEALTH_DIMENSIONS) {
|
|
expect(within(brandModule).getByText(dimension.label)).toBeInTheDocument()
|
|
expect(within(brandModule).getByText(`权重 ${dimension.weight}%`)).toBeInTheDocument()
|
|
}
|
|
}
|
|
|
|
expect(screen.getByRole('link', { name: /返回部门看板/ })).toHaveAttribute('href', '/')
|
|
})
|
|
})
|