refactor(security): 重构安全配置并优化测试环境
- 移除旧的测试套件和UAT测试文件 - 更新密码编码器配置使用BCrypt strength=12 - 添加用户角色关联表和相关服务 - 优化前端日期显示格式 - 清理无用资源和配置文件 - 增强测试数据管理和清理功能
This commit is contained in:
@@ -12,6 +12,11 @@ export class RoleManagementPage {
|
||||
readonly remarkInput: Locator;
|
||||
readonly permissionDialog: Locator;
|
||||
readonly savePermissionButton: Locator;
|
||||
readonly searchInput: Locator;
|
||||
readonly searchButton: Locator;
|
||||
readonly pagination: Locator;
|
||||
readonly nextPageButton: Locator;
|
||||
readonly prevPageButton: Locator;
|
||||
|
||||
constructor(page: Page) {
|
||||
this.page = page;
|
||||
@@ -25,6 +30,11 @@ export class RoleManagementPage {
|
||||
this.remarkInput = page.locator('textarea[placeholder*="备注"]').or(page.locator('textarea[name*="remark"]'));
|
||||
this.permissionDialog = page.locator('.permission-dialog').or(page.locator('.el-dialog'));
|
||||
this.savePermissionButton = page.getByRole('button', { name: '保存' }).or(page.locator('.permission-dialog .save-button'));
|
||||
this.searchInput = page.locator('input[placeholder*="搜索角色名称或标识"]').or(page.locator('input[name*="keyword"]'));
|
||||
this.searchButton = page.getByRole('button', { name: '搜索' }).or(page.locator('button:has-text("搜索")'));
|
||||
this.pagination = page.locator('.el-pagination').or(page.locator('.pagination'));
|
||||
this.nextPageButton = page.locator('.el-pagination .btn-next').or(page.locator('.pagination .next-page'));
|
||||
this.prevPageButton = page.locator('.el-pagination .btn-prev').or(page.locator('.pagination .prev-page'));
|
||||
}
|
||||
|
||||
async goto() {
|
||||
@@ -46,6 +56,40 @@ export class RoleManagementPage {
|
||||
}) {
|
||||
await this.page.locator('.el-dialog').locator('input').first().fill(roleData.roleName);
|
||||
await this.page.locator('.el-dialog').locator('input').nth(1).fill(roleData.roleKey);
|
||||
|
||||
if (roleData.roleSort) {
|
||||
const sortInput = this.page.locator('.el-dialog').locator('.el-input-number');
|
||||
if (await sortInput.count() > 0) {
|
||||
const input = sortInput.locator('input');
|
||||
await input.fill(roleData.roleSort);
|
||||
}
|
||||
}
|
||||
|
||||
if (roleData.status) {
|
||||
const statusSelect = this.page.locator('.el-dialog').locator('.el-form-item').filter({ hasText: '状态' }).locator('.el-select');
|
||||
if (await statusSelect.count() > 0) {
|
||||
await statusSelect.click();
|
||||
await this.page.waitForTimeout(500);
|
||||
|
||||
const statusText = roleData.status === 'ACTIVE' ? '正常' : '禁用';
|
||||
const dropdown = this.page.locator('.el-select-dropdown');
|
||||
if (await dropdown.count() > 0) {
|
||||
const options = dropdown.locator('.el-select-dropdown__item');
|
||||
const optionCount = await options.count();
|
||||
|
||||
for (let i = 0; i < optionCount; i++) {
|
||||
const optionText = await options.nth(i).textContent();
|
||||
if (optionText && optionText.includes(statusText)) {
|
||||
await options.nth(i).click();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await this.page.waitForTimeout(300);
|
||||
}
|
||||
}
|
||||
|
||||
if (roleData.remark) {
|
||||
await this.page.locator('.el-dialog').locator('textarea').fill(roleData.remark);
|
||||
}
|
||||
@@ -98,4 +142,57 @@ export class RoleManagementPage {
|
||||
async getRoleName(rowNumber: number): Promise<string | null> {
|
||||
return await this.table.locator(`tbody tr:nth-child(${rowNumber}) td:first-child`).textContent();
|
||||
}
|
||||
|
||||
async clickPermissionButton(rowNumber: number) {
|
||||
await this.table.locator(`tbody tr:nth-child(${rowNumber})`).getByRole('button', { name: '权限' }).or(this.page.locator(`tbody tr:nth-child(${rowNumber}) .permission-button`)).click();
|
||||
}
|
||||
|
||||
async deselectPermission(permissionValue: string) {
|
||||
const checkbox = this.page.locator(`input[type="checkbox"][value="${permissionValue}"]`);
|
||||
if (await checkbox.isChecked()) {
|
||||
await checkbox.click();
|
||||
}
|
||||
}
|
||||
|
||||
async search(keyword: string) {
|
||||
await this.searchInput.fill(keyword);
|
||||
await this.searchButton.click();
|
||||
}
|
||||
|
||||
async clearSearch() {
|
||||
await this.searchInput.fill('');
|
||||
await this.searchButton.click();
|
||||
}
|
||||
|
||||
async clickStatusButton(rowNumber: number) {
|
||||
const row = this.table.locator(`tbody tr:nth-child(${rowNumber})`);
|
||||
await row.locator('.el-button--text').filter({ hasText: /状态|启用|禁用/ }).first().click();
|
||||
}
|
||||
|
||||
async getCurrentPage(): Promise<string> {
|
||||
try {
|
||||
const activePage = this.page.locator('.el-pager li.is-active');
|
||||
if (await activePage.count() > 0) {
|
||||
return await activePage.textContent() || '1';
|
||||
}
|
||||
|
||||
const currentPage = this.page.locator('.el-pagination__current');
|
||||
if (await currentPage.count() > 0) {
|
||||
return await currentPage.textContent() || '1';
|
||||
}
|
||||
|
||||
return '1';
|
||||
} catch (error) {
|
||||
console.log('获取当前页码失败,返回默认值');
|
||||
return '1';
|
||||
}
|
||||
}
|
||||
|
||||
async nextPage() {
|
||||
await this.nextPageButton.click();
|
||||
}
|
||||
|
||||
async prevPage() {
|
||||
await this.prevPageButton.click();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user