kindergarten_java/reading-platform-frontend/tests/e2e/school/02-dashboard.spec.ts

101 lines
3.3 KiB
TypeScript
Raw Normal View History

/**
* E2E -
*/
import { test, expect } from '@playwright/test';
import { loginAsSchool } from './helpers';
import { SCHOOL_CONFIG } from './fixtures';
test.describe('学校端仪表盘功能', () => {
test.beforeEach(async ({ page }) => {
await loginAsSchool(page);
});
test('验证仪表盘页面加载', async ({ page }) => {
// 验证页面标题
await expect(page).toHaveTitle(/幼儿阅读教学服务平台/);
// 验证学校端仪表盘标题 - 校园阅读管理中心
await expect(page.getByRole('heading', { name: '校园阅读管理中心' })).toBeVisible({ timeout: 5000 });
});
test('验证统计数据卡片显示', async ({ page }) => {
// 检查统计数据卡片(班级数、幼儿数、教师数、家长数等)
const statsCards = page.locator('.ant-statistic, [class*="statistic"], [class*="stats"]');
const statsCount = await statsCards.count();
test.info().annotations.push({
type: 'info',
description: `统计数据卡片数量:${statsCount}`,
});
expect(statsCount).toBeGreaterThan(0);
});
test('验证快捷操作入口', async ({ page }) => {
// 检查是否有快捷操作按钮
const quickActions = page.locator('button, [class*="action"], [class*="shortcut"]');
const actionCount = await quickActions.count();
test.info().annotations.push({
type: 'info',
description: `快捷操作数量:${actionCount}`,
});
});
test('验证最近活动或通知', async ({ page }) => {
// 检查是否有最近活动或通知列表
const activities = page.locator('[class*="activity"], [class*="notice"], [class*="notification"]');
const activityCount = await activities.count();
test.info().annotations.push({
type: 'info',
description: `最近活动/通知数量:${activityCount}`,
});
});
test('验证侧边栏导航菜单', async ({ page }) => {
// 检查侧边栏菜单项
const menuItems = page.locator('.ant-menu-item, [class*="menu-item"], .ant-menu-submenu');
const menuCount = await menuItems.count();
test.info().annotations.push({
type: 'info',
description: `菜单项数量:${menuCount}`,
});
// 验证核心菜单项存在
const expectedMenus = ['课程中心', '班级管理', '幼儿管理', '教师管理', '家长管理'];
for (const menu of expectedMenus) {
const menuExists = await page.getByText(menu).count() > 0;
test.info().annotations.push({
type: menuExists ? 'success' : 'warning',
description: `${menu}菜单:${menuExists ? '存在' : '不存在'}`,
});
}
});
test('验证用户信息区域显示', async ({ page }) => {
// 检查右上角用户信息显示
const userInfo = page.locator('[class*="user"], [class*="profile"]');
const userExists = await userInfo.count() > 0;
test.info().annotations.push({
type: 'info',
description: `用户信息区域:${userExists ? '存在' : '不存在'}`,
});
});
test('截图保存仪表盘状态', async ({ page }) => {
// 等待页面完全加载
await page.waitForTimeout(2000);
// 截图
await page.screenshot({ path: 'test-results/school-dashboard.png' });
test.info().annotations.push({
type: 'success',
description: '仪表盘截图已保存',
});
});
});