e8f51309e5
- 更新 Page Object 模型适配新字段名 - 新增 UAT 测试套件与 journey 测试用例 - 优化测试辅助工具与数据工厂 - 更新 playwright 认证状态
98 lines
3.3 KiB
TypeScript
98 lines
3.3 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { LoginPage } from '../pages/LoginPage';
|
|
import { DashboardPage } from '../pages/DashboardPage';
|
|
|
|
test.describe('UAT: UI 一致性与响应性验收', () => {
|
|
test('UAT-UI-01: 登录页面布局一致性', async ({ page }) => {
|
|
const loginPage = new LoginPage(page);
|
|
await loginPage.goto();
|
|
|
|
await expect(page.locator('input[placeholder="用户名"]')).toBeVisible();
|
|
await expect(page.locator('input[placeholder="密码"]')).toBeVisible();
|
|
await expect(page.locator('button:has-text("登录")')).toBeVisible();
|
|
|
|
const bodyWidth = await page.evaluate(() => document.body.offsetWidth);
|
|
expect(bodyWidth).toBeGreaterThan(0);
|
|
});
|
|
|
|
test('UAT-UI-02: 仪表盘布局一致性', async ({ page }) => {
|
|
const loginPage = new LoginPage(page);
|
|
await loginPage.goto();
|
|
await loginPage.login('admin', 'admin123');
|
|
|
|
await expect(page.locator('.ant-layout')).toBeVisible();
|
|
await expect(page.locator('.ant-layout-sider')).toBeVisible({ timeout: 10000 });
|
|
await expect(page.locator('.ant-layout-header')).toBeVisible({ timeout: 10000 });
|
|
await expect(page.locator('.ant-layout-content')).toBeVisible({ timeout: 10000 });
|
|
});
|
|
|
|
test('UAT-UI-03: 表格分页功能', async ({ page }) => {
|
|
const loginPage = new LoginPage(page);
|
|
await loginPage.goto();
|
|
await loginPage.login('admin', 'admin123');
|
|
|
|
await page.goto('/users');
|
|
await page.waitForLoadState('networkidle');
|
|
await page.waitForTimeout(1000);
|
|
|
|
const pagination = page.locator('.ant-pagination');
|
|
if (await pagination.isVisible()) {
|
|
await expect(pagination).toBeVisible();
|
|
const nextButton = pagination.locator('.ant-pagination-next');
|
|
if (await nextButton.isEnabled()) {
|
|
await nextButton.click();
|
|
await page.waitForLoadState('networkidle');
|
|
await page.waitForTimeout(1000);
|
|
}
|
|
}
|
|
});
|
|
|
|
test('UAT-UI-04: 面包屑导航', async ({ page }) => {
|
|
const loginPage = new LoginPage(page);
|
|
await loginPage.goto();
|
|
await loginPage.login('admin', 'admin123');
|
|
|
|
await page.goto('/users');
|
|
await page.waitForLoadState('networkidle');
|
|
|
|
const breadcrumb = page.locator('.ant-breadcrumb');
|
|
if (await breadcrumb.isVisible()) {
|
|
await expect(breadcrumb).toBeVisible();
|
|
}
|
|
});
|
|
|
|
test('UAT-UI-05: 全局消息提示样式', async ({ page }) => {
|
|
const loginPage = new LoginPage(page);
|
|
await loginPage.goto();
|
|
await loginPage.login('admin', 'admin123');
|
|
|
|
await page.goto('/users');
|
|
await page.waitForLoadState('networkidle');
|
|
|
|
const table = page.locator('.ant-table').first();
|
|
if (await table.isVisible()) {
|
|
await expect(table).toBeVisible();
|
|
}
|
|
});
|
|
|
|
test('UAT-UI-06: 页面标题一致性', async ({ page }) => {
|
|
const loginPage = new LoginPage(page);
|
|
await loginPage.goto();
|
|
await loginPage.login('admin', 'admin123');
|
|
|
|
const routes = [
|
|
{ path: '/dashboard', title: /仪表盘|Dashboard/ },
|
|
{ path: '/users', title: /用户/ },
|
|
{ path: '/roles', title: /角色/ },
|
|
];
|
|
|
|
for (const route of routes) {
|
|
await page.goto(route.path);
|
|
await page.waitForLoadState('networkidle');
|
|
await page.waitForTimeout(1000);
|
|
const pageTitle = await page.title();
|
|
expect(pageTitle.length).toBeGreaterThan(0);
|
|
}
|
|
});
|
|
});
|