import { test, expect } from '@playwright/test';
import { LoginPage } from './pages/LoginPage';
import { DashboardPage } from './pages/DashboardPage';
import { UserManagementPage } from './pages/UserManagementPage';
test.describe('E2E安全测试', () => {
test('SEC-001: XSS攻击防护测试', async ({ page }) => {
const loginPage = new LoginPage(page);
const dashboardPage = new DashboardPage(page);
const userManagementPage = new UserManagementPage(page);
await test.step('1. 管理员登录', async () => {
await loginPage.goto();
await loginPage.login('admin', 'admin123');
await page.waitForURL(/.*dashboard/);
});
await test.step('2. 导航到用户管理', async () => {
await dashboardPage.navigateToUserManagement();
await userManagementPage.clickCreateUser();
});
await test.step('3. 测试XSS payload防护', async () => {
const xssPayloads = [
'',
'
',
'