- E2E: 用 addInitScript 替代 goto+evaluate 注入 localStorage, 解决 Zustand store 初始化时序问题 (10/10 通过) - E2E: 修复 Modal 按钮选择器 (OK/Cancel 替代中文) - E2E: Playwright 配置对齐端口 5174 - 集成测试: 新增 workflow_tests 模块 (4 个测试)
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
import { test, expect } from './auth.fixture';
|
|
|
|
test.describe('用户管理', () => {
|
|
test('用户列表页面加载并显示表格', async ({ page }) => {
|
|
await page.goto('/#/users');
|
|
// 标题
|
|
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('/#/users');
|
|
// 点击新建
|
|
await page.click('button:has-text("新建用户")');
|
|
// 弹窗出现
|
|
await expect(page.locator('.ant-modal')).toBeVisible();
|
|
// 直接提交应显示验证错误
|
|
await page.click('.ant-modal button:has-text("OK")');
|
|
// Ant Design 应显示验证错误(用户名 + 密码必填)
|
|
await expect(page.locator('.ant-form-item-explain-error')).toHaveCount(2);
|
|
// 关闭弹窗
|
|
await page.locator('.ant-modal button:has-text("Cancel")').click();
|
|
});
|
|
|
|
test('搜索框可输入', async ({ page }) => {
|
|
await page.goto('/#/users');
|
|
const searchInput = page.locator('input[placeholder*="搜索"]');
|
|
await searchInput.fill('admin');
|
|
await expect(searchInput).toHaveValue('admin');
|
|
});
|
|
});
|