test: E2E 测试用例更新与新增

- 更新 Page Object 模型适配新字段名
- 新增 UAT 测试套件与 journey 测试用例
- 优化测试辅助工具与数据工厂
- 更新 playwright 认证状态
This commit is contained in:
张翔
2026-05-06 14:17:51 +08:00
parent 0b246b3e24
commit bd21e2d1f7
47 changed files with 1764 additions and 1226 deletions
+12 -12
View File
@@ -100,7 +100,7 @@ export class TestDataCleanup {
await this.page.goto('/users');
await this.page.waitForLoadState('networkidle', { timeout: 10000 });
const searchInput = this.page.locator('input[placeholder*="搜索"], input[name*="keyword"], .el-input__inner').first();
const searchInput = this.page.locator('input[placeholder*="搜索"], input[name*="keyword"], .ant-input__inner').first();
await searchInput.fill(username);
const searchButton = this.page.getByRole('button', { name: '搜索' }).or(this.page.locator('button:has-text("搜索")'));
@@ -111,11 +111,11 @@ export class TestDataCleanup {
const rowCount = await userRow.count();
if (rowCount > 0) {
const deleteButton = userRow.locator('.delete-button, .el-button--danger').first();
const deleteButton = userRow.locator('.delete-button, .ant-btn--danger').first();
await deleteButton.click();
await this.page.waitForTimeout(500);
const confirmButton = this.page.getByRole('button', { name: '确定' }).or(this.page.locator('.el-button--primary:has-text("确定")'));
const confirmButton = this.page.getByRole('button', { name: '确定' }).or(this.page.locator('.ant-btn--primary:has-text("确定")'));
await confirmButton.click();
await this.page.waitForTimeout(1500);
}
@@ -129,7 +129,7 @@ export class TestDataCleanup {
await this.page.goto('/roles');
await this.page.waitForLoadState('networkidle', { timeout: 10000 });
const searchInput = this.page.locator('input[placeholder*="搜索"], input[name*="keyword"], .el-input__inner').first();
const searchInput = this.page.locator('input[placeholder*="搜索"], input[name*="keyword"], .ant-input__inner').first();
await searchInput.fill(roleName);
const searchButton = this.page.getByRole('button', { name: '搜索' }).or(this.page.locator('button:has-text("搜索")'));
@@ -140,11 +140,11 @@ export class TestDataCleanup {
const rowCount = await roleRow.count();
if (rowCount > 0) {
const deleteButton = roleRow.locator('.delete-button, .el-button--danger').first();
const deleteButton = roleRow.locator('.delete-button, .ant-btn--danger').first();
await deleteButton.click();
await this.page.waitForTimeout(500);
const confirmButton = this.page.getByRole('button', { name: '确定' }).or(this.page.locator('.el-button--primary:has-text("确定")'));
const confirmButton = this.page.getByRole('button', { name: '确定' }).or(this.page.locator('.ant-btn--primary:has-text("确定")'));
await confirmButton.click();
await this.page.waitForTimeout(1500);
}
@@ -162,11 +162,11 @@ export class TestDataCleanup {
const rowCount = await menuRow.count();
if (rowCount > 0) {
const deleteButton = menuRow.locator('.delete-button, .el-button--danger').first();
const deleteButton = menuRow.locator('.delete-button, .ant-btn--danger').first();
await deleteButton.click();
await this.page.waitForTimeout(500);
const confirmButton = this.page.getByRole('button', { name: '确定' }).or(this.page.locator('.el-button--primary:has-text("确定")'));
const confirmButton = this.page.getByRole('button', { name: '确定' }).or(this.page.locator('.ant-btn--primary:has-text("确定")'));
await confirmButton.click();
await this.page.waitForTimeout(1500);
}
@@ -184,11 +184,11 @@ export class TestDataCleanup {
const rowCount = await dictRow.count();
if (rowCount > 0) {
const deleteButton = dictRow.locator('.delete-button, .el-button--danger').first();
const deleteButton = dictRow.locator('.delete-button, .ant-btn--danger').first();
await deleteButton.click();
await this.page.waitForTimeout(500);
const confirmButton = this.page.getByRole('button', { name: '确定' }).or(this.page.locator('.el-button--primary:has-text("确定")'));
const confirmButton = this.page.getByRole('button', { name: '确定' }).or(this.page.locator('.ant-btn--primary:has-text("确定")'));
await confirmButton.click();
await this.page.waitForTimeout(1500);
}
@@ -206,11 +206,11 @@ export class TestDataCleanup {
const rowCount = await dictRow.count();
if (rowCount > 0) {
const deleteButton = dictRow.locator('.delete-button, .el-button--danger').first();
const deleteButton = dictRow.locator('.delete-button, .ant-btn--danger').first();
await deleteButton.click();
await this.page.waitForTimeout(500);
const confirmButton = this.page.getByRole('button', { name: '确定' }).or(this.page.locator('.el-button--primary:has-text("确定")'));
const confirmButton = this.page.getByRole('button', { name: '确定' }).or(this.page.locator('.ant-btn--primary:has-text("确定")'));
await confirmButton.click();
await this.page.waitForTimeout(1500);
}
@@ -94,8 +94,8 @@ export class TestDataFactory {
nickname: '管理员',
email: 'admin@example.com',
phone: '13800138000',
password: 'admin123',
confirmPassword: 'admin123'
password: 'Test@123',
confirmPassword: 'Test@123'
};
}
+7 -7
View File
@@ -211,7 +211,7 @@ export class TestHelpers {
}
static async waitForSuccessMessage(page: Page, timeout: number = 5000): Promise<boolean> {
const successMessage = page.locator('.el-message--success, .success-message, [class*="success"]');
const successMessage = page.locator('.ant-message-success, .success-message, [class*="success"]');
try {
await successMessage.waitFor({ state: 'visible', timeout });
return true;
@@ -221,7 +221,7 @@ export class TestHelpers {
}
static async waitForErrorMessage(page: Page, timeout: number = 5000): Promise<boolean> {
const errorMessage = page.locator('.el-message--error, .error-message, [class*="error"]');
const errorMessage = page.locator('.ant-message-error, .error-message, [class*="error"]');
try {
await errorMessage.waitFor({ state: 'visible', timeout });
return true;
@@ -231,7 +231,7 @@ export class TestHelpers {
}
static async waitForLoadingComplete(page: Page, timeout: number = 10000): Promise<void> {
const loadingSpinner = page.locator('.el-loading-mask, .loading, [class*="loading"]');
const loadingSpinner = page.locator('.ant-spin-container, .loading, [class*="loading"]');
try {
await loadingSpinner.waitFor({ state: 'visible', timeout: 2000 });
@@ -242,7 +242,7 @@ export class TestHelpers {
}
static async waitForModal(page: Page, timeout: number = 5000): Promise<boolean> {
const modal = page.locator('.el-dialog, .modal, [role="dialog"]');
const modal = page.locator('.ant-modal, .modal, [role="dialog"]');
try {
await modal.waitFor({ state: 'visible', timeout });
return true;
@@ -252,7 +252,7 @@ export class TestHelpers {
}
static async closeModal(page: Page): Promise<boolean> {
const closeButton = page.locator('.el-dialog__close, .modal-close, button[aria-label="Close"]');
const closeButton = page.locator('.ant-modal__close, .modal-close, button[aria-label="Close"]');
try {
await closeButton.click();
return true;
@@ -262,7 +262,7 @@ export class TestHelpers {
}
static async waitForSelectDropdown(page: Page, timeout: number = 5000): Promise<boolean> {
const dropdown = page.locator('.el-select-dropdown, .select-dropdown');
const dropdown = page.locator('.ant-select-dropdown, .select-dropdown');
try {
await dropdown.waitFor({ state: 'visible', timeout });
return true;
@@ -272,7 +272,7 @@ export class TestHelpers {
}
static async selectFromDropdown(page: Page, value: string): Promise<boolean> {
const option = page.locator('.el-select-dropdown__item, .select-option').filter({ hasText: value });
const option = page.locator('.ant-select-item, .select-option').filter({ hasText: value });
try {
await option.click();
return true;
+3 -3
View File
@@ -124,15 +124,15 @@ export class TestHelper {
message: string,
timeout: number = 5000
): Promise<void> {
await expect(page.locator('.el-message')).toContainText(message, { timeout });
await expect(page.locator('.ant-message')).toContainText(message, { timeout });
}
static async waitForSuccessMessage(page: Page, timeout: number = 5000): Promise<void> {
await expect(page.locator('.el-message--success')).toBeVisible({ timeout });
await expect(page.locator('.ant-message-success')).toBeVisible({ timeout });
}
static async waitForErrorMessage(page: Page, timeout: number = 5000): Promise<void> {
await expect(page.locator('.el-message--error')).toBeVisible({ timeout });
await expect(page.locator('.ant-message-error')).toBeVisible({ timeout });
}
static async getElementText(page: Page, selector: string): Promise<string> {