Files
novalon-manage-system/novalon-manage-web/e2e/diagnostic.spec.ts
T

67 lines
2.3 KiB
TypeScript

import { test, expect } from '@playwright/test';
test.describe('环境诊断测试', () => {
test('诊断1: 检查前端服务连接', async ({ page }) => {
console.log('开始诊断测试1:检查前端服务连接');
try {
const response = await page.goto('http://localhost:3001');
console.log('前端服务响应状态:', response.status());
console.log('页面标题:', await page.title());
expect(response.status()).toBe(200);
} catch (error) {
console.error('前端服务连接失败:', error);
throw error;
}
});
test('诊断2: 检查后端服务连接', async ({ request }) => {
console.log('开始诊断测试2:检查后端服务连接');
try {
const response = await request.get('http://localhost:8084/actuator/health');
console.log('后端服务响应状态:', response.status());
console.log('后端服务响应体:', await response.text());
expect(response.status()).toBe(200);
} catch (error) {
console.error('后端服务连接失败:', error);
throw error;
}
});
test('诊断3: 检查登录页面可访问性', async ({ page }) => {
console.log('开始诊断测试3:检查登录页面可访问性');
try {
await page.goto('http://localhost:3001/login');
console.log('当前URL:', page.url());
console.log('页面标题:', await page.title());
const title = await page.title();
console.log('页面标题内容:', title);
expect(title).toContain('登录');
} catch (error) {
console.error('登录页面访问失败:', error);
throw error;
}
});
test('诊断4: 检查页面元素可定位性', async ({ page }) => {
console.log('开始诊断测试4:检查页面元素可定位性');
try {
await page.goto('http://localhost:3001/login');
await page.waitForLoadState('networkidle');
const usernameInput = page.locator('input[placeholder*="用户名"]');
const isVisible = await usernameInput.isVisible({ timeout: 5000 });
console.log('用户名输入框可见性:', isVisible);
expect(isVisible).toBe(true);
} catch (error) {
console.error('页面元素定位失败:', error);
throw error;
}
});
});