library-picturebook-activity/lesingle-creation-frontend/e2e/admin/registrations.spec.ts
En 98e9ad1d28 feat(前端): 测试环境登录框支持自动填充测试账号
通过 VITE_AUTO_FILL_TEST 环境变量控制,在 .env.test 中启用,
使测试环境构建后登录框也能自动填充测试账号,方便测试人员使用。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-11 17:03:22 +08:00

80 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 })
}
})
})