前后端目录重命名: - reading-platform-java/ → lesingle-edu-reading-platform-backend/ - reading-platform-frontend/ → lesingle-edu-reading-platform-frontend/ 更新相关文件: - 所有 shell 脚本中的目录引用 - pom.xml 和 application.yml 中的项目名称 - package.json 中的项目名称 - .claude/CLAUDE.md 中的路径引用 - README 文档中的路径引用
113 lines
3.5 KiB
TypeScript
113 lines
3.5 KiB
TypeScript
/**
|
||
* 教师端 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 hasClassList = await page.locator('[class*="class"], [class*="card"], table').count() > 0;
|
||
const hasEmpty = await page.getByText(/暂无数据 | 暂无班级/).count() > 0;
|
||
|
||
test.info().annotations.push({
|
||
type: 'info',
|
||
description: `班级数据:${hasClassList ? '存在' : hasEmpty ? '空状态' : '未知'}`,
|
||
});
|
||
});
|
||
|
||
test('验证班级学生列表', async ({ page }) => {
|
||
// 导航到班级管理页面
|
||
await clickSubMenu(page, '', '我的班级');
|
||
|
||
// 等待页面加载
|
||
await page.waitForTimeout(2000);
|
||
|
||
// 查找第一个班级并点击进入
|
||
const firstClass = page.locator('[class*="class-card"], [class*="class-item"], table tbody tr').first();
|
||
const hasClass = await firstClass.count() > 0;
|
||
|
||
if (hasClass) {
|
||
// 尝试点击进入班级详情
|
||
await firstClass.click();
|
||
await page.waitForTimeout(2000);
|
||
|
||
// 验证是否进入班级详情页
|
||
const hasStudentList = await page.locator('[class*="student"], table').count() > 0;
|
||
test.info().annotations.push({
|
||
type: 'info',
|
||
description: `学生列表:${hasStudentList ? '存在' : '不存在'}`,
|
||
});
|
||
} else {
|
||
test.info().annotations.push({
|
||
type: 'warning',
|
||
description: '没有找到班级数据',
|
||
});
|
||
}
|
||
});
|
||
|
||
test('验证班级教师列表', async ({ page }) => {
|
||
// 导航到班级管理页面
|
||
await clickSubMenu(page, '', '我的班级');
|
||
|
||
// 等待页面加载
|
||
await page.waitForTimeout(2000);
|
||
|
||
// 查找第一个班级并查看教师
|
||
const firstClass = page.locator('[class*="class-card"], [class*="class-item"], table tbody tr').first();
|
||
const hasClass = await firstClass.count() > 0;
|
||
|
||
if (hasClass) {
|
||
// 查找查看教师按钮
|
||
const viewTeachersBtn = page.getByRole('button', { name: /教师 | 老师/ }).first();
|
||
const hasBtn = await viewTeachersBtn.count() > 0;
|
||
|
||
test.info().annotations.push({
|
||
type: 'info',
|
||
description: `查看教师按钮:${hasBtn ? '存在' : '不存在'}`,
|
||
});
|
||
}
|
||
});
|
||
|
||
test('截图保存班级列表状态', async ({ page }) => {
|
||
// 导航到班级管理页面(教师端菜单为"我的班级")
|
||
await clickSubMenu(page, '', '我的班级');
|
||
|
||
// 等待页面完全加载
|
||
await page.waitForTimeout(3000);
|
||
|
||
// 截图
|
||
await page.screenshot({ path: 'test-results/teacher-classes.png' });
|
||
test.info().annotations.push({
|
||
type: 'success',
|
||
description: '班级列表截图已保存',
|
||
});
|
||
});
|
||
});
|