Files
novalon-manage-system/novalon-manage-web/e2e/pages/FileManagementPage.ts
T
张翔 af44c23f21 refactor(security): 重构安全配置并优化测试环境
- 移除旧的测试套件和UAT测试文件
- 更新密码编码器配置使用BCrypt strength=12
- 添加用户角色关联表和相关服务
- 优化前端日期显示格式
- 清理无用资源和配置文件
- 增强测试数据管理和清理功能
2026-03-27 13:00:22 +08:00

95 lines
2.9 KiB
TypeScript

import { Page, expect } from '@playwright/test';
export class FileManagementPage {
readonly page: Page;
readonly uploadButton;
readonly fileInput;
readonly table;
readonly deleteButton;
readonly downloadButton;
readonly searchInput;
constructor(page: Page) {
this.page = page;
this.uploadButton = page.locator('.el-upload--text').first();
this.fileInput = page.locator('input[type="file"]');
this.table = page.locator('.el-table');
this.deleteButton = page.getByRole('button', { name: '删除' });
this.downloadButton = page.getByRole('button', { name: '下载' });
this.searchInput = page.locator('.search-bar .el-input__inner');
}
async goto() {
await this.page.goto('/files');
await this.page.waitForLoadState('networkidle');
await this.page.waitForTimeout(3000);
}
async uploadFile(filePath: string) {
await this.uploadButton.waitFor({ state: 'visible', timeout: 10000 });
await this.uploadButton.click();
const fileInput = this.page.locator('input[type="file"]');
await fileInput.setInputFiles(filePath);
await this.page.waitForTimeout(1000);
}
async deleteFile(fileName: string) {
const row = this.table.locator('tr').filter({ hasText: fileName }).first();
await row.locator('.el-button--danger').click();
const confirmButton = this.page.getByRole('button', { name: '确定' });
await confirmButton.click();
await this.page.waitForLoadState('networkidle');
}
async downloadFile(fileName: string) {
const row = this.table.locator('tr').filter({ hasText: fileName }).first();
const downloadButton = row.locator('.el-button--primary').first();
await downloadButton.click();
}
async searchFile(keyword: string) {
await this.searchInput.fill(keyword);
await this.page.waitForTimeout(500);
}
async clearSearch() {
await this.searchInput.clear();
await this.page.waitForTimeout(500);
}
async verifyTableContains(text: string) {
await expect(this.table).toContainText(text);
}
async verifyTableNotContains(text: string) {
await expect(this.table).not.toContainText(text);
}
async getTableRowCount() {
const rows = await this.table.locator('.el-table__row').count();
return rows;
}
async clickUploadButton() {
await this.uploadButton.waitFor({ state: 'visible', timeout: 10000 });
await this.uploadButton.click();
}
async submitUpload() {
const confirmButton = this.page.getByRole('button', { name: '确定' }).or(this.page.locator('.el-dialog .el-button--primary'));
await confirmButton.click();
}
async clickDeleteButton(rowNumber: number) {
const row = this.table.locator(`tbody tr:nth-child(${rowNumber})`);
await row.locator('.el-button--danger').click();
}
async clickDownloadButton(rowNumber: number) {
const row = this.table.locator(`tbody tr:nth-child(${rowNumber})`);
await row.locator('.el-button--primary').first().click();
}
}