kindergarten_java/lesingle-edu-reading-platform-frontend/tests/e2e/teacher/98-comprehensive.spec.ts

147 lines
4.8 KiB
TypeScript
Raw Permalink Normal View History

2026-03-17 10:38:51 +08:00
/**
* E2E -
*/
import { test, expect } from '@playwright/test';
import { loginAsTeacher, clickSubMenu } from './helpers';
test.describe('教师端综合流程测试', () => {
test.beforeEach(async ({ page }) => {
await loginAsTeacher(page);
});
test('完整教学流程测试', async ({ page }) => {
test.info().annotations.push({
type: 'feature',
description: '测试完整教学流程:课表 → 课程 → 授课 → 反馈',
});
// 1. 访问仪表盘
await page.goto('/teacher/dashboard');
await page.waitForTimeout(2000);
test.info().annotations.push({
type: 'success',
description: '步骤 1: 仪表盘页面加载成功',
});
// 2. 访问我的课表
await clickSubMenu(page, '教学管理', '我的课表');
await page.waitForTimeout(2000);
test.info().annotations.push({
type: 'success',
description: '步骤 2: 我的课表页面加载成功',
});
// 3. 访问课程列表
await clickSubMenu(page, '教学管理', '课程列表');
await page.waitForTimeout(2000);
test.info().annotations.push({
type: 'success',
description: '步骤 3: 课程列表页面加载成功',
});
// 4. 访问授课记录
await clickSubMenu(page, '教学管理', '授课记录');
await page.waitForTimeout(2000);
test.info().annotations.push({
type: 'success',
description: '步骤 4: 授课记录页面加载成功',
});
// 5. 访问班级管理
await clickSubMenu(page, '班级管理', '班级列表');
await page.waitForTimeout(2000);
test.info().annotations.push({
type: 'success',
description: '步骤 5: 班级管理页面加载成功',
});
// 6. 访问学生管理
await clickSubMenu(page, '学生管理', '学生列表');
await page.waitForTimeout(2000);
test.info().annotations.push({
type: 'success',
description: '步骤 6: 学生管理页面加载成功',
});
// 7. 访问任务管理
await clickSubMenu(page, '任务管理', '任务列表');
await page.waitForTimeout(2000);
test.info().annotations.push({
type: 'success',
description: '步骤 7: 任务管理页面加载成功',
});
// 8. 访问成长记录
await clickSubMenu(page, '成长记录', '成长记录');
await page.waitForTimeout(2000);
test.info().annotations.push({
type: 'success',
description: '步骤 8: 成长记录页面加载成功',
});
test.info().annotations.push({
type: 'success',
description: '完整教学流程测试完成!',
});
});
test('验证所有菜单导航', async ({ page }) => {
const menus = [
{ parent: '首页', child: null, path: '/teacher/dashboard' },
{ parent: '教学管理', child: '我的课表', path: '/teacher/schedule' },
{ parent: '教学管理', child: '课程列表', path: '/teacher/courses' },
{ parent: '教学管理', child: '授课记录', path: '/teacher/lessons' },
{ parent: '班级管理', child: '班级列表', path: '/teacher/classes' },
{ parent: '学生管理', child: '学生列表', path: '/teacher/students' },
{ parent: '任务管理', child: '任务列表', path: '/teacher/tasks' },
{ parent: '成长记录', child: '成长记录', path: '/teacher/growth-records' },
];
for (const menu of menus) {
if (menu.path) {
await page.goto(menu.path);
await page.waitForTimeout(1000);
test.info().annotations.push({
type: 'success',
description: `导航成功:${menu.parent} - ${menu.child || '首页'} (${menu.path})`,
});
} else if (menu.parent && menu.child) {
await clickSubMenu(page, menu.parent, menu.child);
await page.waitForTimeout(1000);
test.info().annotations.push({
type: 'success',
description: `导航成功:${menu.parent} - ${menu.child}`,
});
}
}
test.info().annotations.push({
type: 'success',
description: '所有菜单导航验证完成!',
});
});
test('验证页面响应式布局', async ({ page }) => {
// 测试不同屏幕尺寸
const sizes = [
{ width: 1920, height: 1080 },
{ width: 1366, height: 768 },
{ width: 1024, height: 768 },
];
for (const size of sizes) {
await page.setViewportSize({ width: size.width, height: size.height });
await page.goto('/teacher/dashboard');
await page.waitForTimeout(1000);
// 检查页面是否正常显示
const hasContent = await page.locator('.ant-layout-content').count() > 0;
test.info().annotations.push({
type: 'info',
description: `分辨率 ${size.width}x${size.height}: ${hasContent ? '正常' : '异常'}`,
});
}
});
});