Web 端 (Playwright): - fixtures: test-data 工厂 + API Client (乐观锁 version) + 增强 auth fixture - pages: LoginPage, PatientListPage, PatientDetailPage, HealthDataPage, AppointmentPage - flows: 患者全流程, 体征数据链路, 预约排班链路, 随访管理链路, 告警处理链路 - smoke tests 迁移到 smoke/ 目录,import 路径更新 - playwright.config.ts 更新: globalSetup 环境检查, 60s timeout, video retain 小程序端 (Vitest + miniprogram-automator): - helpers: AutomatorClient, MpApiClient, MpAuthHelper, MpNavigator - flows: 患者健康数据查看, 体征数据录入, 积分签到兑换, 积分商城浏览 - vitest.config.ts + check-readiness.ts - vitest 4.1.5 依赖安装 Playwright 发现 15 个测试 (5 flow + 10 smoke),全部就绪
49 lines
2.0 KiB
TypeScript
49 lines
2.0 KiB
TypeScript
import { test, expect } from '../fixtures/auth.fixture';
|
|
|
|
test.describe('用户管理', () => {
|
|
test('用户列表页面加载并显示表格', async ({ page }) => {
|
|
await page.goto('/#/');
|
|
// 通过侧边栏导航到用户管理
|
|
await page.locator('text=用户管理').first().click();
|
|
await expect(page).toHaveURL(/#\/users/, { timeout: 10000 });
|
|
|
|
// 标题
|
|
await expect(page.locator('h4')).toContainText('用户管理');
|
|
// 新建用户按钮
|
|
await expect(page.locator('button:has-text("新建用户")')).toBeVisible();
|
|
// 搜索框
|
|
await expect(page.locator('input[placeholder*="搜索"]')).toBeVisible();
|
|
// 表格列头
|
|
await expect(page.locator('text=用户').first()).toBeVisible();
|
|
await expect(page.locator('text=状态').first()).toBeVisible();
|
|
});
|
|
|
|
test('新建用户弹窗表单验证', async ({ page }) => {
|
|
await page.goto('/#/');
|
|
await page.locator('text=用户管理').first().click();
|
|
await expect(page).toHaveURL(/#\/users/, { timeout: 10000 });
|
|
|
|
// 点击新建
|
|
await page.click('button:has-text("新建用户")');
|
|
// 弹窗出现
|
|
await expect(page.locator('.ant-modal')).toBeVisible();
|
|
// 直接提交应显示验证错误(点击 modal 内最后一个 button 即确认按钮)
|
|
const modalButtons = page.locator('.ant-modal .ant-modal-footer button');
|
|
await modalButtons.last().click();
|
|
// Ant Design 应显示验证错误(用户名 + 密码必填)
|
|
await expect(page.locator('.ant-form-item-explain-error')).toHaveCount(2);
|
|
// 关闭弹窗(点击第一个按钮即取消)
|
|
await modalButtons.first().click();
|
|
});
|
|
|
|
test('搜索框可输入', async ({ page }) => {
|
|
await page.goto('/#/');
|
|
await page.locator('text=用户管理').first().click();
|
|
await expect(page).toHaveURL(/#\/users/, { timeout: 10000 });
|
|
|
|
const searchInput = page.locator('input[placeholder*="搜索"]');
|
|
await searchInput.fill('admin');
|
|
await expect(searchInput).toHaveValue('admin');
|
|
});
|
|
});
|