2026-03-17 10:38:51 +08:00
|
|
|
/**
|
|
|
|
|
* 教师端 E2E 测试 - 仪表盘
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { test, expect } from '@playwright/test';
|
|
|
|
|
import { loginAsTeacher } from './helpers';
|
|
|
|
|
import { TEACHER_CONFIG } from './fixtures';
|
|
|
|
|
|
|
|
|
|
test.describe('教师端仪表盘功能', () => {
|
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
|
|
|
await loginAsTeacher(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('验证仪表盘页面加载', async ({ page }) => {
|
|
|
|
|
// 验证页面标题
|
2026-03-26 12:02:20 +08:00
|
|
|
await expect(page).toHaveTitle(/少儿智慧阅读/);
|
2026-03-17 10:38:51 +08:00
|
|
|
|
|
|
|
|
// 验证教师端仪表盘标题
|
|
|
|
|
await expect(page.getByRole('heading', { name: /仪表盘|我的教学|教学概览/ })).toBeVisible({ timeout: 5000 });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('验证统计数据卡片显示', async ({ page }) => {
|
|
|
|
|
// 检查统计数据卡片(班级数、学生数、课程数等)
|
|
|
|
|
const statsCards = page.locator('.ant-statistic, [class*="statistic"], [class*="stats"]');
|
|
|
|
|
const statsCount = await statsCards.count();
|
|
|
|
|
|
|
|
|
|
test.info().annotations.push({
|
|
|
|
|
type: 'info',
|
|
|
|
|
description: `统计数据卡片数量:${statsCount}`,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(statsCount).toBeGreaterThan(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('验证今日课程显示', async ({ page }) => {
|
|
|
|
|
// 检查是否有今日课程列表
|
|
|
|
|
const todayLessons = page.locator('[class*="lesson"], [class*="course"], [class*="schedule"]');
|
|
|
|
|
const lessonCount = await todayLessons.count();
|
|
|
|
|
|
|
|
|
|
test.info().annotations.push({
|
|
|
|
|
type: 'info',
|
|
|
|
|
description: `今日课程数量:${lessonCount}`,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('验证推荐课程显示', async ({ page }) => {
|
|
|
|
|
// 检查是否有推荐课程
|
|
|
|
|
const recommendedCourses = page.locator('[class*="course-card"], [class*="recommend"]');
|
|
|
|
|
const courseCount = await recommendedCourses.count();
|
|
|
|
|
|
|
|
|
|
test.info().annotations.push({
|
|
|
|
|
type: 'info',
|
|
|
|
|
description: `推荐课程数量:${courseCount}`,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('验证侧边栏导航菜单', async ({ page }) => {
|
|
|
|
|
// 检查侧边栏菜单项
|
|
|
|
|
const menuItems = page.locator('.ant-menu-item, [class*="menu-item"], .ant-menu-submenu');
|
|
|
|
|
const menuCount = await menuItems.count();
|
|
|
|
|
|
|
|
|
|
test.info().annotations.push({
|
|
|
|
|
type: 'info',
|
|
|
|
|
description: `菜单项数量:${menuCount}`,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 验证核心菜单项存在
|
|
|
|
|
const expectedMenus = ['首页', '我的课表', '课程列表', '授课记录', '班级管理', '学生管理', '任务管理', '成长记录'];
|
|
|
|
|
for (const menu of expectedMenus) {
|
|
|
|
|
const menuExists = await page.getByText(menu).count() > 0;
|
|
|
|
|
test.info().annotations.push({
|
|
|
|
|
type: menuExists ? 'success' : 'warning',
|
|
|
|
|
description: `${menu}菜单:${menuExists ? '存在' : '不存在'}`,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('验证用户信息区域显示', async ({ page }) => {
|
|
|
|
|
// 检查右上角用户信息显示
|
|
|
|
|
const userInfo = page.locator('[class*="user"], [class*="profile"]');
|
|
|
|
|
const userExists = await userInfo.count() > 0;
|
|
|
|
|
|
|
|
|
|
test.info().annotations.push({
|
|
|
|
|
type: 'info',
|
|
|
|
|
description: `用户信息区域:${userExists ? '存在' : '不存在'}`,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('截图保存仪表盘状态', async ({ page }) => {
|
|
|
|
|
// 等待页面完全加载
|
|
|
|
|
await page.waitForTimeout(2000);
|
|
|
|
|
|
|
|
|
|
// 截图
|
|
|
|
|
await page.screenshot({ path: 'test-results/teacher-dashboard.png' });
|
|
|
|
|
test.info().annotations.push({
|
|
|
|
|
type: 'success',
|
|
|
|
|
description: '仪表盘截图已保存',
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|