新增e2e测试脚本,修复部分问题
This commit was merged in pull request #51.
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { MemberManagementPage } from '../pages/MemberManagementPage';
|
||||
|
||||
test.describe.serial('会员管理完整CRUD旅程', () => {
|
||||
let memberPage: MemberManagementPage;
|
||||
const timestamp = Date.now();
|
||||
const searchKeyword = `会员_${timestamp}`;
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
memberPage = new MemberManagementPage(page);
|
||||
});
|
||||
|
||||
test('会员列表显示 + 搜索', async ({ page }) => {
|
||||
await test.step('导航到会员管理页面', async () => {
|
||||
await memberPage.goto();
|
||||
});
|
||||
|
||||
await test.step('验证表格显示', async () => {
|
||||
await expect(memberPage.table).toBeVisible({ timeout: 10000 });
|
||||
});
|
||||
|
||||
await test.step('验证数据加载', async () => {
|
||||
const rowCount = await memberPage.getTableRowCount();
|
||||
console.log(`会员列表包含 ${rowCount} 条记录`);
|
||||
expect(rowCount).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
|
||||
await test.step('搜索会员', async () => {
|
||||
await memberPage.search('测试');
|
||||
console.log('会员搜索完成');
|
||||
});
|
||||
});
|
||||
|
||||
test('编辑会员信息', async ({ page }) => {
|
||||
await test.step('导航到会员管理页面', async () => {
|
||||
await memberPage.goto();
|
||||
});
|
||||
|
||||
await test.step('等待数据加载', async () => {
|
||||
await expect(memberPage.table).toBeVisible({ timeout: 10000 });
|
||||
});
|
||||
|
||||
await test.step('点击第一个会员的编辑按钮', async () => {
|
||||
const rows = await memberPage.getTableRowCount();
|
||||
if (rows > 0) {
|
||||
await memberPage.clickEditOnFirstRow();
|
||||
console.log('编辑弹窗已打开');
|
||||
} else {
|
||||
console.log('当前没有会员记录,跳过编辑测试');
|
||||
test.skip();
|
||||
}
|
||||
});
|
||||
|
||||
await test.step('修改会员信息', async () => {
|
||||
const newNickname = `编辑昵称_${timestamp}`;
|
||||
await memberPage.fillEditForm(newNickname, '女');
|
||||
console.log(`昵称已修改为: ${newNickname}`);
|
||||
});
|
||||
|
||||
await test.step('提交表单', async () => {
|
||||
await memberPage.submitForm();
|
||||
});
|
||||
|
||||
await test.step('验证更新成功', async () => {
|
||||
await memberPage.waitForDialogClose();
|
||||
console.log('会员信息更新完成');
|
||||
});
|
||||
});
|
||||
|
||||
test('搜索验证编辑后的会员', async ({ page }) => {
|
||||
await test.step('导航到会员管理页面', async () => {
|
||||
await memberPage.goto();
|
||||
});
|
||||
|
||||
await test.step('按昵称搜索', async () => {
|
||||
await memberPage.search(`编辑昵称_${timestamp}`);
|
||||
console.log('搜索编辑后的会员');
|
||||
});
|
||||
|
||||
await test.step('验证搜索结果显示', async () => {
|
||||
const rowCount = await memberPage.getTableRowCount();
|
||||
console.log(`搜索结果显示 ${rowCount} 条记录`);
|
||||
expect(rowCount).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user