合并同事的远程更新: - 多地点登录支持功能 - 资源库管理优化 - 数据看板修复 - 视频预览功能 - KidsMode增强 两层结构重构完成: - 数据库迁移 V28(course_collection、course_collection_package) - 后端实体、Service、Controller实现 - 前端API类型和组件重构 - 修复冲突文件:CHANGELOG.md、components.d.ts、TeacherLessonController.java Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
144 lines
4.6 KiB
TypeScript
144 lines
4.6 KiB
TypeScript
/**
|
||
* 教师端 E2E 测试 - 任务管理
|
||
*/
|
||
|
||
import { test, expect } from '@playwright/test';
|
||
import { loginAsTeacher, clickSubMenu, waitForTable, waitForSuccess } 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 hasTaskList = await page.locator('[class*="task"], table').count() > 0;
|
||
const hasEmpty = await page.getByText(/暂无数据 | 暂无任务/).count() > 0;
|
||
|
||
test.info().annotations.push({
|
||
type: 'info',
|
||
description: `任务数据:${hasTaskList ? '存在' : hasEmpty ? '空状态' : '未知'}`,
|
||
});
|
||
});
|
||
|
||
test('验证创建任务功能', async ({ page }) => {
|
||
// 导航到任务管理页面
|
||
await clickSubMenu(page, '', '阅读任务');
|
||
|
||
// 等待页面加载
|
||
await page.waitForTimeout(2000);
|
||
|
||
// 查找创建按钮
|
||
const createBtn = page.getByRole('button', { name: /创建 | 新建 | 添加/ });
|
||
const hasCreateBtn = await createBtn.count() > 0;
|
||
|
||
test.info().annotations.push({
|
||
type: 'info',
|
||
description: `创建按钮:${hasCreateBtn ? '存在' : '不存在'}`,
|
||
});
|
||
|
||
if (hasCreateBtn) {
|
||
// 点击创建按钮
|
||
await createBtn.click();
|
||
await page.waitForTimeout(1000);
|
||
|
||
// 验证弹窗是否打开
|
||
const hasModal = await page.locator('.ant-modal, [class*="modal"]').count() > 0;
|
||
test.info().annotations.push({
|
||
type: 'info',
|
||
description: `创建弹窗:${hasModal ? '打开' : '未打开'}`,
|
||
});
|
||
|
||
if (hasModal) {
|
||
// 验证表单字段
|
||
const hasTitleInput = await page.locator('[class*="title"] input, input[placeholder*="标题"]').count() > 0;
|
||
const hasTypeSelect = await page.locator('[class*="type"] .ant-select, [class*="taskType"]').count() > 0;
|
||
|
||
test.info().annotations.push({
|
||
type: 'info',
|
||
description: `标题输入框:${hasTitleInput ? '存在' : '不存在'}`,
|
||
});
|
||
test.info().annotations.push({
|
||
type: 'info',
|
||
description: `任务类型选择:${hasTypeSelect ? '存在' : '不存在'}`,
|
||
});
|
||
}
|
||
}
|
||
});
|
||
|
||
test('验证任务筛选功能', async ({ page }) => {
|
||
// 导航到任务管理页面
|
||
await clickSubMenu(page, '', '阅读任务');
|
||
|
||
// 等待页面加载
|
||
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 hasStatusFilter = await page.getByText(/状态 | 全部 | 进行中 | 已完成/).count() > 0;
|
||
test.info().annotations.push({
|
||
type: 'info',
|
||
description: `状态筛选:${hasStatusFilter ? '存在' : '不存在'}`,
|
||
});
|
||
});
|
||
|
||
test('验证任务操作按钮', async ({ page }) => {
|
||
// 导航到任务管理页面
|
||
await clickSubMenu(page, '', '阅读任务');
|
||
|
||
// 等待页面加载
|
||
await page.waitForTimeout(3000);
|
||
|
||
// 查找操作按钮(编辑、删除等)
|
||
const actionBtns = page.locator('button:has-text("编辑"), button:has-text("删除"), button:has-text("详情")');
|
||
const hasActionBtns = await actionBtns.count() > 0;
|
||
|
||
test.info().annotations.push({
|
||
type: 'info',
|
||
description: `操作按钮:${hasActionBtns ? '存在' : '不存在'}`,
|
||
});
|
||
});
|
||
|
||
test('截图保存任务管理状态', async ({ page }) => {
|
||
// 导航到任务管理页面(教师端菜单为"阅读任务")
|
||
await clickSubMenu(page, '', '阅读任务');
|
||
|
||
// 等待页面完全加载
|
||
await page.waitForTimeout(3000);
|
||
|
||
// 截图
|
||
await page.screenshot({ path: 'test-results/teacher-tasks.png' });
|
||
test.info().annotations.push({
|
||
type: 'success',
|
||
description: '任务管理截图已保存',
|
||
});
|
||
});
|
||
});
|