/** * 教师端 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 hasSchedule = await page.locator('[class*="schedule"], [class*="timetable"], table').count() > 0; const hasEmpty = await page.getByText(/暂无数据 | 暂无排课 | 空/).count() > 0; test.info().annotations.push({ type: 'info', description: `课表数据:${hasSchedule ? '存在' : 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"], [class*="dialog"]').count() > 0; test.info().annotations.push({ type: 'info', description: `创建弹窗:${hasModal ? '打开' : '未打开'}`, }); } }); test('验证课表视图切换', async ({ page }) => { // 导航到课表页面 await clickSubMenu(page, '教学管理', '我的课表'); // 等待页面加载 await page.waitForTimeout(2000); // 查找视图切换按钮(周/月) const viewSwitcher = page.locator('[class*="switch"], [class*="view"], .ant-radio-group'); const hasViewSwitcher = await viewSwitcher.count() > 0; test.info().annotations.push({ type: 'info', description: `视图切换:${hasViewSwitcher ? '存在' : '不存在'}`, }); }); test('截图保存课表状态', async ({ page }) => { // 导航到课表页面 await clickSubMenu(page, '教学管理', '我的课表'); // 等待页面完全加载 await page.waitForTimeout(3000); // 截图 await page.screenshot({ path: 'test-results/teacher-schedule.png' }); test.info().annotations.push({ type: 'success', description: '课表页面截图已保存', }); }); });