1 changed files with 100 additions and 0 deletions
@ -0,0 +1,100 @@ |
|||
import { TEST_CONFIG, ROUTES, SELECTORS } from './config'; |
|||
|
|||
/** |
|||
* 测试场景: 仪表板页面功能 |
|||
* |
|||
* 前置条件: |
|||
* 1. 用户已登录(localStorage 中有 token) |
|||
*/ |
|||
|
|||
export const dashboardTests = { |
|||
name: '仪表板页面测试', |
|||
|
|||
// Test 1: 仪表板加载验证
|
|||
async testDashboardLoad() { |
|||
console.log('🧪 Test: 仪表板页面加载'); |
|||
|
|||
// 导航到仪表板
|
|||
await mcp__plugin_playwright_playwright__browser_navigate({ |
|||
url: `${TEST_CONFIG.baseURL}${ROUTES.dashboard}` |
|||
}); |
|||
|
|||
await mcp__plugin_playwright_playwright__browser_wait_for({ time: 2 }); |
|||
|
|||
const snapshot = await mcp__plugin_playwright_playwright__browser_snapshot({}); |
|||
|
|||
// 验证统计数据卡片
|
|||
console.assert( |
|||
snapshot.includes('总用户数') && |
|||
snapshot.includes('活跃用户') && |
|||
snapshot.includes('系统负载') && |
|||
snapshot.includes('数据库状态'), |
|||
'所有统计卡片应该显示' |
|||
); |
|||
|
|||
// 验证图表区域
|
|||
console.assert( |
|||
snapshot.includes('用户增长趋势'), |
|||
'用户增长趋势图表应该显示' |
|||
); |
|||
|
|||
// 验证最近活动
|
|||
console.assert( |
|||
snapshot.includes('最近活动'), |
|||
'最近活动列表应该显示' |
|||
); |
|||
|
|||
console.log('✅ 仪表板页面加载验证通过'); |
|||
}, |
|||
|
|||
// Test 2: 统计数据验证
|
|||
async testStatsDisplay() { |
|||
console.log('🧪 Test: 统计数据展示'); |
|||
|
|||
const snapshot = await mcp__plugin_playwright_playwright__browser_snapshot({}); |
|||
|
|||
// 验证统计数据值存在
|
|||
const stats = ['1,234', '856', '32%', '正常']; |
|||
stats.forEach(stat => { |
|||
console.assert( |
|||
snapshot.includes(stat), |
|||
`统计值 ${stat} 应该显示` |
|||
); |
|||
}); |
|||
|
|||
console.log('✅ 统计数据展示验证通过'); |
|||
}, |
|||
|
|||
// Test 3: 快捷操作按钮
|
|||
async testQuickActions() { |
|||
console.log('🧪 Test: 快捷操作按钮'); |
|||
|
|||
const snapshot = await mcp__plugin_playwright_playwright__browser_snapshot({}); |
|||
|
|||
// 验证快捷操作按钮
|
|||
const actions = ['添加用户', '系统设置', '数据备份', '查看日志']; |
|||
actions.forEach(action => { |
|||
console.assert( |
|||
snapshot.includes(action), |
|||
`快捷操作 ${action} 应该显示` |
|||
); |
|||
}); |
|||
|
|||
console.log('✅ 快捷操作按钮验证通过'); |
|||
}, |
|||
|
|||
// Test 4: 最近活动列表
|
|||
async testRecentActivity() { |
|||
console.log('🧪 Test: 最近活动列表'); |
|||
|
|||
const snapshot = await mcp__plugin_playwright_playwright__browser_snapshot({}); |
|||
|
|||
// 验证活动项存在
|
|||
console.assert( |
|||
snapshot.includes('登录系统') || snapshot.includes('更新资料'), |
|||
'应该有最近活动记录' |
|||
); |
|||
|
|||
console.log('✅ 最近活动列表验证通过'); |
|||
}, |
|||
}; |
|||
Loading…
Reference in new issue