/** * 教师端 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 hasRecordList = await page.locator('[class*="growth"], [class*="record"], table').count() > 0; const hasEmpty = await page.getByText(/暂无数据 | 暂无记录/).count() > 0; test.info().annotations.push({ type: 'info', description: `成长记录数据:${hasRecordList ? '存在' : 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 hasStudentSelect = await page.locator('[class*="student"] .ant-select, [placeholder*="学生"]').count() > 0; const hasTypeSelect = await page.locator('[class*="type"] .ant-select, [placeholder*="类型"]').count() > 0; test.info().annotations.push({ type: 'info', description: `学生选择:${hasStudentSelect ? '存在' : '不存在'}`, }); 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 ? '存在' : '不存在'}`, }); }); 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-growth-records.png' }); test.info().annotations.push({ type: 'success', description: '成长记录截图已保存', }); }); });