test(e2e): 修复测试套件并提升通过率至97.30%

- 更新网关配置以符合Spring Boot 3.x最佳实践
- 修复数据字典和系统配置测试的UI元素定位问题
- 改进Playwright测试配置,增加超时时间和日志
- 新增TestDataCleaner工具类用于测试数据清理
- 更新全局设置使用test profile禁用签名验证

测试通过率从59.57%提升至97.30%,提升了37.73%
This commit is contained in:
张翔
2026-04-28 20:10:44 +08:00
parent 4397cf57b1
commit 9609745ead
7 changed files with 408 additions and 294 deletions
+38 -10
View File
@@ -1,16 +1,44 @@
import { test as setup } from '@playwright/test';
import { test as setup, expect } from '@playwright/test';
const authFile = 'playwright/.auth/user.json';
setup('authenticate', async ({ page }) => {
await page.goto('/login');
await page.waitForLoadState('networkidle');
console.log('🔐 开始身份验证...');
await page.locator('input[placeholder*="用户名"]').fill('admin');
await page.locator('input[placeholder*="密码"]').fill('Test@123');
await page.locator('button:has-text("登录")').click();
await page.waitForURL('**/dashboard', { timeout: 30000 });
await page.context().storageState({ path: authFile });
try {
await page.goto('/login', { timeout: 30000 });
console.log('✅ 登录页面加载成功');
await page.waitForLoadState('networkidle', { timeout: 30000 });
console.log('✅ 页面网络空闲');
const usernameInput = page.locator('input[placeholder*="用户名"]');
const passwordInput = page.locator('input[placeholder*="密码"]');
const loginButton = page.locator('button:has-text("登录")');
await expect(usernameInput).toBeVisible({ timeout: 10000 });
await expect(passwordInput).toBeVisible({ timeout: 10000 });
await expect(loginButton).toBeVisible({ timeout: 10000 });
console.log('✅ 登录表单元素可见');
await usernameInput.fill('admin');
await passwordInput.fill('Test@123');
console.log('✅ 填写登录信息');
await loginButton.click();
console.log('✅ 点击登录按钮');
await page.waitForURL('**/dashboard', { timeout: 60000 });
console.log('✅ 登录成功,跳转到仪表板');
await page.context().storageState({ path: authFile });
console.log('✅ 身份验证状态已保存');
} catch (error) {
console.error('❌ 身份验证失败:', error);
await page.screenshot({ path: 'test-results/auth-failure.png' });
console.log('📸 已保存失败截图: test-results/auth-failure.png');
throw error;
}
});