kindergarten_java/reading-platform-frontend/tests/e2e/teacher/09-students.spec.ts

131 lines
4.1 KiB
TypeScript
Raw Normal View History

2026-03-17 10:38:51 +08:00
/**
* 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, '', '我的班级');
2026-03-17 10:38:51 +08:00
// 等待页面加载
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, '', '我的班级');
2026-03-17 10:38:51 +08:00
// 等待页面加载
await page.waitForTimeout(3000);
// 检查是否有学生数据
const hasStudentList = await page.locator('[class*="student"], table').count() > 0;
const hasEmpty = await page.getByText(/暂无数据 | 暂无学生/).count() > 0;
test.info().annotations.push({
type: 'info',
description: `学生数据:${hasStudentList ? '存在' : hasEmpty ? '空状态' : '未知'}`,
});
});
test('验证学生筛选功能', async ({ page }) => {
// 导航到学生管理页面
await clickSubMenu(page, '', '我的班级');
2026-03-17 10:38:51 +08:00
// 等待页面加载
await page.waitForTimeout(2000);
// 查找筛选器
const hasFilter = await page.locator('[class*="filter"], [class*="search"], .ant-input, .ant-select').count() > 0;
test.info().annotations.push({
type: 'info',
description: `筛选功能:${hasFilter ? '存在' : '不存在'}`,
});
// 查找班级筛选
const hasClassFilter = await page.getByText(/班级 | 全部班级/).count() > 0;
test.info().annotations.push({
type: 'info',
description: `班级筛选:${hasClassFilter ? '存在' : '不存在'}`,
});
});
test('验证学生详情查看', async ({ page }) => {
// 导航到学生管理页面
await clickSubMenu(page, '', '我的班级');
2026-03-17 10:38:51 +08:00
// 等待页面加载
await page.waitForTimeout(3000);
// 查找第一个学生记录
const firstStudent = page.locator('table tbody tr').first();
const hasStudent = await firstStudent.count() > 0;
if (hasStudent) {
// 查找查看按钮
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, '', '我的班级');
2026-03-17 10:38:51 +08:00
// 等待页面加载
await page.waitForTimeout(3000);
// 检查表格列头
const headers = page.locator('thead th');
const headerCount = await headers.count();
test.info().annotations.push({
type: 'info',
description: `表格列数:${headerCount}`,
});
// 检查是否有姓名列
const hasNameColumn = await page.getByText(/姓名 | 学生姓名/).count() > 0;
test.info().annotations.push({
type: 'info',
description: `姓名显示:${hasNameColumn ? '存在' : '不存在'}`,
});
});
test('截图保存学生管理状态', async ({ page }) => {
// 注意:教师端当前菜单没有独立的"学生管理"入口
// 学生信息通过"我的班级"进入后查看
// 暂时跳转到我的班级页面
await clickSubMenu(page, '', '我的班级');
2026-03-17 10:38:51 +08:00
// 等待页面完全加载
await page.waitForTimeout(3000);
// 截图
await page.screenshot({ path: 'test-results/teacher-students.png' });
test.info().annotations.push({
type: 'info',
description: '学生管理功能在"我的班级"页面内,截图已保存',
2026-03-17 10:38:51 +08:00
});
});
});