kindergarten_java/lesingle-edu-reading-platform-frontend/tests/e2e/teacher/06-tasks.spec.ts
En 40589f59e7 chore: 重命名项目目录
前后端目录重命名:
- 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 文档中的路径引用
2026-03-26 11:31:47 +08:00

144 lines
4.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 教师端 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: '任务管理截图已保存',
});
});
});