c50ccd258f
refactor(tests): 将e2e_tests迁移到tests_suite和api_integration_tests style: 为Java类添加文档注释 docs: 更新.gitignore和配置文件 test: 添加性能测试和Playwright测试脚本 chore: 清理旧测试文件和配置
79 lines
2.7 KiB
TypeScript
79 lines
2.7 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('角色管理 E2E 测试', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('/login');
|
|
await page.fill('input[placeholder*="用户名"]', 'admin');
|
|
await page.fill('input[type="password"]', 'admin123');
|
|
await page.click('button:has-text("登录")');
|
|
await page.waitForURL('**/dashboard');
|
|
});
|
|
|
|
test('创建角色完整流程', async ({ page }) => {
|
|
await page.click('text=角色管理');
|
|
await page.waitForURL('**/roles');
|
|
|
|
await page.click('text=创建角色');
|
|
|
|
const timestamp = Date.now();
|
|
const roleName = `测试角色_${timestamp}`;
|
|
const roleKey = `test_role_${timestamp}`;
|
|
|
|
await page.fill('input[name="roleName"]', roleName);
|
|
await page.fill('input[name="roleKey"]', roleKey);
|
|
await page.fill('input[name="roleSort"]', '1');
|
|
|
|
await page.click('input[type="checkbox"][value="user:view"]');
|
|
await page.click('input[type="checkbox"][value="user:create"]');
|
|
|
|
await page.click('button[type="submit"]');
|
|
|
|
await expect(page.locator('.success-message')).toBeVisible();
|
|
await expect(page.locator('table')).toContainText(roleName);
|
|
});
|
|
|
|
test('编辑角色流程', async ({ page }) => {
|
|
await page.click('text=角色管理');
|
|
await page.waitForURL('**/roles');
|
|
|
|
await page.click('table tbody tr:first-child .edit-button');
|
|
|
|
await page.fill('input[name="roleName"]', '更新后的角色名称');
|
|
|
|
await page.click('button[type="submit"]');
|
|
|
|
await expect(page.locator('.success-message')).toBeVisible();
|
|
await expect(page.locator('table')).toContainText('更新后的角色名称');
|
|
});
|
|
|
|
test('分配权限流程', async ({ page }) => {
|
|
await page.click('text=角色管理');
|
|
await page.waitForURL('**/roles');
|
|
|
|
await page.click('table tbody tr:first-child .permission-button');
|
|
|
|
await page.click('input[type="checkbox"][value="user:edit"]');
|
|
await page.click('input[type="checkbox"][value="user:delete"]');
|
|
|
|
await page.click('.permission-dialog .save-button');
|
|
|
|
await expect(page.locator('.success-message')).toBeVisible();
|
|
});
|
|
|
|
test('删除角色流程', async ({ page }) => {
|
|
await page.click('text=角色管理');
|
|
await page.waitForURL('**/roles');
|
|
|
|
const firstRow = page.locator('table tbody tr:first-child');
|
|
const roleName = await firstRow.locator('td:first-child').textContent();
|
|
|
|
await firstRow.locator('.delete-button').click();
|
|
|
|
await page.click('.confirm-dialog .confirm-button');
|
|
|
|
await expect(page.locator('.success-message')).toBeVisible();
|
|
|
|
await page.reload();
|
|
await expect(page.locator('table')).not.toContainText(roleName);
|
|
});
|
|
}); |