Files
gym-manage/gym-manage-web/e2e/pages/DashboardPage.ts
T

179 lines
7.0 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;
readonly dictionaryLink: Locator;
constructor(page: Page) {
this.page = page;
this.userInfo = page.locator('.el-avatar');
this.userManagementLink = page.locator('.el-menu-item:has-text("用户管理")');
this.roleManagementLink = page.locator('.el-menu-item:has-text("角色管理")');
this.menuManagementLink = page.locator('.el-menu-item:has-text("菜单管理")');
this.systemConfigLink = page.locator('.el-menu-item:has-text("参数配置")');
this.noticeManagementLink = page.locator('.el-menu-item:has-text("通知公告")');
this.fileManagementLink = page.locator('.el-menu-item:has-text("文件列表")');
this.operationLogLink = page.locator('.el-menu-item:has-text("操作日志")');
this.loginLogLink = page.locator('.el-menu-item:has-text("登录日志")');
this.dictionaryLink = page.locator('.el-menu-item:has-text("字典管理")');
}
async goto() {
await this.page.goto('/dashboard');
await this.page.waitForLoadState('networkidle');
}
async navigateToUserManagement() {
const systemMenu = this.page.locator('.el-sub-menu__title:has-text("系统管理")');
await systemMenu.click();
await this.page.waitForTimeout(1000);
await this.userManagementLink.click();
await this.page.waitForURL('**/users', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
async navigateToRoleManagement() {
const systemMenu = this.page.locator('.el-sub-menu__title:has-text("系统管理")');
await systemMenu.click();
await this.page.waitForTimeout(1000);
await this.roleManagementLink.click();
await this.page.waitForURL('**/roles', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
async navigateToMenuManagement() {
const systemMenu = this.page.locator('.el-sub-menu__title:has-text("系统管理")');
await systemMenu.click();
await this.page.waitForTimeout(1000);
await this.menuManagementLink.click();
await this.page.waitForURL('**/menus', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
async navigateToSystemConfig() {
const configMenu = this.page.locator('.el-sub-menu__title:has-text("系统配置")');
await configMenu.click();
await this.page.waitForTimeout(1000);
await this.systemConfigLink.click();
await this.page.waitForURL('**/sys/config', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
async navigateToNoticeManagement() {
const notifyMenu = this.page.locator('.el-sub-menu__title:has-text("通知中心")');
await notifyMenu.click();
await this.page.waitForTimeout(1000);
await this.noticeManagementLink.click();
await this.page.waitForURL('**/notice', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
async navigateToFileManagement() {
const fileMenu = this.page.locator('.el-sub-menu__title:has-text("文件管理")');
await fileMenu.click();
await this.page.waitForTimeout(1000);
await this.fileManagementLink.click();
await this.page.waitForURL('**/files', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
async navigateToAudit() {
const auditMenu = this.page.locator('.el-sub-menu__title:has-text("审计中心")');
await auditMenu.click();
await this.page.waitForTimeout(1000);
}
async navigateToOperationLog() {
await this.navigateToAudit();
await this.operationLogLink.click();
await this.page.waitForURL('**/oplog', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
async navigateToLoginLog() {
await this.navigateToAudit();
await this.loginLogLink.click();
await this.page.waitForURL('**/loginlog', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
async navigateToNotification() {
const notifyMenu = this.page.locator('.el-sub-menu__title:has-text("通知中心")');
await notifyMenu.click();
await this.page.waitForTimeout(1000);
await this.noticeManagementLink.click();
await this.page.waitForURL('**/notification', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
async navigateToDictionary() {
const configMenu = this.page.locator('.el-sub-menu__title:has-text("系统配置")');
await configMenu.click();
await this.page.waitForTimeout(1000);
await this.dictionaryLink.click();
await this.page.waitForURL('**/dict', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
// ============================================
// Gym 业务模块导航方法
// ============================================
async navigateToMemberManagement() {
const memberMenu = this.page.locator('.el-sub-menu__title:has-text("会员管理")');
await memberMenu.click();
await this.page.waitForTimeout(1000);
const memberMenuItem = this.page.locator('.el-menu-item:has-text("会员管理")');
await memberMenuItem.click();
await this.page.waitForURL('**/members', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
async navigateToGroupCourseManagement() {
const courseMenu = this.page.locator('.el-sub-menu__title:has-text("团课管理")');
await courseMenu.click();
await this.page.waitForTimeout(1000);
const courseMenuItem = this.page.locator('.el-menu-item:has-text("团课管理")');
await courseMenuItem.click();
await this.page.waitForURL('**/group-courses', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
async navigateToCoachManagement() {
const coachMenuItem = this.page.locator('.el-menu-item:has-text("教练管理")');
await coachMenuItem.click();
await this.page.waitForURL('**/coaches', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
async navigateToCheckInManagement() {
const checkInMenuItem = this.page.locator('.el-menu-item:has-text("签到管理")');
await checkInMenuItem.click();
await this.page.waitForURL('**/checkin', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
async navigateToStatisticsDashboard() {
const statsMenu = this.page.locator('.el-sub-menu__title:has-text("数据统计")');
await statsMenu.click();
await this.page.waitForTimeout(1000);
const statsMenuItem = this.page.locator('.el-menu-item:has-text("数据统计看板")');
await statsMenuItem.click();
await this.page.waitForURL('**/statistics', { timeout: 30000 });
await this.page.waitForLoadState('networkidle');
}
async getUsername(): Promise<string | null> {
return await this.userInfo.textContent();
}
}