新增 10 个管理端 E2E 测试文件和 1 个 Mock fixture: - admin.fixture.ts: Mock 数据 + 登录注入 + 组件预热 + 兜底 API 拦截 - login/contests/dashboard/navigation/registrations/works/reviews/users 等 9 个 spec 关键修复:route.fallback() 替代 route.continue() 修正 Mock 链式传递; review-rules/select Mock + 兜底拦截器防止未 mock 请求到达真实后端。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
88 lines
3.1 KiB
TypeScript
88 lines
3.1 KiB
TypeScript
import { test, expect } from '../fixtures/admin.fixture'
|
||
|
||
/**
|
||
* 工作台/仪表盘测试
|
||
*/
|
||
|
||
test.describe('工作台/仪表盘', () => {
|
||
test('D-01 工作台页面正常加载', async ({ adminPage }) => {
|
||
const page = adminPage
|
||
|
||
// 导航到工作台
|
||
await page.locator('.ant-menu-item').filter({ hasText: '工作台' }).first().click()
|
||
await page.waitForURL(/dashboard|workbench/, { timeout: 10_000 })
|
||
|
||
// 验证页面容器存在
|
||
await expect(page.locator('.tenant-dashboard')).toBeVisible({ timeout: 10_000 })
|
||
|
||
// 验证欢迎横幅可见
|
||
await expect(page.locator('.welcome-banner')).toBeVisible()
|
||
})
|
||
|
||
test('D-02 统计卡片数据展示', async ({ adminPage }) => {
|
||
const page = adminPage
|
||
|
||
// 导航到工作台
|
||
await page.locator('.ant-menu-item').filter({ hasText: '工作台' }).first().click()
|
||
await page.waitForURL(/dashboard|workbench/, { timeout: 10_000 })
|
||
|
||
// 等待统计数据加载
|
||
await expect(page.locator('.stat-card').first()).toBeVisible({ timeout: 10_000 })
|
||
|
||
// 验证统计卡片数量(6个:可见活动、进行中、总报名数、待审核报名、总作品数、今日报名)
|
||
const statCards = page.locator('.stat-card')
|
||
const count = await statCards.count()
|
||
expect(count).toBe(6)
|
||
|
||
// 验证统计数字存在(非空)
|
||
const statCounts = page.locator('.stat-count')
|
||
for (let i = 0; i < await statCounts.count(); i++) {
|
||
const text = await statCounts.nth(i).textContent()
|
||
expect(text).not.toBeNull()
|
||
expect(text!.trim().length).toBeGreaterThan(0)
|
||
}
|
||
})
|
||
|
||
test('D-03 快捷入口可点击', async ({ adminPage }) => {
|
||
const page = adminPage
|
||
|
||
// 导航到工作台
|
||
await page.locator('.ant-menu-item').filter({ hasText: '工作台' }).first().click()
|
||
await page.waitForURL(/dashboard|workbench/, { timeout: 10_000 })
|
||
|
||
// 等待快捷操作加载
|
||
await expect(page.locator('.action-item').first()).toBeVisible({ timeout: 10_000 })
|
||
|
||
// 验证至少有快捷操作按钮
|
||
const actionItems = page.locator('.action-item')
|
||
const count = await actionItems.count()
|
||
expect(count).toBeGreaterThan(0)
|
||
|
||
// 点击第一个快捷入口
|
||
await actionItems.first().click()
|
||
|
||
// 验证页面跳转(离开工作台)
|
||
await page.waitForURL(/gdlib\/(contests|system)/, { timeout: 10_000 })
|
||
})
|
||
|
||
test('D-04 顶部信息栏正确', async ({ adminPage }) => {
|
||
const page = adminPage
|
||
|
||
// 导航到工作台
|
||
await page.locator('.ant-menu-item').filter({ hasText: '工作台' }).first().click()
|
||
await page.waitForURL(/dashboard|workbench/, { timeout: 10_000 })
|
||
|
||
// 验证欢迎横幅中的用户名
|
||
const welcomeText = await page.locator('.welcome-banner h1').textContent()
|
||
expect(welcomeText).toContain('管理员')
|
||
|
||
// 验证日期显示
|
||
await expect(page.locator('.date-text')).toBeVisible()
|
||
|
||
// 验证底部用户信息
|
||
await expect(page.locator('.user-info .username')).toBeVisible()
|
||
const username = await page.locator('.user-info .username').textContent()
|
||
expect(username).toBeTruthy()
|
||
})
|
||
})
|