refactor(security): 重构安全配置并优化测试环境

- 移除旧的测试套件和UAT测试文件
- 更新密码编码器配置使用BCrypt strength=12
- 添加用户角色关联表和相关服务
- 优化前端日期显示格式
- 清理无用资源和配置文件
- 增强测试数据管理和清理功能
This commit is contained in:
张翔
2026-03-27 13:00:22 +08:00
parent ce30893a96
commit af44c23f21
294 changed files with 16057 additions and 22601 deletions
@@ -1,90 +1,183 @@
import { Page, expect } from '@playwright/test';
import { Page, Locator } from '@playwright/test';
export class DictionaryManagementPage {
readonly page: Page;
readonly table;
readonly addButton;
readonly editButton;
readonly deleteButton;
readonly saveButton;
readonly cancelButton;
readonly searchInput;
readonly searchButton;
readonly dictNameInput;
readonly dictTypeInput;
readonly dictStatusSelect;
readonly table: Locator;
readonly createDictTypeButton: Locator;
readonly createDictDataButton: Locator;
readonly searchInput: Locator;
readonly searchButton: Locator;
readonly successMessage: Locator;
readonly dictTypeTable: Locator;
readonly dictDataTable: Locator;
constructor(page: Page) {
this.page = page;
this.table = page.locator('.el-table');
this.addButton = page.getByRole('button', { name: '新增字典' });
this.editButton = page.getByRole('button', { name: '编辑' });
this.deleteButton = page.getByRole('button', { name: '删除' });
this.saveButton = page.getByRole('button', { name: '确定' });
this.cancelButton = page.getByRole('button', { name: '取消' });
this.searchInput = page.getByPlaceholder('搜索字典名称');
this.searchButton = page.getByRole('button', { name: '搜索' });
this.dictNameInput = page.getByPlaceholder('请输入字典名称');
this.dictTypeInput = page.getByPlaceholder('请输入字典类型');
this.dictStatusSelect = page.locator('.el-select');
this.table = page.locator('.el-table').or(page.locator('.dict-table'));
this.createDictTypeButton = page.getByRole('button', { name: '新增字典类型' }).or(page.locator('button:has-text("新增字典类型")'));
this.createDictDataButton = page.getByRole('button', { name: '新增字典数据' }).or(page.locator('button:has-text("新增字典数据")'));
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.successMessage = page.locator('.el-message--success').or(page.locator('.success-message'));
this.dictTypeTable = page.locator('.dict-type-table').or(page.locator('.el-table').first());
this.dictDataTable = page.locator('.dict-data-table').or(page.locator('.el-table').nth(1));
}
async goto() {
await this.page.goto('/system/dict');
await this.page.goto('/dict');
await this.page.waitForLoadState('networkidle');
}
async addDictionary(dictName: string, dictType: string, status: string = '0') {
await this.addButton.click();
await this.dictNameInput.fill(dictName);
await this.dictTypeInput.fill(dictType);
await this.saveButton.click();
await this.page.waitForLoadState('networkidle');
async clickCreateDictType() {
await this.createDictTypeButton.click();
await this.page.waitForTimeout(500);
}
async editDictionary(dictType: string, newName: string) {
const row = this.table.locator('tr').filter({ hasText: dictType }).first();
await row.locator('.el-button--primary').click();
await this.dictNameInput.clear();
await this.dictNameInput.fill(newName);
await this.saveButton.click();
await this.page.waitForLoadState('networkidle');
async clickCreateDictData() {
await this.createDictDataButton.click();
await this.page.waitForTimeout(500);
}
async deleteDictionary(dictType: string) {
const row = this.table.locator('tr').filter({ hasText: dictType }).first();
await row.locator('.el-button--danger').click();
async fillDictTypeForm(dictTypeData: {
dictName: string;
dictType: string;
status?: string;
remark?: string;
}) {
const dialog = this.page.locator('.el-dialog');
await this.saveButton.click();
await this.page.waitForLoadState('networkidle');
await dialog.locator('input').first().fill(dictTypeData.dictName);
await dialog.locator('input').nth(1).fill(dictTypeData.dictType);
if (dictTypeData.status) {
const statusRadio = dialog.locator(`input[value="${dictTypeData.status}"]`);
if (await statusRadio.count() > 0) {
await statusRadio.check();
}
}
if (dictTypeData.remark) {
const remarkInput = dialog.locator('textarea');
if (await remarkInput.count() > 0) {
await remarkInput.fill(dictTypeData.remark);
}
}
}
async searchDictionary(keyword: string) {
async fillDictDataForm(dictData: {
dictLabel: string;
dictValue: string;
dictType?: string;
cssClass?: string;
listClass?: string;
isDefault?: string;
status?: string;
sort?: number;
}) {
const dialog = this.page.locator('.el-dialog');
await dialog.locator('input').first().fill(dictData.dictLabel);
await dialog.locator('input').nth(1).fill(dictData.dictValue);
if (dictData.dictType) {
const dictTypeSelect = dialog.locator('.el-select');
if (await dictTypeSelect.count() > 0) {
await dictTypeSelect.click();
await this.page.waitForTimeout(300);
await this.page.getByRole('option', { name: dictData.dictType }).click();
}
}
if (dictData.cssClass) {
const cssClassInput = dialog.locator('input[placeholder*="CSS"]');
if (await cssClassInput.count() > 0) {
await cssClassInput.fill(dictData.cssClass);
}
}
if (dictData.listClass) {
const listClassInput = dialog.locator('input[placeholder*="列表"]');
if (await listClassInput.count() > 0) {
await listClassInput.fill(dictData.listClass);
}
}
if (dictData.isDefault) {
const defaultRadio = dialog.locator(`input[value="${dictData.isDefault}"]`);
if (await defaultRadio.count() > 0) {
await defaultRadio.check();
}
}
if (dictData.status) {
const statusRadio = dialog.locator(`input[value="${dictData.status}"]`);
if (await statusRadio.count() > 0) {
await statusRadio.check();
}
}
if (dictData.sort !== undefined) {
const sortInput = dialog.locator('input[type="number"]');
if (await sortInput.count() > 0) {
await sortInput.fill(String(dictData.sort));
}
}
}
async submitForm() {
await this.page.getByRole('button', { name: '确定' }).or(this.page.locator('button:has-text("确定")')).click();
}
async editDictType(dictName: string) {
const dictTypeRow = this.dictTypeTable.locator('tbody tr').filter({ hasText: dictName });
await dictTypeRow.getByRole('button', { name: '编辑' }).or(this.page.locator('.edit-button')).click();
}
async editDictData(dictLabel: string) {
const dictDataRow = this.dictDataTable.locator('tbody tr').filter({ hasText: dictLabel });
await dictDataRow.getByRole('button', { name: '编辑' }).or(this.page.locator('.edit-button')).click();
}
async deleteDictType(dictName: string) {
const dictTypeRow = this.dictTypeTable.locator('tbody tr').filter({ hasText: dictName });
await dictTypeRow.getByRole('button', { name: '删除' }).or(this.page.locator('.delete-button')).click();
}
async deleteDictData(dictLabel: string) {
const dictDataRow = this.dictDataTable.locator('tbody tr').filter({ hasText: dictLabel });
await dictDataRow.getByRole('button', { name: '删除' }).or(this.page.locator('.delete-button')).click();
}
async confirmDelete() {
await this.page.getByRole('button', { name: '确定' }).or(this.page.locator('.confirm-dialog .confirm-button')).click();
}
async search(keyword: string) {
await this.searchInput.fill(keyword);
await this.searchButton.click();
await this.page.waitForLoadState('networkidle');
}
async clearSearch() {
await this.searchInput.clear();
await this.searchButton.click();
await this.page.waitForLoadState('networkidle');
async containsText(text: string): Promise<boolean> {
return await this.table.getByText(text).count() > 0;
}
async verifyTableContains(text: string) {
await expect(this.table).toContainText(text);
async isSuccessMessageVisible(): Promise<boolean> {
try {
return await this.successMessage.isVisible({ timeout: 3000 });
} catch {
return false;
}
}
async verifyTableNotContains(text: string) {
await expect(this.table).not.toContainText(text);
async getDictTypeCount(): Promise<number> {
return await this.dictTypeTable.locator('tbody tr').count();
}
async getTableRowCount() {
const rows = await this.table.locator('.el-table__row').count();
return rows;
async getDictDataCount(): Promise<number> {
return await this.dictDataTable.locator('tbody tr').count();
}
}
async reload() {
await this.page.reload();
}
}