fix: resolve UAT test issues and improve test infrastructure

This commit is contained in:
张翔
2026-03-25 10:21:47 +08:00
parent f0efbaeabd
commit 6c35ba7fb4
7 changed files with 202 additions and 4 deletions
@@ -0,0 +1,36 @@
import { test, expect } from '@playwright/test';
test.describe('UAT - 基础环境验证', () => {
test('前端服务可访问', async ({ page }) => {
await page.goto('http://localhost:3003');
await page.waitForLoadState('networkidle');
const title = await page.title();
console.log('页面标题:', title);
expect(title).toBeTruthy();
});
test('登录页面可访问', async ({ page }) => {
await page.goto('http://localhost:3003/login');
await page.waitForLoadState('networkidle');
const currentUrl = page.url();
console.log('当前URL:', currentUrl);
expect(currentUrl).toContain('/login');
});
test('登录表单元素存在', async ({ page }) => {
await page.goto('http://localhost:3003/login');
await page.waitForLoadState('networkidle');
const usernameInput = page.locator('input[type="text"], input[placeholder*="用户"]');
const passwordInput = page.locator('input[type="password"]');
const loginButton = page.locator('button:has-text("登录"), button:has-text("登 录")');
await expect(usernameInput).toBeVisible();
await expect(passwordInput).toBeVisible();
await expect(loginButton).toBeVisible();
});
});
@@ -0,0 +1,34 @@
import { test, expect } from '@playwright/test';
import { LoginPage } from '../../novalon-manage-web/e2e/pages/LoginPage';
test.describe('UAT - 登录功能验证', () => {
let loginPage: LoginPage;
test.beforeEach(async ({ page }) => {
loginPage = new LoginPage(page);
await loginPage.goto();
});
test('使用admin账户登录', async ({ page }) => {
await loginPage.login('admin', 'admin123');
const currentUrl = page.url();
console.log('登录后URL:', currentUrl);
await page.waitForLoadState('networkidle');
const isLoggedIn = await loginPage.isLoggedIn();
expect(isLoggedIn).toBeTruthy();
});
test('登录失败显示错误信息', async ({ page }) => {
await loginPage.login('wronguser', 'wrongpassword');
await page.waitForTimeout(2000);
const errorMessage = await loginPage.getErrorMessage();
console.log('错误信息:', errorMessage);
expect(errorMessage).toBeTruthy();
});
});