新增 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>
80 lines
2.7 KiB
TypeScript
80 lines
2.7 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\/registrations/, { timeout: 10_000 })
|
||
})
|
||
|
||
test('R-01 报名列表页正常加载', async ({ adminPage }) => {
|
||
const page = adminPage
|
||
|
||
// 验证页面内容加载
|
||
await expect(page.locator('.ant-table, .registrations-page, .ant-card').first()).toBeVisible({ timeout: 10_000 })
|
||
})
|
||
|
||
test('R-02 搜索报名记录', async ({ adminPage }) => {
|
||
const page = adminPage
|
||
|
||
// 查找搜索输入框
|
||
const searchInput = page.locator('input[placeholder*="搜索"], input[placeholder*="姓名"], input[placeholder*="报名"]').first()
|
||
if (await searchInput.isVisible({ timeout: 5000 }).catch(() => false)) {
|
||
await searchInput.fill('张小明')
|
||
|
||
// 点击搜索按钮或按回车
|
||
const searchBtn = page.locator('button:has-text("搜索"), button[type="submit"]').first()
|
||
if (await searchBtn.isVisible()) {
|
||
await searchBtn.click()
|
||
} else {
|
||
await searchInput.press('Enter')
|
||
}
|
||
|
||
await page.waitForTimeout(1000)
|
||
}
|
||
})
|
||
|
||
test('R-03 审核状态筛选', async ({ adminPage }) => {
|
||
const page = adminPage
|
||
|
||
// 查找状态筛选下拉框
|
||
const statusSelect = page.locator('.ant-select').filter({ hasText: '全部' }).first()
|
||
if (await statusSelect.isVisible({ timeout: 5000 }).catch(() => false)) {
|
||
await statusSelect.click()
|
||
await page.waitForTimeout(500)
|
||
|
||
// 选择"待审核"选项
|
||
const option = page.locator('.ant-select-item-option').filter({ hasText: '待审核' }).first()
|
||
if (await option.isVisible()) {
|
||
await option.click()
|
||
await page.waitForTimeout(1000)
|
||
}
|
||
}
|
||
})
|
||
|
||
test('R-04 查看报名详情', async ({ adminPage }) => {
|
||
const page = adminPage
|
||
|
||
// 等待表格加载
|
||
await page.waitForTimeout(2000)
|
||
|
||
// 报名详情页操作列有"详情"按钮(页面快照显示为 button "详情")
|
||
const detailBtn = page.locator('button:has-text("详情")').first()
|
||
if (await detailBtn.isVisible({ timeout: 5000 }).catch(() => false)) {
|
||
await detailBtn.click()
|
||
|
||
// 验证详情弹窗/抽屉出现
|
||
await expect(page.locator('.ant-drawer, .ant-modal').first()).toBeVisible({ timeout: 5000 })
|
||
}
|
||
})
|
||
})
|