Forráskód Böngészése

🐛 fix(e2e): 修复管理后台页面定位器问题

- 登录页面:优化密码显示切换按钮和背景元素定位器
- 仪表板页面:改进用户菜单和登出按钮定位逻辑,提高稳定性

🔧 chore(settings): 更新Bash命令白名单

- 添加"pnpm run"命令到允许列表,支持更多包管理操作
yourname 2 hónapja
szülő
commit
6b0ada0b35

+ 2 - 1
.claude/settings.local.json

@@ -23,7 +23,8 @@
       "Bash(node debug-page.js:*)",
       "Bash(psql:*)",
       "Bash(npx playwright open:*)",
-      "Bash(npx playwright codegen:*)"
+      "Bash(npx playwright codegen:*)",
+      "Bash(pnpm run)"
     ],
     "deny": [],
     "ask": []

+ 3 - 3
tests/e2e/pages/admin/auth/login.page.ts

@@ -22,7 +22,7 @@ export class AdminLoginPage {
     this.usernameInput = page.getByPlaceholder('请输入用户名');
     this.passwordInput = page.getByPlaceholder('请输入密码');
     this.submitButton = page.getByRole('button', { name: '登录' });
-    this.togglePasswordButton = page.locator('button:has(img), [aria-label*="密码"], [aria-label*="显示"], [aria-label*="隐藏"]').nth(1);
+    this.togglePasswordButton = page.locator('button:has(svg)').nth(1);
     this.pageTitle = page.getByRole('heading', { name: '管理后台登录' });
     this.welcomeText = page.getByText('请输入您的账号和密码继续操作');
     this.successToast = page.locator('[data-sonner-toast][data-type="success"]');
@@ -31,8 +31,8 @@ export class AdminLoginPage {
     this.passwordError = page.locator('text=请输入密码');
     this.testAccountInfo = page.locator('text=测试账号:');
     this.loadingSpinner = page.locator('[aria-busy="true"], .loading-spinner, .spinner');
-    this.backgroundElement = page.locator('body, main').first();
-    this.loginCard = page.locator('form, .card, [role="form"]').first();
+    this.backgroundElement = page.locator('div.flex.items-center.justify-center').first();
+    this.loginCard = page.locator('.card').first();
   }
 
   async goto() {

+ 2 - 2
tests/e2e/pages/admin/dashboard.page.ts

@@ -46,11 +46,11 @@ export class DashboardPage {
 
   async logout() {
     // 先点击用户头像/用户名打开下拉菜单
-    const userMenuButton = this.page.locator('button:has-text("admin"), [aria-label*="用户"], [aria-label*="menu"]');
+    const userMenuButton = this.page.getByRole('button', { name: 'admin' });
     await userMenuButton.click();
 
     // 然后查找并点击登出按钮
-    const logoutButton = this.page.locator('button:has-text("登出"), button:has-text("退出"), button:has-text("Logout"), button:has-text("Sign out")');
+    const logoutButton = this.page.getByRole('menuitem', { name: /登出|退出|Logout|Sign out/i });
     await logoutButton.click();
     await this.page.waitForLoadState('networkidle');
   }