d2cef85187
- Add comprehensive test report (TEST_REPORT.md) - Add database reset scripts for testing - Update .gitignore to exclude temporary files - Add frontend e2e test utilities and configuration
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import { Page, expect } from '@playwright/test';
|
|
|
|
export class LoginLogPage {
|
|
readonly page: Page;
|
|
readonly searchInput;
|
|
readonly searchButton;
|
|
readonly table;
|
|
readonly exportButton;
|
|
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
this.searchInput = page.getByPlaceholder('搜索用户名或IP地址');
|
|
this.searchButton = page.getByRole('button', { name: '搜索' });
|
|
this.table = page.locator('.el-table');
|
|
this.exportButton = page.getByRole('button', { name: '导出' });
|
|
}
|
|
|
|
async goto() {
|
|
try {
|
|
console.log('导航到登录日志页面...');
|
|
await this.page.goto('/loginlog');
|
|
|
|
await this.page.waitForLoadState('networkidle');
|
|
await this.table.waitFor({ state: 'visible', timeout: 10000 });
|
|
await expect(this.page).toHaveURL(/.*loginlog/);
|
|
|
|
console.log('登录日志页面加载完成');
|
|
} catch (error) {
|
|
await this.page.screenshot({ path: `test-results/login-log-error-${Date.now()}.png` });
|
|
console.error('导航到登录日志页面失败:', error);
|
|
throw new Error(`导航到登录日志页面失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
}
|
|
}
|
|
|
|
async searchByKeyword(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;
|
|
}
|
|
|
|
async exportData() {
|
|
await this.exportButton.click();
|
|
}
|
|
} |