test: E2E 测试用例更新与新增
- 更新 Page Object 模型适配新字段名 - 新增 UAT 测试套件与 journey 测试用例 - 优化测试辅助工具与数据工厂 - 更新 playwright 认证状态
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { LoginPage } from '../pages/LoginPage';
|
||||
import { DashboardPage } from '../pages/DashboardPage';
|
||||
|
||||
test.describe('UAT: 权限边界与访问控制', () => {
|
||||
test('UAT-PERM-01: 管理员可访问所有菜单', async ({ page }) => {
|
||||
const loginPage = new LoginPage(page);
|
||||
|
||||
await loginPage.goto();
|
||||
await loginPage.login('admin', 'Test@123');
|
||||
await expect(page).toHaveURL(/.*dashboard/);
|
||||
|
||||
const menuItems = page.locator('.ant-menu-submenu-title');
|
||||
const count = await menuItems.count();
|
||||
expect(count).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test('UAT-PERM-02: 未登录用户无法访问任何功能页面', async ({ page }) => {
|
||||
const protectedRoutes = ['/users', '/roles', '/menus', '/dict', '/sys/config', '/oplog', '/loginlog', '/exceptionlog'];
|
||||
|
||||
for (const route of protectedRoutes) {
|
||||
await page.goto(route);
|
||||
await page.waitForTimeout(2000);
|
||||
await expect(page).toHaveURL(/.*login/, { timeout: 5000 });
|
||||
}
|
||||
});
|
||||
|
||||
test('UAT-PERM-03: 登出后无法回退访问受保护页面', async ({ page }) => {
|
||||
const loginPage = new LoginPage(page);
|
||||
|
||||
await loginPage.goto();
|
||||
await loginPage.login('admin', 'Test@123');
|
||||
await expect(page).toHaveURL(/.*dashboard/);
|
||||
|
||||
await loginPage.logout();
|
||||
await expect(page).toHaveURL(/.*login/);
|
||||
|
||||
await page.goBack();
|
||||
await page.waitForTimeout(2000);
|
||||
await expect(page).toHaveURL(/.*login/, { timeout: 5000 });
|
||||
});
|
||||
|
||||
test('UAT-PERM-04: 侧边栏菜单折叠与展开', async ({ page }) => {
|
||||
const loginPage = new LoginPage(page);
|
||||
|
||||
await loginPage.goto();
|
||||
await loginPage.login('admin', 'Test@123');
|
||||
|
||||
const collapseButton = page.locator('.ant-layout-sider-trigger, [class*="sider-trigger"]').first();
|
||||
if (await collapseButton.isVisible()) {
|
||||
await collapseButton.click();
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
const sider = page.locator('.ant-layout-sider-collapsed');
|
||||
const isCollapsed = await sider.count() > 0;
|
||||
expect(typeof isCollapsed).toBe('boolean');
|
||||
|
||||
await collapseButton.click();
|
||||
await page.waitForTimeout(500);
|
||||
}
|
||||
});
|
||||
|
||||
test('UAT-PERM-05: 仪表盘统计卡片可见', async ({ page }) => {
|
||||
const loginPage = new LoginPage(page);
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
|
||||
await loginPage.goto();
|
||||
await loginPage.login('admin', 'Test@123');
|
||||
await expect(page).toHaveURL(/.*dashboard/);
|
||||
|
||||
await expect(page.locator('.ant-statistic').first()).toBeVisible({ timeout: 15000 });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user