新增e2e测试脚本,修复部分问题
This commit was merged in pull request #51.
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Gym模块冒烟测试', () => {
|
||||
test.use({ storageState: { cookies: [], origins: [] } });
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await test.step('导航到登录页面', async () => {
|
||||
await page.goto('/login');
|
||||
await page.waitForLoadState('networkidle');
|
||||
});
|
||||
|
||||
await test.step('输入登录信息', async () => {
|
||||
await page.fill('input[type="text"]', 'admin');
|
||||
await page.fill('input[type="password"]', 'Test@123');
|
||||
});
|
||||
|
||||
await test.step('点击登录按钮并等待跳转', async () => {
|
||||
await page.click('button:has-text("登录")');
|
||||
await page.waitForURL(/.*dashboard/, { timeout: 30000 });
|
||||
await page.waitForLoadState('networkidle');
|
||||
});
|
||||
|
||||
await test.step('验证登录成功', async () => {
|
||||
await expect(page).toHaveURL(/.*dashboard/);
|
||||
console.log('管理员登录成功,进入Dashboard');
|
||||
});
|
||||
});
|
||||
|
||||
test('会员管理页面加载', async ({ page }) => {
|
||||
await test.step('导航到会员管理页面', async () => {
|
||||
await page.goto('/members');
|
||||
await page.waitForURL('**/members', { timeout: 30000 });
|
||||
await page.waitForLoadState('networkidle');
|
||||
});
|
||||
|
||||
await test.step('验证表格可见', async () => {
|
||||
const table = page.locator('.el-table');
|
||||
await expect(table).toBeVisible({ timeout: 15000 });
|
||||
console.log('会员管理页面表格已加载');
|
||||
});
|
||||
|
||||
await test.step('验证搜索框可见', async () => {
|
||||
const searchInput = page.getByPlaceholder('搜索会员编号/昵称/手机号');
|
||||
await expect(searchInput).toBeVisible({ timeout: 5000 });
|
||||
console.log('会员管理页面功能元素正常');
|
||||
});
|
||||
});
|
||||
|
||||
test('团课管理页面加载', async ({ page }) => {
|
||||
await test.step('导航到团课管理页面', async () => {
|
||||
await page.goto('/courses');
|
||||
await page.waitForURL('**/courses', { timeout: 30000 });
|
||||
await page.waitForLoadState('networkidle');
|
||||
});
|
||||
|
||||
await test.step('验证表格可见', async () => {
|
||||
const table = page.locator('.el-table');
|
||||
await expect(table).toBeVisible({ timeout: 15000 });
|
||||
console.log('团课管理页面表格已加载');
|
||||
});
|
||||
|
||||
await test.step('验证新增按钮可见', async () => {
|
||||
const addButton = page.getByRole('button', { name: '新增团课' });
|
||||
await expect(addButton).toBeVisible({ timeout: 5000 });
|
||||
console.log('团课管理页面功能元素正常');
|
||||
});
|
||||
});
|
||||
|
||||
test('教练管理页面加载', async ({ page }) => {
|
||||
await test.step('导航到教练管理页面', async () => {
|
||||
await page.goto('/coach');
|
||||
await page.waitForURL('**/coach', { timeout: 30000 });
|
||||
await page.waitForLoadState('networkidle');
|
||||
});
|
||||
|
||||
await test.step('验证表格可见', async () => {
|
||||
const table = page.locator('.el-table');
|
||||
await expect(table).toBeVisible({ timeout: 15000 });
|
||||
console.log('教练管理页面表格已加载');
|
||||
});
|
||||
|
||||
await test.step('验证新增按钮可见', async () => {
|
||||
const addButton = page.getByRole('button', { name: '新增教练' });
|
||||
await expect(addButton).toBeVisible({ timeout: 5000 });
|
||||
console.log('教练管理页面功能元素正常');
|
||||
});
|
||||
});
|
||||
|
||||
test('数据统计页面加载', async ({ page }) => {
|
||||
await test.step('导航到数据统计页面', async () => {
|
||||
await page.goto('/statistics');
|
||||
await page.waitForURL('**/statistics', { timeout: 30000 });
|
||||
await page.waitForLoadState('networkidle');
|
||||
});
|
||||
|
||||
await test.step('验证统计卡片可见', async () => {
|
||||
const statCards = page.locator('.stat-card');
|
||||
await expect(statCards.first()).toBeVisible({ timeout: 15000 });
|
||||
const cardCount = await statCards.count();
|
||||
expect(cardCount).toBeGreaterThanOrEqual(4);
|
||||
console.log(`数据统计页面加载成功,共 ${cardCount} 个统计卡片`);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user