新增e2e测试脚本,修复部分问题
This commit was merged in pull request #51.
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
const { launchMiniProgram, closeMiniProgram, waitForPage } = require('../helpers/automator');
|
||||
const LoginPage = require('../pages/LoginPage');
|
||||
const HomePage = require('../pages/HomePage');
|
||||
|
||||
let miniProgram;
|
||||
let loginPage;
|
||||
let homePage;
|
||||
|
||||
describe('P0 - 教练端冒烟测试', () => {
|
||||
beforeAll(async () => {
|
||||
miniProgram = await launchMiniProgram();
|
||||
loginPage = new LoginPage(miniProgram);
|
||||
homePage = new HomePage(miniProgram);
|
||||
}, 120000);
|
||||
|
||||
afterAll(async () => {
|
||||
await closeMiniProgram();
|
||||
}, 30000);
|
||||
|
||||
test('启动小程序 → 应显示登录页', async () => {
|
||||
const isLogin = await loginPage.isOnLoginPage();
|
||||
expect(isLogin).toBe(true);
|
||||
|
||||
// 验证登录页关键元素存在
|
||||
const page = await miniProgram.currentPage();
|
||||
const brandArea = await page.$('.brand-area');
|
||||
const loginForm = await page.$('.login-form');
|
||||
const loginBtn = await page.$('.login-btn');
|
||||
|
||||
expect(brandArea).not.toBeNull();
|
||||
expect(loginForm).not.toBeNull();
|
||||
expect(loginBtn).not.toBeNull();
|
||||
}, 30000);
|
||||
|
||||
test('登录页应包含品牌信息', async () => {
|
||||
const page = await miniProgram.currentPage();
|
||||
const appName = await page.$('.app-name');
|
||||
expect(appName).not.toBeNull();
|
||||
const nameText = await appName.text();
|
||||
expect(nameText).toContain('Novalon');
|
||||
}, 15000);
|
||||
|
||||
test('登录 → 应跳转到教练首页', async () => {
|
||||
await loginPage.login('coach_test1', 'Test@123');
|
||||
const homePage_ = await loginPage.waitForLoginSuccess(20000);
|
||||
expect(homePage_.path).toContain('pages/index/index');
|
||||
}, 60000);
|
||||
|
||||
test('首页应显示教练欢迎信息', async () => {
|
||||
const page = await miniProgram.currentPage();
|
||||
|
||||
// 验证欢迎卡片
|
||||
const greetingCard = await page.$('.greeting-card');
|
||||
expect(greetingCard).not.toBeNull();
|
||||
|
||||
// 验证教练名称存在
|
||||
const coachName = await homePage.getCoachName();
|
||||
expect(coachName).toBeTruthy();
|
||||
}, 15000);
|
||||
|
||||
test('首页应显示今日统计信息', async () => {
|
||||
await homePage.waitForLoad();
|
||||
const stats = await homePage.getTodayStats();
|
||||
// 统计数值应为有效数字(0 也是有效的)
|
||||
expect(stats).toBeDefined();
|
||||
expect(typeof stats.pending).toBe('string');
|
||||
expect(typeof stats.inProgress).toBe('string');
|
||||
expect(typeof stats.ended).toBe('string');
|
||||
}, 15000);
|
||||
});
|
||||
Reference in New Issue
Block a user