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