|
|
@@ -27,16 +27,42 @@ export class DashboardPage {
|
|
|
}
|
|
|
|
|
|
async navigateToUserManagement() {
|
|
|
- // 使用更具体的定位器来避免重复元素问题
|
|
|
- const userManagementCard = this.page.locator('text=用户管理').first();
|
|
|
- await userManagementCard.click();
|
|
|
+ // 检查是否为移动端,需要先打开菜单
|
|
|
+ const isMobile = (this.page.viewportSize()?.width || 0) < 768;
|
|
|
+
|
|
|
+ if (isMobile) {
|
|
|
+ // 移动端需要先点击菜单按钮 - 使用测试ID
|
|
|
+ const menuButton = this.page.getByTestId('mobile-menu-button');
|
|
|
+ await expect(menuButton).toBeVisible({ timeout: 10000 });
|
|
|
+ await menuButton.click({ timeout: 15000 });
|
|
|
+ await this.page.waitForTimeout(1000); // 等待菜单完全展开
|
|
|
+ }
|
|
|
+
|
|
|
+ // 移动端需要点击侧边栏菜单项,而不是快捷操作卡片
|
|
|
+ const userManagementCard = isMobile
|
|
|
+ ? this.page.getByRole('button', { name: '用户管理' }).first()
|
|
|
+ : this.page.locator('text=用户管理').first();
|
|
|
+
|
|
|
+ await expect(userManagementCard).toBeVisible({ timeout: 10000 });
|
|
|
+ await userManagementCard.click({ timeout: 10000 });
|
|
|
await this.page.waitForLoadState('networkidle');
|
|
|
}
|
|
|
|
|
|
async navigateToSystemSettings() {
|
|
|
+ // 检查是否为移动端,需要先打开菜单
|
|
|
+ const isMobile = (this.page.viewportSize()?.width || 0) < 768;
|
|
|
+
|
|
|
+ if (isMobile) {
|
|
|
+ // 移动端需要先点击菜单按钮 - 使用测试ID
|
|
|
+ const menuButton = this.page.getByTestId('mobile-menu-button');
|
|
|
+ await expect(menuButton).toBeVisible({ timeout: 10000 });
|
|
|
+ await menuButton.click({ timeout: 15000 });
|
|
|
+ await this.page.waitForTimeout(1000); // 等待菜单完全展开
|
|
|
+ }
|
|
|
+
|
|
|
// 使用更具体的定位器来避免重复元素问题
|
|
|
const systemSettingsCard = this.page.locator('text=系统设置').first();
|
|
|
- await systemSettingsCard.click();
|
|
|
+ await systemSettingsCard.click({ timeout: 10000 });
|
|
|
await this.page.waitForLoadState('networkidle');
|
|
|
}
|
|
|
|