develop #1

Merged
zhangxiang merged 60 commits from develop into main 2026-04-05 10:28:15 +08:00
7 changed files with 105 additions and 18 deletions
Showing only changes of commit ba9cdb4b6f - Show all commits
@@ -1,4 +1,4 @@
import { Page, Locator } from '@playwright/test'; import { Page, Locator, expect } from '@playwright/test';
export class DictionaryManagementPage { export class DictionaryManagementPage {
readonly page: Page; readonly page: Page;
@@ -24,8 +24,20 @@ export class DictionaryManagementPage {
} }
async goto() { async goto() {
try {
console.log('导航到字典管理页面...');
await this.page.goto('/dict'); await this.page.goto('/dict');
await this.page.waitForLoadState('networkidle'); await this.page.waitForLoadState('networkidle');
await this.table.waitFor({ state: 'visible', timeout: 10000 });
await expect(this.page).toHaveURL(/.*dict/);
console.log('字典管理页面加载完成');
} catch (error) {
await this.page.screenshot({ path: `test-results/dict-management-error-${Date.now()}.png` });
console.error('导航到字典管理页面失败:', error);
throw new Error(`导航到字典管理页面失败: ${error instanceof Error ? error.message : String(error)}`);
}
} }
async clickCreateDictType() { async clickCreateDictType() {
@@ -1,4 +1,4 @@
import { Page, Locator } from '@playwright/test'; import { Page, Locator, expect } from '@playwright/test';
export class ExceptionLogPage { export class ExceptionLogPage {
readonly page: Page; readonly page: Page;
@@ -22,8 +22,20 @@ export class ExceptionLogPage {
} }
async goto() { async goto() {
try {
console.log('导航到异常日志页面...');
await this.page.goto('/exceptionlog'); await this.page.goto('/exceptionlog');
await this.page.waitForLoadState('networkidle'); await this.page.waitForLoadState('networkidle');
await this.table.waitFor({ state: 'visible', timeout: 10000 });
await expect(this.page).toHaveURL(/.*exceptionlog/);
console.log('异常日志页面加载完成');
} catch (error) {
await this.page.screenshot({ path: `test-results/exception-log-error-${Date.now()}.png` });
console.error('导航到异常日志页面失败:', error);
throw new Error(`导航到异常日志页面失败: ${error instanceof Error ? error.message : String(error)}`);
}
} }
async search(keyword: string) { async search(keyword: string) {
@@ -20,9 +20,20 @@ export class FileManagementPage {
} }
async goto() { async goto() {
try {
console.log('导航到文件管理页面...');
await this.page.goto('/files'); await this.page.goto('/files');
await this.page.waitForLoadState('networkidle'); await this.page.waitForLoadState('networkidle');
await this.page.waitForTimeout(3000); await this.table.waitFor({ state: 'visible', timeout: 10000 });
await expect(this.page).toHaveURL(/.*files/);
console.log('文件管理页面加载完成');
} catch (error) {
await this.page.screenshot({ path: `test-results/file-management-error-${Date.now()}.png` });
console.error('导航到文件管理页面失败:', error);
throw new Error(`导航到文件管理页面失败: ${error instanceof Error ? error.message : String(error)}`);
}
} }
async uploadFile(filePath: string) { async uploadFile(filePath: string) {
@@ -16,8 +16,20 @@ export class LoginLogPage {
} }
async goto() { async goto() {
try {
console.log('导航到登录日志页面...');
await this.page.goto('/loginlog'); await this.page.goto('/loginlog');
await this.page.waitForLoadState('networkidle'); await this.page.waitForLoadState('networkidle');
await this.table.waitFor({ state: 'visible', timeout: 10000 });
await expect(this.page).toHaveURL(/.*loginlog/);
console.log('登录日志页面加载完成');
} catch (error) {
await this.page.screenshot({ path: `test-results/login-log-error-${Date.now()}.png` });
console.error('导航到登录日志页面失败:', error);
throw new Error(`导航到登录日志页面失败: ${error instanceof Error ? error.message : String(error)}`);
}
} }
async searchByKeyword(keyword: string) { async searchByKeyword(keyword: string) {
@@ -1,4 +1,4 @@
import { Page, Locator } from '@playwright/test'; import { Page, Locator, expect } from '@playwright/test';
export class MenuManagementPage { export class MenuManagementPage {
readonly page: Page; readonly page: Page;
@@ -24,8 +24,24 @@ export class MenuManagementPage {
} }
async goto() { async goto() {
try {
console.log('导航到菜单管理页面...');
await this.page.goto('/menus'); await this.page.goto('/menus');
await this.page.waitForLoadState('networkidle'); await this.page.waitForLoadState('networkidle');
await this.page.waitForSelector('.el-tree', { timeout: 10000 }).catch(() => {
return this.page.waitForSelector('.el-table', { timeout: 5000 });
});
await expect(this.page).toHaveURL(/.*menus/);
console.log('菜单管理页面加载完成');
} catch (error) {
await this.page.screenshot({ path: `test-results/menu-management-error-${Date.now()}.png` });
console.error('导航到菜单管理页面失败:', error);
throw new Error(`导航到菜单管理页面失败: ${error instanceof Error ? error.message : String(error)}`);
}
} }
async clickCreateMenu() { async clickCreateMenu() {
@@ -16,8 +16,20 @@ export class OperationLogPage {
} }
async goto() { async goto() {
try {
console.log('导航到操作日志页面...');
await this.page.goto('/oplog'); await this.page.goto('/oplog');
await this.page.waitForLoadState('networkidle'); await this.page.waitForLoadState('networkidle');
await this.table.waitFor({ state: 'visible', timeout: 10000 });
await expect(this.page).toHaveURL(/.*oplog/);
console.log('操作日志页面加载完成');
} catch (error) {
await this.page.screenshot({ path: `test-results/operation-log-error-${Date.now()}.png` });
console.error('导航到操作日志页面失败:', error);
throw new Error(`导航到操作日志页面失败: ${error instanceof Error ? error.message : String(error)}`);
}
} }
async searchByKeyword(keyword: string) { async searchByKeyword(keyword: string) {
@@ -32,8 +32,20 @@ export class SystemConfigPage {
} }
async goto() { async goto() {
try {
console.log('导航到系统配置页面...');
await this.page.goto('/sys/config'); await this.page.goto('/sys/config');
await this.page.waitForLoadState('networkidle'); await this.page.waitForLoadState('networkidle');
await this.table.waitFor({ state: 'visible', timeout: 10000 });
await expect(this.page).toHaveURL(/.*config/);
console.log('系统配置页面加载完成');
} catch (error) {
await this.page.screenshot({ path: `test-results/system-config-error-${Date.now()}.png` });
console.error('导航到系统配置页面失败:', error);
throw new Error(`导航到系统配置页面失败: ${error instanceof Error ? error.message : String(error)}`);
}
} }
async addConfig(configName: string, configKey: string, configValue: string, configType: string = 'Y') { async addConfig(configName: string, configKey: string, configValue: string, configType: string = 'Y') {