/** * 学校端 E2E 测试 - 设置模块功能 */ import { test, expect } from '@playwright/test'; import { loginAsSchool, clickSubMenu } from './helpers'; import { SCHOOL_CONFIG } from './fixtures'; test.describe('学校端设置功能', () => { test.beforeEach(async ({ page }) => { await loginAsSchool(page); }); test('测试 1: 访问设置页面', async ({ page }) => { // 1. 点击系统管理 → 系统设置 await clickSubMenu(page, '系统管理', '系统设置'); await page.waitForURL('**/school/settings*', { timeout: 10000 }); await page.waitForTimeout(1000); // 2. 验证页面标题 await expect(page.locator('text=设置').or(page.locator('text=系统设置')).first()).toBeVisible({ timeout: 5000 }); // 3. 验证设置项加载 const settingsItems = page.locator('.ant-form-item, [class*="setting"]'); const settingsCount = await settingsItems.count(); test.info().annotations.push({ type: 'info', description: `设置项数量:${settingsCount}`, }); // 截图 await page.screenshot({ path: 'test-results/school-settings.png' }); }); test('测试 2: 查看租户信息', async ({ page }) => { // 1. 进入设置页面 await clickSubMenu(page, '系统管理', '系统设置'); await page.waitForURL('**/school/settings*', { timeout: 10000 }); await page.waitForTimeout(1000); // 2. 查找租户信息区域 const tenantInfo = page.locator('text=租户信息').or(page.locator('text=幼儿园信息')).or(page.locator('[class*="tenant"]')); const infoExists = await tenantInfo.count() > 0; test.info().annotations.push({ type: 'info', description: `租户信息:${infoExists ? '存在' : '不存在'}`, }); }); test('测试 3: 编辑基本信息', async ({ page }) => { test.slow(); // 1. 进入设置页面 await clickSubMenu(page, '系统管理', '系统设置'); await page.waitForURL('**/school/settings*', { timeout: 10000 }); await page.waitForTimeout(1000); // 2. 查找编辑按钮 const editBtn = page.locator('button:has-text("编辑")').first(); if (await editBtn.count() > 0) { await editBtn.click(); await page.waitForTimeout(1000); // 3. 验证表单显示 await expect(page.locator('.ant-form')).toBeVisible({ timeout: 5000 }); // 4. 保存修改 const saveBtn = page.locator('button:has-text("保存")').or(page.locator('button:has-text("确定")')); if (await saveBtn.count() > 0) { await saveBtn.first().click(); await page.waitForTimeout(2000); const successMsg = await page.locator('.ant-message-success').count() > 0; test.info().annotations.push({ type: successMsg ? 'success' : 'info', description: `编辑设置:${successMsg ? '成功' : '完成'}`, }); } } else { test.info().annotations.push({ type: 'warning', description: '未找到编辑按钮', }); } }); test('测试 4: 修改密码', async ({ page }) => { test.slow(); // 1. 进入设置页面 await clickSubMenu(page, '系统管理', '系统设置'); await page.waitForURL('**/school/settings*', { timeout: 10000 }); await page.waitForTimeout(1000); // 2. 查找修改密码入口 const passwordTab = page.locator('text=修改密码').or(page.locator('[role="tab"]:has-text("密码")')); if (await passwordTab.count() > 0) { await passwordTab.first().click(); await page.waitForTimeout(500); // 3. 验证密码表单显示 await expect(page.locator('.ant-form')).toBeVisible({ timeout: 5000 }); test.info().annotations.push({ type: 'success', description: '修改密码功能:可用', }); } else { test.info().annotations.push({ type: 'warning', description: '未找到修改密码入口', }); } }); test('测试 5: 查看套餐信息', async ({ page }) => { // 1. 进入设置页面 await clickSubMenu(page, '系统管理', '系统设置'); await page.waitForURL('**/school/settings*', { timeout: 10000 }); await page.waitForTimeout(1000); // 2. 查找套餐信息 const packageInfo = page.locator('text=套餐').or(page.locator('text=版本')).or(page.locator('[class*="package"]')); const packageExists = await packageInfo.count() > 0; test.info().annotations.push({ type: 'info', description: `套餐信息:${packageExists ? '存在' : '不存在'}`, }); }); test('测试 6: 查看有效期', async ({ page }) => { // 1. 进入设置页面 await clickSubMenu(page, '系统管理', '系统设置'); await page.waitForURL('**/school/settings*', { timeout: 10000 }); await page.waitForTimeout(1000); // 2. 查找有效期信息 const expiryInfo = page.locator('text=有效期').or(page.locator('text=到期')).or(page.locator('text=截止')); const expiryExists = await expiryInfo.count() > 0; test.info().annotations.push({ type: 'info', description: `有效期信息:${expiryExists ? '存在' : '不存在'}`, }); }); });