2 changed files with 85 additions and 0 deletions
@ -0,0 +1,21 @@ |
|||||
|
# Playwright MCP 测试 |
||||
|
|
||||
|
本测试套件使用 Playwright MCP 工具进行端到端测试。 |
||||
|
|
||||
|
## 前置条件 |
||||
|
|
||||
|
1. 启动后端服务: `cd backend && go run main.go` |
||||
|
2. 启动前端开发服务器: `cd frontend/react-shadcn/pc && npm run dev` |
||||
|
3. 确保 MCP Playwright 工具已配置 |
||||
|
|
||||
|
## 测试场景 |
||||
|
|
||||
|
- 登录/登出流程 |
||||
|
- 仪表板页面验证 |
||||
|
- 用户管理 CRUD |
||||
|
- 设置页面验证 |
||||
|
- 导航和路由保护 |
||||
|
|
||||
|
## 运行测试 |
||||
|
|
||||
|
通过 Claude Code 的 MCP Playwright 工具手动执行测试步骤。 |
||||
@ -0,0 +1,64 @@ |
|||||
|
export const TEST_CONFIG = { |
||||
|
// 测试环境配置
|
||||
|
baseURL: 'http://localhost:5173', // Vite 默认开发服务器
|
||||
|
apiURL: 'http://localhost:8888/api/v1', |
||||
|
|
||||
|
// 测试用户凭证
|
||||
|
testUser: { |
||||
|
email: 'admin@example.com', |
||||
|
password: 'password123', |
||||
|
}, |
||||
|
|
||||
|
// 测试超时配置
|
||||
|
timeouts: { |
||||
|
navigation: 10000, |
||||
|
element: 5000, |
||||
|
api: 5000, |
||||
|
}, |
||||
|
}; |
||||
|
|
||||
|
// 页面路由
|
||||
|
export const ROUTES = { |
||||
|
login: '/login', |
||||
|
dashboard: '/dashboard', |
||||
|
users: '/users', |
||||
|
settings: '/settings', |
||||
|
}; |
||||
|
|
||||
|
// 选择器定义
|
||||
|
export const SELECTORS = { |
||||
|
login: { |
||||
|
emailInput: 'input[type="email"]', |
||||
|
passwordInput: 'input[type="password"]', |
||||
|
submitButton: 'button[type="submit"]', |
||||
|
errorMessage: '.text-red-400', |
||||
|
}, |
||||
|
sidebar: { |
||||
|
dashboardLink: 'a[href="/dashboard"]', |
||||
|
usersLink: 'a[href="/users"]', |
||||
|
settingsLink: 'a[href="/settings"]', |
||||
|
logoutButton: 'button[title="退出登录"]', |
||||
|
}, |
||||
|
dashboard: { |
||||
|
statsCards: '.grid > div', |
||||
|
chartContainer: '.h-64', |
||||
|
activityList: '.space-y-4 > div', |
||||
|
}, |
||||
|
users: { |
||||
|
searchInput: 'input[placeholder*="搜索"]', |
||||
|
addButton: 'button:has-text("添加用户")', |
||||
|
table: 'table', |
||||
|
tableRows: 'tbody tr', |
||||
|
editButton: 'button:has(> svg[data-lucide="Edit2"])', |
||||
|
deleteButton: 'button:has(> svg[data-lucide="Trash2"])', |
||||
|
modal: { |
||||
|
container: '[role="dialog"]', |
||||
|
usernameInput: 'input[placeholder*="用户名"]', |
||||
|
emailInput: 'input[type="email"]', |
||||
|
passwordInput: 'input[type="password"]', |
||||
|
phoneInput: 'input[placeholder*="手机号"]', |
||||
|
saveButton: 'button:has-text("保存"), button:has-text("创建")', |
||||
|
cancelButton: 'button:has-text("取消")', |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
Loading…
Reference in new issue