be5d5ede90
refactor: 重构后端查询逻辑和API响应处理 fix: 修复用户角色更新和文件上传问题 test: 添加前端性能测试脚本和E2E测试用例 chore: 更新依赖版本和配置文件 docs: 添加环境检查脚本和测试文档 style: 统一表格标签样式和路由命名 perf: 优化前端页面加载速度和响应时间
92 lines
2.9 KiB
TypeScript
92 lines
2.9 KiB
TypeScript
import { Page, expect } from '@playwright/test';
|
|
|
|
export class NotificationPage {
|
|
readonly page: Page;
|
|
readonly table;
|
|
readonly addButton;
|
|
readonly editButton;
|
|
readonly deleteButton;
|
|
readonly saveButton;
|
|
readonly cancelButton;
|
|
readonly searchInput;
|
|
readonly searchButton;
|
|
readonly titleInput;
|
|
readonly contentInput;
|
|
readonly typeSelect;
|
|
readonly statusSelect;
|
|
|
|
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.titleInput = page.getByPlaceholder('请输入通知标题');
|
|
this.contentInput = page.getByPlaceholder('请输入通知内容');
|
|
this.typeSelect = page.locator('.el-select');
|
|
this.statusSelect = page.locator('.el-select');
|
|
}
|
|
|
|
async goto() {
|
|
await this.page.goto('/system/notice');
|
|
await this.page.waitForLoadState('networkidle');
|
|
}
|
|
|
|
async addNotification(title: string, content: string, type: string = '1', status: string = '0') {
|
|
await this.addButton.click();
|
|
|
|
await this.titleInput.fill(title);
|
|
await this.contentInput.fill(content);
|
|
|
|
await this.saveButton.click();
|
|
await this.page.waitForLoadState('networkidle');
|
|
}
|
|
|
|
async editNotification(title: string, newContent: string) {
|
|
const row = this.table.locator('tr').filter({ hasText: title }).first();
|
|
await row.locator('.el-button--primary').click();
|
|
|
|
await this.contentInput.clear();
|
|
await this.contentInput.fill(newContent);
|
|
|
|
await this.saveButton.click();
|
|
await this.page.waitForLoadState('networkidle');
|
|
}
|
|
|
|
async deleteNotification(title: string) {
|
|
const row = this.table.locator('tr').filter({ hasText: title }).first();
|
|
await row.locator('.el-button--danger').click();
|
|
|
|
await this.saveButton.click();
|
|
await this.page.waitForLoadState('networkidle');
|
|
}
|
|
|
|
async searchNotification(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 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;
|
|
}
|
|
} |