增加 后端,后台管理系统,uniapp会员端的自动化测试。

This commit is contained in:
2026-07-21 18:09:29 +08:00
parent df0e68469b
commit 6b60b3b4da
64 changed files with 13095 additions and 376 deletions
@@ -0,0 +1,50 @@
import { Page, Locator, expect } from '@playwright/test';
export class MemberCardManagementPage {
readonly page: Page;
readonly table: Locator;
readonly searchInput: Locator;
readonly searchButton: Locator;
readonly successMessage: Locator;
readonly pagination: Locator;
constructor(page: Page) {
this.page = page;
this.table = page.locator('.el-table').first();
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.pagination = page.locator('.el-pagination').or(page.locator('.pagination'));
}
async goto() {
console.log('导航到会员卡管理页面...');
await this.page.goto('/member-cards');
await this.page.waitForLoadState('networkidle');
await this.table.waitFor({ state: 'visible', timeout: 10000 });
await expect(this.page).toHaveURL(/.*member-cards/);
console.log('会员卡管理页面加载完成');
}
async waitForTableReady() {
await this.table.waitFor({ state: 'visible', timeout: 10000 });
await this.page.waitForFunction(
() => document.querySelectorAll('.el-table__body-wrapper tbody tr').length > 0,
{ timeout: 5000 }
).catch(() => console.log('表格没有数据,继续执行'));
}
async search(keyword: string) {
await this.searchInput.fill(keyword);
await this.searchButton.click();
await this.page.waitForTimeout(500);
}
async getRowCount(): Promise<number> {
return await this.table.locator('tbody tr').count();
}
async containsText(text: string): Promise<boolean> {
return await this.table.getByText(text).count() > 0;
}
}