/** * 超管端 E2E 测试 - 数据看板 */ import { test, expect } from '@playwright/test'; import { loginAsAdmin } from './helpers'; test.describe('数据看板', () => { test.beforeEach(async ({ page }) => { // 登录并进入仪表盘 await loginAsAdmin(page); }); test('验证统计卡片显示', async ({ page }) => { // 等待统计卡片加载 await page.waitForSelector('.ant-statistic, [class*="statistic"]', { timeout: 10000 }); // 验证租户数卡片 const tenantCard = page.getByText(/租户数|租户总数|机构数/).first(); await expect(tenantCard).toBeVisible(); // 验证课程包数卡片 const courseCard = page.getByText(/课程包数|课程总数/).first(); await expect(courseCard).toBeVisible(); // 验证月授课次数卡片 const lessonCard = page.getByText(/月授课|授课次数/).first(); await expect(lessonCard).toBeVisible(); // 验证学生总数卡片 const studentCard = page.getByText(/学生总数|学生数/).first(); await expect(studentCard).toBeVisible(); }); test('验证趋势图加载', async ({ page }) => { // 等待图表容器加载 const chartContainer = page.locator('[class*="trend"], [class*="chart"], canvas').first(); await expect(chartContainer).toBeVisible({ timeout: 10000 }); }); test('验证活跃租户 TOP5 列表', async ({ page }) => { // 查找活跃租户列表区域 const activeTenantsSection = page.getByText(/活跃租户|活跃机构|TOP5/); await expect(activeTenantsSection).toBeVisible({ timeout: 10000 }); // 验证列表中有数据行 const listItems = page.locator('[class*="list-item"], [class*="table-row"]').first(); await expect(listItems).toBeVisible(); }); test('验证热门课程包 TOP5 列表', async ({ page }) => { // 查找热门课程包列表区域 const popularCoursesSection = page.getByText(/热门课程|热门课程包|TOP5/); await expect(popularCoursesSection).toBeVisible({ timeout: 10000 }); // 验证列表中有数据行 const listItems = page.locator('[class*="list-item"], [class*="table-row"]').first(); await expect(listItems).toBeVisible(); }); test('验证快捷入口点击跳转 - 创建课程包', async ({ page }) => { // 查找创建课程包快捷入口 const createCourseLink = page.getByText(/创建课程包|新建课程/).first(); await expect(createCourseLink).toBeVisible(); // 点击并验证跳转 await createCourseLink.click(); await page.waitForURL(/\/admin\/courses\/create|\/admin\/courses\/new/); }); test('验证快捷入口点击跳转 - 管理租户', async ({ page }) => { // 查找管理租户快捷入口 const tenantLink = page.getByText(/管理租户|租户管理/).first(); await expect(tenantLink).toBeVisible(); // 点击并验证跳转 await tenantLink.click(); await page.waitForURL(/\/admin\/tenants/); }); test('验证快捷入口点击跳转 - 资源库', async ({ page }) => { // 查找资源库快捷入口 const resourceLink = page.getByText(/资源库|资源管理/).first(); await expect(resourceLink).toBeVisible(); // 点击并验证跳转 await resourceLink.click(); await page.waitForURL(/\/admin\/resources/); }); });