fix: improve UAT tests with proper waits and increased timeouts
This commit is contained in:
@@ -3,6 +3,7 @@ import { LoginPage } from './pages/LoginPage';
|
||||
import { DashboardPage } from './pages/DashboardPage';
|
||||
|
||||
test.describe('UAT阶段一:核心功能验证', () => {
|
||||
test.slow();
|
||||
|
||||
test('UAT-AUTH-001: 成功登录流程', async ({ page }) => {
|
||||
const loginPage = new LoginPage(page);
|
||||
@@ -10,6 +11,7 @@ test.describe('UAT阶段一:核心功能验证', () => {
|
||||
|
||||
await test.step('访问登录页面', async () => {
|
||||
await loginPage.goto();
|
||||
await page.waitForLoadState('networkidle');
|
||||
await expect(page).toHaveTitle(/登录/);
|
||||
});
|
||||
|
||||
@@ -23,7 +25,8 @@ test.describe('UAT阶段一:核心功能验证', () => {
|
||||
});
|
||||
|
||||
await test.step('验证登录成功', async () => {
|
||||
await page.waitForURL(/.*dashboard/, { timeout: 10000 });
|
||||
await page.waitForURL(/.*dashboard/, { timeout: 30000 });
|
||||
await page.waitForLoadState('networkidle');
|
||||
const username = await dashboardPage.getUsername();
|
||||
expect(username).toContain('admin');
|
||||
});
|
||||
@@ -34,6 +37,7 @@ test.describe('UAT阶段一:核心功能验证', () => {
|
||||
|
||||
await test.step('访问登录页面', async () => {
|
||||
await loginPage.goto();
|
||||
await page.waitForLoadState('networkidle');
|
||||
await expect(page).toHaveTitle(/登录/);
|
||||
});
|
||||
|
||||
@@ -44,7 +48,7 @@ test.describe('UAT阶段一:核心功能验证', () => {
|
||||
});
|
||||
|
||||
await test.step('验证错误消息显示', async () => {
|
||||
await page.waitForTimeout(2000);
|
||||
await expect(loginPage.errorMessage).toBeVisible({ timeout: 10000 });
|
||||
const errorMessage = await loginPage.getErrorMessage();
|
||||
expect(errorMessage).toBeTruthy();
|
||||
});
|
||||
@@ -59,16 +63,17 @@ test.describe('UAT阶段一:核心功能验证', () => {
|
||||
|
||||
await test.step('登录系统', async () => {
|
||||
await loginPage.goto();
|
||||
await page.waitForLoadState('networkidle');
|
||||
await loginPage.usernameInput.fill('admin');
|
||||
await loginPage.passwordInput.fill('password');
|
||||
await loginPage.loginButton.click();
|
||||
await page.waitForURL(/.*dashboard/, { timeout: 10000 });
|
||||
await page.waitForURL(/.*dashboard/, { timeout: 30000 });
|
||||
});
|
||||
|
||||
await test.step('点击用户头像', async () => {
|
||||
const avatar = page.locator('.el-avatar');
|
||||
await avatar.click();
|
||||
await page.waitForTimeout(1000);
|
||||
await page.waitForSelector('.el-dropdown-menu', { state: 'visible' });
|
||||
});
|
||||
|
||||
await test.step('点击退出登录', async () => {
|
||||
@@ -77,7 +82,7 @@ test.describe('UAT阶段一:核心功能验证', () => {
|
||||
});
|
||||
|
||||
await test.step('验证跳转到登录页面', async () => {
|
||||
await page.waitForURL(/.*login/, { timeout: 10000 });
|
||||
await page.waitForURL(/.*login/, { timeout: 30000 });
|
||||
await expect(page).toHaveTitle(/登录/);
|
||||
});
|
||||
});
|
||||
@@ -88,16 +93,17 @@ test.describe('UAT阶段一:核心功能验证', () => {
|
||||
|
||||
await test.step('登录系统', async () => {
|
||||
await loginPage.goto();
|
||||
await page.waitForLoadState('networkidle');
|
||||
await loginPage.usernameInput.fill('admin');
|
||||
await loginPage.passwordInput.fill('password');
|
||||
await loginPage.loginButton.click();
|
||||
await page.waitForURL(/.*dashboard/, { timeout: 10000 });
|
||||
await page.waitForURL(/.*dashboard/, { timeout: 30000 });
|
||||
});
|
||||
|
||||
await test.step('点击系统管理菜单', async () => {
|
||||
const systemMenu = page.locator('.el-sub-menu').filter({ hasText: '系统管理' });
|
||||
await systemMenu.click();
|
||||
await page.waitForTimeout(500);
|
||||
await page.waitForLoadState('networkidle');
|
||||
});
|
||||
|
||||
await test.step('点击用户管理', async () => {
|
||||
@@ -105,7 +111,7 @@ test.describe('UAT阶段一:核心功能验证', () => {
|
||||
});
|
||||
|
||||
await test.step('验证页面跳转', async () => {
|
||||
await page.waitForURL(/.*users/, { timeout: 10000 });
|
||||
await page.waitForURL(/.*users/, { timeout: 30000 });
|
||||
await expect(page).toHaveURL(/.*users/);
|
||||
});
|
||||
});
|
||||
@@ -116,16 +122,17 @@ test.describe('UAT阶段一:核心功能验证', () => {
|
||||
|
||||
await test.step('登录系统', async () => {
|
||||
await loginPage.goto();
|
||||
await page.waitForLoadState('networkidle');
|
||||
await loginPage.usernameInput.fill('admin');
|
||||
await loginPage.passwordInput.fill('password');
|
||||
await loginPage.loginButton.click();
|
||||
await page.waitForURL(/.*dashboard/, { timeout: 10000 });
|
||||
await page.waitForURL(/.*dashboard/, { timeout: 30000 });
|
||||
});
|
||||
|
||||
await test.step('点击系统管理菜单', async () => {
|
||||
const systemMenu = page.locator('.el-sub-menu').filter({ hasText: '系统管理' });
|
||||
await systemMenu.click();
|
||||
await page.waitForTimeout(500);
|
||||
await page.waitForLoadState('networkidle');
|
||||
});
|
||||
|
||||
await test.step('点击角色管理', async () => {
|
||||
@@ -133,7 +140,7 @@ test.describe('UAT阶段一:核心功能验证', () => {
|
||||
});
|
||||
|
||||
await test.step('验证页面跳转', async () => {
|
||||
await page.waitForURL(/.*roles/, { timeout: 10000 });
|
||||
await page.waitForURL(/.*roles/, { timeout: 30000 });
|
||||
await expect(page).toHaveURL(/.*roles/);
|
||||
});
|
||||
});
|
||||
@@ -144,16 +151,17 @@ test.describe('UAT阶段一:核心功能验证', () => {
|
||||
|
||||
await test.step('登录系统', async () => {
|
||||
await loginPage.goto();
|
||||
await page.waitForLoadState('networkidle');
|
||||
await loginPage.usernameInput.fill('admin');
|
||||
await loginPage.passwordInput.fill('password');
|
||||
await loginPage.loginButton.click();
|
||||
await page.waitForURL(/.*dashboard/, { timeout: 10000 });
|
||||
await page.waitForURL(/.*dashboard/, { timeout: 30000 });
|
||||
});
|
||||
|
||||
await test.step('点击系统管理菜单', async () => {
|
||||
const systemMenu = page.locator('.el-sub-menu').filter({ hasText: '系统管理' });
|
||||
await systemMenu.click();
|
||||
await page.waitForTimeout(500);
|
||||
await page.waitForLoadState('networkidle');
|
||||
});
|
||||
|
||||
await test.step('点击菜单管理', async () => {
|
||||
@@ -161,7 +169,7 @@ test.describe('UAT阶段一:核心功能验证', () => {
|
||||
});
|
||||
|
||||
await test.step('验证页面跳转', async () => {
|
||||
await page.waitForURL(/.*menus/, { timeout: 10000 });
|
||||
await page.waitForURL(/.*menus/, { timeout: 30000 });
|
||||
await expect(page).toHaveURL(/.*menus/);
|
||||
});
|
||||
});
|
||||
@@ -172,16 +180,17 @@ test.describe('UAT阶段一:核心功能验证', () => {
|
||||
|
||||
await test.step('登录系统', async () => {
|
||||
await loginPage.goto();
|
||||
await page.waitForLoadState('networkidle');
|
||||
await loginPage.usernameInput.fill('admin');
|
||||
await loginPage.passwordInput.fill('password');
|
||||
await loginPage.loginButton.click();
|
||||
await page.waitForURL(/.*dashboard/, { timeout: 10000 });
|
||||
await page.waitForURL(/.*dashboard/, { timeout: 30000 });
|
||||
});
|
||||
|
||||
await test.step('点击系统配置菜单', async () => {
|
||||
const configMenu = page.locator('.el-sub-menu').filter({ hasText: '系统配置' });
|
||||
await configMenu.click();
|
||||
await page.waitForTimeout(500);
|
||||
await page.waitForLoadState('networkidle');
|
||||
});
|
||||
|
||||
await test.step('点击参数配置', async () => {
|
||||
@@ -189,8 +198,8 @@ test.describe('UAT阶段一:核心功能验证', () => {
|
||||
});
|
||||
|
||||
await test.step('验证页面跳转', async () => {
|
||||
await page.waitForURL(/.*sysconfig/, { timeout: 10000 });
|
||||
await page.waitForURL(/.*sysconfig/, { timeout: 30000 });
|
||||
await expect(page).toHaveURL(/.*sysconfig/);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user