fix(e2e): 修复测试用例元素定位器问题
问题: - 按钮文本不匹配:测试查找"新建",实际是"新增角色" - 菜单结构不匹配:测试点击父菜单,实际需要点击子菜单 - 菜单名称不匹配:测试查找"系统监控",实际是"审计中心" - 重复登录逻辑:部分测试用例仍在尝试登录 修复: - admin-complete-workflow.spec.ts: 修复按钮文本 - audit-workflow.spec.ts: 修复菜单名称 - system-config-workflow.spec.ts: 修复菜单导航 - file-management-workflow.spec.ts: 修复菜单导航 - user-permission-boundary.spec.ts: 移除重复登录逻辑 优势: - 测试用例与实际页面匹配 - 提高测试稳定性 - 减少测试失败
This commit is contained in:
@@ -18,7 +18,7 @@ test.describe('管理员完整工作流', () => {
|
||||
});
|
||||
|
||||
await test.step('点击创建角色按钮', async () => {
|
||||
await page.locator('button:has-text("新建")').click();
|
||||
await page.locator('button:has-text("新增角色")').click();
|
||||
});
|
||||
|
||||
await test.step('填写角色信息', async () => {
|
||||
|
||||
@@ -19,7 +19,7 @@ test.describe('审计工作流', () => {
|
||||
|
||||
await test.step('导航到操作日志', async () => {
|
||||
await page.goto('/dashboard');
|
||||
await page.locator('text=系统监控').click();
|
||||
await page.locator('text=审计中心').click();
|
||||
await page.locator('text=操作日志').click();
|
||||
await expect(page.locator('table')).toBeVisible();
|
||||
});
|
||||
@@ -34,7 +34,7 @@ test.describe('审计工作流', () => {
|
||||
test('查看登录日志', async ({ page }) => {
|
||||
await test.step('导航到登录日志', async () => {
|
||||
await page.goto('/dashboard');
|
||||
await page.locator('text=系统监控').click();
|
||||
await page.locator('text=审计中心').click();
|
||||
await page.locator('text=登录日志').click();
|
||||
});
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ test.describe('文件管理工作流', () => {
|
||||
test('文件上传流程', async ({ page }) => {
|
||||
await test.step('导航到文件管理', async () => {
|
||||
await page.goto('/dashboard');
|
||||
await page.locator('text=系统管理').click();
|
||||
await page.locator('text=文件管理').click();
|
||||
await page.locator('text=文件列表').click();
|
||||
});
|
||||
|
||||
await test.step('上传文件', async () => {
|
||||
|
||||
@@ -4,8 +4,8 @@ test.describe('系统配置工作流', () => {
|
||||
test('查看系统配置', async ({ page }) => {
|
||||
await test.step('导航到系统配置', async () => {
|
||||
await page.goto('/dashboard');
|
||||
await page.locator('text=系统管理').click();
|
||||
await page.locator('text=系统配置').click();
|
||||
await page.locator('text=参数配置').click();
|
||||
await expect(page).toHaveURL(/.*sys\/config/);
|
||||
});
|
||||
|
||||
|
||||
@@ -2,26 +2,6 @@ import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('用户权限边界验证', () => {
|
||||
test('管理员可以访问所有管理功能', async ({ page }) => {
|
||||
await test.step('管理员登录', async () => {
|
||||
await page.goto('/login');
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
const usernameInput = page.locator('input[placeholder*="用户名"]');
|
||||
const passwordInput = page.locator('input[placeholder*="密码"]');
|
||||
const loginButton = page.locator('button:has-text("登录")');
|
||||
|
||||
await usernameInput.waitFor({ state: 'visible' });
|
||||
await usernameInput.fill('admin');
|
||||
|
||||
await passwordInput.waitFor({ state: 'visible' });
|
||||
await passwordInput.fill('admin123');
|
||||
|
||||
await loginButton.waitFor({ state: 'visible' });
|
||||
await loginButton.click();
|
||||
|
||||
await page.waitForURL('**/dashboard', { timeout: 30000 });
|
||||
});
|
||||
|
||||
await test.step('验证可以访问用户管理', async () => {
|
||||
await page.goto('/users');
|
||||
await expect(page).toHaveURL(/.*users/);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
},
|
||||
{
|
||||
"name": "token",
|
||||
"value": "eyJhbGciOiJIUzM4NCJ9.eyJyb2xlcyI6W10sInVzZXJJZCI6MSwidXNlcm5hbWUiOiJhZG1pbiIsInN1YiI6ImFkbWluIiwiaWF0IjoxNzc1NTMzNzQ5LCJleHAiOjE3NzU2MjAxNDl9.FH-r-jQL6ojOAB0xjxj41mTiVnRl8vhMZ5yRuDjgbjI9Y1AzSLRveN6I7aGToelN"
|
||||
"value": "eyJhbGciOiJIUzM4NCJ9.eyJyb2xlcyI6W10sInVzZXJJZCI6MSwidXNlcm5hbWUiOiJhZG1pbiIsInN1YiI6ImFkbWluIiwiaWF0IjoxNzc1NTM2NDg2LCJleHAiOjE3NzU2MjI4ODZ9.8vPn7-X9UH8g6Bv8qakwamYyjnAXjD8u8NHtLtjSHmLhjfm8e7D4MV_yhjYS6rer"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user