新增 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>
91 lines
3.0 KiB
TypeScript
91 lines
3.0 KiB
TypeScript
import { test, expect } from '../fixtures/admin.fixture'
|
|
|
|
/**
|
|
* 活动管理列表测试
|
|
*/
|
|
|
|
test.describe('活动管理列表', () => {
|
|
test.beforeEach(async ({ adminPage }) => {
|
|
const page = adminPage
|
|
|
|
// 导航到活动管理 > 活动列表
|
|
const submenu = page.locator('.ant-menu-submenu').filter({ hasText: '活动管理' }).first()
|
|
await submenu.click()
|
|
await page.waitForTimeout(500)
|
|
await submenu.locator('.ant-menu-item').filter({ hasText: '活动列表' }).first().click()
|
|
await page.waitForURL(/contests\/list/, { timeout: 15_000 })
|
|
})
|
|
|
|
test('C-01 活动列表页正常加载', async ({ adminPage }) => {
|
|
const page = adminPage
|
|
|
|
// 验证页面标题
|
|
await expect(page.locator('.title-card').getByText('活动列表')).toBeVisible({ timeout: 10_000 })
|
|
|
|
// 验证表格渲染
|
|
await expect(page.locator('.data-table')).toBeVisible()
|
|
|
|
// 验证表格有数据行
|
|
const rows = page.locator('.ant-table-tbody tr')
|
|
const rowCount = await rows.count()
|
|
expect(rowCount).toBeGreaterThan(0)
|
|
})
|
|
|
|
test('C-02 搜索功能正常', async ({ adminPage }) => {
|
|
const page = adminPage
|
|
|
|
// 等待搜索表单可见
|
|
await expect(page.locator('.search-form')).toBeVisible()
|
|
|
|
// 在搜索框输入关键词
|
|
await page.locator('input[placeholder="请输入活动名称"]').fill('绘本')
|
|
|
|
// 点击搜索按钮
|
|
await page.locator('.search-form button[type="submit"]').click()
|
|
|
|
// 验证表格刷新(有 loading 状态后恢复)
|
|
await page.waitForTimeout(1000)
|
|
await expect(page.locator('.ant-table-tbody tr').first()).toBeVisible()
|
|
})
|
|
|
|
test('C-03 活动阶段筛选正常', async ({ adminPage }) => {
|
|
const page = adminPage
|
|
|
|
// 等待统计卡片可见
|
|
await expect(page.locator('.stat-card').first()).toBeVisible({ timeout: 10_000 })
|
|
|
|
// 点击"报名中"统计卡片
|
|
await page.locator('.stat-card').filter({ hasText: '报名中' }).click()
|
|
|
|
// 验证筛选生效(活动阶段选择器或卡片高亮)
|
|
const activeCard = page.locator('.stat-card.active')
|
|
await expect(activeCard).toBeVisible()
|
|
})
|
|
|
|
test('C-04 分页功能正常', async ({ adminPage }) => {
|
|
const page = adminPage
|
|
|
|
// 验证分页组件可见
|
|
await expect(page.locator('.ant-pagination')).toBeVisible({ timeout: 10_000 })
|
|
|
|
// 验证总数信息显示
|
|
const paginationText = await page.locator('.ant-pagination').textContent()
|
|
expect(paginationText).toBeTruthy()
|
|
})
|
|
|
|
test('C-05 点击活动查看详情', async ({ adminPage }) => {
|
|
const page = adminPage
|
|
|
|
// 等待表格加载完成
|
|
await expect(page.locator('.ant-table-tbody tr').first()).toBeVisible({ timeout: 10_000 })
|
|
|
|
// 点击"查看"按钮(已发布的活动)
|
|
const viewBtn = page.locator('text=查看').first()
|
|
if (await viewBtn.isVisible()) {
|
|
await viewBtn.click()
|
|
// 验证跳转到活动详情页
|
|
await page.waitForURL(/contests\/\d+/, { timeout: 10_000 })
|
|
}
|
|
})
|
|
})
|