101 lines
3.7 KiB
TypeScript
101 lines
3.7 KiB
TypeScript
import { Page, Locator } from '@playwright/test';
|
|
|
|
export class DashboardPage {
|
|
readonly page: Page;
|
|
readonly userInfo: Locator;
|
|
readonly userManagementLink: Locator;
|
|
readonly roleManagementLink: Locator;
|
|
readonly menuManagementLink: Locator;
|
|
readonly systemConfigLink: Locator;
|
|
readonly noticeManagementLink: Locator;
|
|
readonly fileManagementLink: Locator;
|
|
readonly operationLogLink: Locator;
|
|
readonly loginLogLink: Locator;
|
|
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
this.userInfo = page.locator('.el-avatar');
|
|
this.userManagementLink = page.getByRole('menuitem', { name: '用户管理' });
|
|
this.roleManagementLink = page.getByRole('menuitem', { name: '角色管理' });
|
|
this.menuManagementLink = page.getByRole('menuitem', { name: '菜单管理' });
|
|
this.systemConfigLink = page.getByRole('menuitem', { name: '参数配置' });
|
|
this.noticeManagementLink = page.getByRole('menuitem', { name: '通知公告' });
|
|
this.fileManagementLink = page.getByRole('menuitem', { name: '文件列表' });
|
|
this.operationLogLink = page.getByRole('menuitem', { name: '操作日志' });
|
|
this.loginLogLink = page.getByRole('menuitem', { name: '登录日志' });
|
|
}
|
|
|
|
async goto() {
|
|
await this.page.goto('/dashboard');
|
|
await this.page.waitForLoadState('networkidle');
|
|
}
|
|
|
|
async navigateToUserManagement() {
|
|
const systemMenu = this.page.locator('.el-sub-menu').filter({ hasText: '系统管理' });
|
|
await systemMenu.click();
|
|
await this.page.waitForTimeout(500);
|
|
await this.userManagementLink.click();
|
|
await this.page.waitForURL('**/users');
|
|
}
|
|
|
|
async navigateToRoleManagement() {
|
|
const systemMenu = this.page.locator('.el-sub-menu').filter({ hasText: '系统管理' });
|
|
await systemMenu.click();
|
|
await this.page.waitForTimeout(500);
|
|
await this.roleManagementLink.click();
|
|
await this.page.waitForURL('**/roles');
|
|
}
|
|
|
|
async navigateToMenuManagement() {
|
|
const systemMenu = this.page.locator('.el-sub-menu').filter({ hasText: '系统管理' });
|
|
await systemMenu.click();
|
|
await this.page.waitForTimeout(500);
|
|
await this.menuManagementLink.click();
|
|
await this.page.waitForURL('**/menus');
|
|
}
|
|
|
|
async navigateToSystemConfig() {
|
|
const configMenu = this.page.locator('.el-sub-menu').filter({ hasText: '系统配置' });
|
|
await configMenu.click();
|
|
await this.page.waitForTimeout(500);
|
|
await this.systemConfigLink.click();
|
|
await this.page.waitForURL('**/sysconfig');
|
|
}
|
|
|
|
async navigateToNoticeManagement() {
|
|
const notifyMenu = this.page.locator('.el-sub-menu').filter({ hasText: '通知中心' });
|
|
await notifyMenu.click();
|
|
await this.page.waitForTimeout(500);
|
|
await this.noticeManagementLink.click();
|
|
await this.page.waitForURL('**/notice');
|
|
}
|
|
|
|
async navigateToFileManagement() {
|
|
const fileMenu = this.page.locator('.el-sub-menu').filter({ hasText: '文件管理' });
|
|
await fileMenu.click();
|
|
await this.page.waitForTimeout(500);
|
|
await this.fileManagementLink.click();
|
|
await this.page.waitForURL('**/files');
|
|
}
|
|
|
|
async navigateToOperationLog() {
|
|
const auditMenu = this.page.locator('.el-sub-menu').filter({ hasText: '审计中心' });
|
|
await auditMenu.click();
|
|
await this.page.waitForTimeout(500);
|
|
await this.operationLogLink.click();
|
|
await this.page.waitForURL('**/oplog');
|
|
}
|
|
|
|
async navigateToLoginLog() {
|
|
const auditMenu = this.page.locator('.el-sub-menu').filter({ hasText: '审计中心' });
|
|
await auditMenu.click();
|
|
await this.page.waitForTimeout(500);
|
|
await this.loginLogLink.click();
|
|
await this.page.waitForURL('**/loginlog');
|
|
}
|
|
|
|
async getUsername(): Promise<string | null> {
|
|
return await this.userInfo.textContent();
|
|
}
|
|
}
|