/** * 教师端 E2E 测试 - 课程反馈 */ import { test, expect } from '@playwright/test'; import { loginAsTeacher, clickSubMenu, waitForTable } from './helpers'; test.describe('教师端课程反馈功能', () => { test.beforeEach(async ({ page }) => { await loginAsTeacher(page); }); test('验证课程反馈列表页面加载', async ({ page }) => { // 导航到课程反馈页面 await clickSubMenu(page, '教学管理', '课程反馈'); // 等待页面加载 await page.waitForTimeout(2000); // 验证页面标题 const hasTitle = await page.getByText(/反馈 | 课程反馈 | 教学反馈/).count() > 0; test.info().annotations.push({ type: hasTitle ? 'success' : 'warning', description: `课程反馈标题:${hasTitle ? '存在' : '不存在'}`, }); }); test('验证课程反馈数据加载', async ({ page }) => { // 导航到课程反馈页面 await clickSubMenu(page, '教学管理', '课程反馈'); // 等待页面加载 await page.waitForTimeout(3000); // 检查是否有反馈数据 const hasFeedbackList = await page.locator('[class*="feedback"], table').count() > 0; const hasEmpty = await page.getByText(/暂无数据 | 暂无反馈/).count() > 0; test.info().annotations.push({ type: 'info', description: `课程反馈数据:${hasFeedbackList ? '存在' : hasEmpty ? '空状态' : '未知'}`, }); }); test('验证反馈统计数据显示', async ({ page }) => { // 导航到课程反馈页面 await clickSubMenu(page, '教学管理', '课程反馈'); // 等待页面加载 await page.waitForTimeout(2000); // 查找统计数据卡片 const statsCards = page.locator('[class*="statistic"], [class*="stats"], [class*="chart"]'); const hasStats = await statsCards.count() > 0; test.info().annotations.push({ type: 'info', description: `反馈统计:${hasStats ? '存在' : '不存在'}`, }); }); test('验证反馈评分显示', async ({ page }) => { // 导航到课程反馈页面 await clickSubMenu(page, '教学管理', '课程反馈'); // 等待页面加载 await page.waitForTimeout(3000); // 查找第一个反馈记录 const firstFeedback = page.locator('table tbody tr, [class*="feedback-item"]').first(); const hasFeedback = await firstFeedback.count() > 0; if (hasFeedback) { // 查找评分显示 const hasRating = await page.locator('[class*="rating"], [class*="score"], .ant-rate').count() > 0; test.info().annotations.push({ type: 'info', description: `评分显示:${hasRating ? '存在' : '不存在'}`, }); } }); test('验证反馈详情查看', async ({ page }) => { // 导航到课程反馈页面 await clickSubMenu(page, '教学管理', '课程反馈'); // 等待页面加载 await page.waitForTimeout(2000); // 查找操作按钮 const viewBtn = page.getByRole('button', { name: /查看 | 详情/ }).first(); const hasViewBtn = await viewBtn.count() > 0; test.info().annotations.push({ type: 'info', description: `查看详情按钮:${hasViewBtn ? '存在' : '不存在'}`, }); }); test('截图保存课程反馈状态', async ({ page }) => { // 导航到课程反馈页面 await clickSubMenu(page, '教学管理', '课程反馈'); // 等待页面完全加载 await page.waitForTimeout(3000); // 截图 await page.screenshot({ path: 'test-results/teacher-feedbacks.png' }); test.info().annotations.push({ type: 'success', description: '课程反馈截图已保存', }); }); });