library-picturebook-activity/lesingle-creation-frontend/e2e/admin/reviews.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

62 lines
2.3 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\/reviews/, { timeout: 10_000 })
})
test('RV-01 评审规则列表正常加载', async ({ adminPage }) => {
const page = adminPage
// 验证页面内容加载
await expect(page.locator('.ant-table, .ant-card, .reviews-page').first()).toBeVisible({ timeout: 10_000 })
})
test('RV-02 新建评审规则弹窗', async ({ adminPage }) => {
const page = adminPage
// 查找新建/创建按钮
const createBtn = page.locator('button:has-text("新建"), button:has-text("创建"), button:has-text("添加")').first()
if (await createBtn.isVisible({ timeout: 5000 }).catch(() => false)) {
await createBtn.click()
// 验证弹窗/抽屉出现
await expect(page.locator('.ant-modal, .ant-drawer').first()).toBeVisible({ timeout: 5000 })
// 验证表单字段
const nameInput = page.locator('.ant-modal input, .ant-drawer input').first()
if (await nameInput.isVisible()) {
await nameInput.fill('E2E测试评审规则')
await expect(nameInput).toHaveValue('E2E测试评审规则')
}
}
})
test('RV-03 评委管理页面', async ({ adminPage }) => {
const page = adminPage
// 导航到评委管理
const submenu = page.locator('.ant-menu-submenu').filter({ hasText: '活动管理' }).first()
// 先确认子菜单已展开,再找评委管理
const judgeItem = submenu.locator('.ant-menu-item').filter({ hasText: '评委管理' }).first()
if (await judgeItem.isVisible({ timeout: 3000 }).catch(() => false)) {
await judgeItem.click()
await page.waitForURL(/contests\/judges/, { timeout: 10_000 })
// 验证页面加载
await expect(page.locator('.ant-table, .ant-card').first()).toBeVisible({ timeout: 10_000 })
}
})
})