feat: 添加异常日志功能并优化UI样式
refactor: 重构后端查询逻辑和API响应处理 fix: 修复用户角色更新和文件上传问题 test: 添加前端性能测试脚本和E2E测试用例 chore: 更新依赖版本和配置文件 docs: 添加环境检查脚本和测试文档 style: 统一表格标签样式和路由命名 perf: 优化前端页面加载速度和响应时间
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('登录诊断测试', () => {
|
||||
test('诊断1: 检查登录页面元素', async ({ page }) => {
|
||||
await page.goto('/login');
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
console.log('页面URL:', page.url());
|
||||
console.log('页面标题:', await page.title());
|
||||
|
||||
const usernameInput = page.locator('input[placeholder*="用户名"]');
|
||||
const passwordInput = page.locator('input[type="password"]');
|
||||
const submitButton = page.locator('button[type="submit"]');
|
||||
|
||||
console.log('用户名输入框可见:', await usernameInput.isVisible());
|
||||
console.log('密码输入框可见:', await passwordInput.isVisible());
|
||||
console.log('提交按钮可见:', await submitButton.isVisible());
|
||||
|
||||
await usernameInput.fill('admin');
|
||||
await passwordInput.fill('admin123');
|
||||
|
||||
console.log('表单已填充');
|
||||
|
||||
const [response] = await Promise.all([
|
||||
page.waitForResponse(res => res.url().includes('/auth/login')),
|
||||
submitButton.click()
|
||||
]);
|
||||
|
||||
console.log('登录响应状态:', response.status());
|
||||
console.log('登录响应内容:', await response.text());
|
||||
console.log('当前URL:', page.url());
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
console.log('2秒后URL:', page.url());
|
||||
});
|
||||
|
||||
test('诊断2: 检查登录后的页面', async ({ page }) => {
|
||||
await page.goto('/login');
|
||||
|
||||
const usernameInput = page.locator('input[placeholder*="用户名"]');
|
||||
const passwordInput = page.locator('input[type="password"]');
|
||||
const submitButton = page.locator('button[type="submit"]');
|
||||
|
||||
await usernameInput.fill('admin');
|
||||
await passwordInput.fill('admin123');
|
||||
|
||||
await submitButton.click();
|
||||
|
||||
try {
|
||||
await page.waitForURL('**/dashboard', { timeout: 10000 });
|
||||
console.log('成功跳转到dashboard');
|
||||
} catch (error) {
|
||||
console.log('未能跳转到dashboard,当前URL:', page.url());
|
||||
|
||||
const errorMessages = page.locator('.el-message');
|
||||
if (await errorMessages.count() > 0) {
|
||||
console.log('错误消息:', await errorMessages.first().textContent());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('诊断3: 使用API直接测试登录', async ({ request }) => {
|
||||
const response = await request.post('http://localhost:8084/api/auth/login', {
|
||||
data: {
|
||||
username: 'admin',
|
||||
password: 'admin123'
|
||||
}
|
||||
});
|
||||
|
||||
console.log('API响应状态:', response.status());
|
||||
console.log('API响应内容:', await response.text());
|
||||
|
||||
expect(response.status()).toBe(200);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user