You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.3 KiB
90 lines
2.3 KiB
/**
|
|
* Playwright MCP 测试主入口
|
|
*
|
|
* 运行所有测试的顺序:
|
|
* 1. 登录页面测试
|
|
* 2. 导航和路由保护测试
|
|
* 3. 仪表板页面测试
|
|
* 4. 用户管理页面测试
|
|
* 5. 设置页面测试
|
|
*/
|
|
|
|
import { loginTests } from './login.test';
|
|
import { dashboardTests } from './dashboard.test';
|
|
import { userManagementTests } from './users.test';
|
|
import { settingsTests } from './settings.test';
|
|
import { navigationTests } from './navigation.test';
|
|
import { userE2ETests } from './users.e2e.test';
|
|
import { runFullE2ETests } from './run-e2e-tests';
|
|
|
|
export const allTests = {
|
|
login: loginTests,
|
|
navigation: navigationTests,
|
|
dashboard: dashboardTests,
|
|
users: userManagementTests,
|
|
settings: settingsTests,
|
|
};
|
|
|
|
// 测试套件配置
|
|
export const testSuite = {
|
|
name: 'react-shadcn/pc Playwright MCP 完整测试套件',
|
|
version: '1.0.0',
|
|
|
|
// 测试执行顺序
|
|
executionOrder: [
|
|
'login',
|
|
'navigation',
|
|
'dashboard',
|
|
'users',
|
|
'settings',
|
|
],
|
|
|
|
// 运行所有测试
|
|
async runAll() {
|
|
console.log('🚀 开始执行完整测试套件...\n');
|
|
const results = [];
|
|
|
|
for (const testName of this.executionOrder) {
|
|
console.log(`\n📦 运行测试模块: ${testName}`);
|
|
const testModule = allTests[testName as keyof typeof allTests];
|
|
|
|
if (testModule) {
|
|
const moduleResults = await this.runModule(testModule);
|
|
results.push({ name: testName, results: moduleResults });
|
|
}
|
|
}
|
|
|
|
console.log('\n📊 测试执行完成!');
|
|
return results;
|
|
},
|
|
|
|
// 运行单个测试模块
|
|
async runModule(testModule: any) {
|
|
const results = [];
|
|
const tests = Object.entries(testModule).filter(([key]) => key.startsWith('test'));
|
|
|
|
for (const [testName, testFn] of tests) {
|
|
if (typeof testFn === 'function') {
|
|
try {
|
|
await testFn();
|
|
results.push({ name: testName, status: 'passed' });
|
|
} catch (error) {
|
|
results.push({ name: testName, status: 'failed', error });
|
|
}
|
|
}
|
|
}
|
|
|
|
return results;
|
|
},
|
|
};
|
|
|
|
// 导出 E2E 测试
|
|
export { userE2ETests } from './users.e2e.test';
|
|
export { runFullE2ETests } from './run-e2e-tests';
|
|
|
|
// 便捷函数:执行完整 E2E 测试
|
|
export async function runE2E() {
|
|
return runFullE2ETests();
|
|
}
|
|
|
|
export default testSuite;
|
|
|