test(e2e): 改进 Playwright 测试框架和 E2E 测试
- 更新 Playwright 配置,添加认证状态管理和 setup 项目 - 优化 E2E 测试用例,简化测试流程 - 添加 auth-debug.spec.ts 用于调试认证问题 - 添加 playwright/.auth/user.json 认证状态文件
This commit is contained in:
@@ -28,9 +28,10 @@ export class DictionaryManagementPage {
|
||||
console.log('导航到字典管理页面...');
|
||||
await this.page.goto('/dict');
|
||||
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
await this.table.waitFor({ state: 'visible', timeout: 10000 });
|
||||
await expect(this.page).toHaveURL(/.*dict/);
|
||||
await this.page.waitForLoadState('domcontentloaded');
|
||||
await this.page.waitForTimeout(1000);
|
||||
await this.table.waitFor({ state: 'visible', timeout: 15000 });
|
||||
await expect(this.page).toHaveURL(/.*dict/, { timeout: 15000 });
|
||||
|
||||
console.log('字典管理页面加载完成');
|
||||
} catch (error) {
|
||||
|
||||
@@ -26,13 +26,16 @@ export class ExceptionLogPage {
|
||||
console.log('导航到异常日志页面...');
|
||||
await this.page.goto('/exceptionlog');
|
||||
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
await this.table.waitFor({ state: 'visible', timeout: 10000 });
|
||||
await expect(this.page).toHaveURL(/.*exceptionlog/);
|
||||
await this.page.waitForLoadState('domcontentloaded');
|
||||
await this.page.waitForTimeout(1000);
|
||||
await this.table.waitFor({ state: 'visible', timeout: 15000 });
|
||||
await expect(this.page).toHaveURL(/.*exceptionlog/, { timeout: 15000 });
|
||||
|
||||
console.log('异常日志页面加载完成');
|
||||
} catch (error) {
|
||||
await this.page.screenshot({ path: `test-results/exception-log-error-${Date.now()}.png` });
|
||||
if (!this.page.isClosed()) {
|
||||
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)}`);
|
||||
}
|
||||
|
||||
@@ -30,13 +30,16 @@ export class NotificationPage {
|
||||
console.log('导航到通知管理页面...');
|
||||
await this.page.goto('/notice');
|
||||
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
await this.table.waitFor({ state: 'visible', timeout: 10000 });
|
||||
await expect(this.page).toHaveURL(/.*notice/);
|
||||
await this.page.waitForLoadState('domcontentloaded');
|
||||
await this.page.waitForTimeout(1000);
|
||||
await this.table.waitFor({ state: 'visible', timeout: 15000 });
|
||||
await expect(this.page).toHaveURL(/.*notice/, { timeout: 15000 });
|
||||
|
||||
console.log('通知管理页面加载完成');
|
||||
} catch (error) {
|
||||
await this.page.screenshot({ path: `test-results/notification-error-${Date.now()}.png` });
|
||||
if (!this.page.isClosed()) {
|
||||
await this.page.screenshot({ path: `test-results/notification-error-${Date.now()}.png` });
|
||||
}
|
||||
console.error('导航到通知管理页面失败:', error);
|
||||
throw new Error(`导航到通知管理页面失败: ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,10 @@ export class SystemConfigPage {
|
||||
console.log('导航到系统配置页面...');
|
||||
await this.page.goto('/sys/config');
|
||||
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
await this.table.waitFor({ state: 'visible', timeout: 10000 });
|
||||
await expect(this.page).toHaveURL(/.*config/);
|
||||
await this.page.waitForLoadState('domcontentloaded');
|
||||
await this.page.waitForTimeout(1000);
|
||||
await this.table.waitFor({ state: 'visible', timeout: 15000 });
|
||||
await expect(this.page).toHaveURL(/.*config/, { timeout: 15000 });
|
||||
|
||||
console.log('系统配置页面加载完成');
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user