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

78 lines
2.5 KiB
TypeScript
Raw Permalink 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\/works/, { timeout: 10_000 })
})
test('W-01 作品列表页正常加载', async ({ adminPage }) => {
const page = adminPage
// 验证页面内容加载
await expect(page.locator('.ant-table, .works-page, .ant-card').first()).toBeVisible({ timeout: 10_000 })
})
test('W-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('W-03 作品状态筛选', async ({ adminPage }) => {
const page = adminPage
// 查找状态筛选
const statusSelect = page.locator('.ant-select').first()
if (await statusSelect.isVisible({ timeout: 5000 }).catch(() => false)) {
await statusSelect.click()
await page.waitForTimeout(500)
// 选择一个状态选项
const option = page.locator('.ant-select-item-option').first()
if (await option.isVisible()) {
await option.click()
await page.waitForTimeout(1000)
}
}
})
test('W-04 作品表格操作按钮', async ({ adminPage }) => {
const page = adminPage
// 等待页面加载
await page.waitForTimeout(2000)
// 作品详情页操作列有"分配评委"按钮(页面快照显示为 button "分配评委"
const actionBtn = page.locator('button:has-text("分配评委")').first()
if (await actionBtn.isVisible({ timeout: 5000 }).catch(() => false)) {
// 验证按钮可点击
expect(await actionBtn.isEnabled()).toBe(true)
}
})
})