ucenter.test.js 1.8 KB
Newer Older
A
Anne_LXM 已提交
1
jest.setTimeout(20000);
A
Anne_LXM 已提交
2 3
const PAGE_PATH = '/pages/ucenter/ucenter'
describe('ucenter', () => {
Anne_LXM's avatar
Anne_LXM 已提交
4
	let page,platform,hasLogin;
A
Anne_LXM 已提交
5
	platform = process.env.UNI_PLATFORM
study夏羽's avatar
study夏羽 已提交
6
	beforeAll(async () => {
A
Anne_LXM 已提交
7
		try{
A
Anne_LXM 已提交
8
			page = await program.switchTab(PAGE_PATH)
A
Anne_LXM 已提交
9
			await page.waitFor('view')
Anne_LXM's avatar
Anne_LXM 已提交
10 11
      hasLogin = await page.callMethod('hasLoginTest')
      console.log("登录状态",hasLogin,platform)
A
Anne_LXM 已提交
12 13
		}catch(err){
			console.log('err: ',err);
study夏羽's avatar
study夏羽 已提交
14
		}
study夏羽's avatar
study夏羽 已提交
15 16
	})
	it('宫格', async () => {
study夏羽's avatar
study夏羽 已提交
17
		expect.assertions(1);
study夏羽's avatar
study夏羽 已提交
18
		const getGrid = await page.data('gridList')
Anne_LXM's avatar
Anne_LXM 已提交
19
    console.log('getGrid',getGrid.length)
study夏羽's avatar
study夏羽 已提交
20
		expect(getGrid.length).toBe(4)
study夏羽's avatar
study夏羽 已提交
21 22 23
	})
	it('列表', async () => {
		const getUcenterList = await page.data('ucenterList')
Anne_LXM's avatar
Anne_LXM 已提交
24
    console.log('getUcenterList',getUcenterList.length)
A
Anne_LXM 已提交
25
		if(platform === "mp-weixin"){
Anne_LXM's avatar
Anne_LXM 已提交
26
			expect(getUcenterList.length).toBe(2);
A
Anne_LXM 已提交
27
		}else{
Anne_LXM's avatar
Anne_LXM 已提交
28
			expect(getUcenterList.length).toBe(3);
study夏羽's avatar
study夏羽 已提交
29
		}
study夏羽's avatar
study夏羽 已提交
30
	})
Anne_LXM's avatar
Anne_LXM 已提交
31
	if(hasLogin){
A
Anne_LXM 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
		it('普通签到', async () => {
			if(platform.startsWith("app")){
				await page.callMethod('signInByAd')
				await page.waitFor(1000)
				await page.callMethod('share')
				// await program.screenshot({
				// 	path: "static/screenshot/sign-app.png" 
				// })
			}else{
				await page.callMethod('signIn')
			}
		})
		it('我的积分', async () => {
			const getScoreRes = await page.callMethod('getScore')
			console.log('getScoreRes: ',getScoreRes);
			await page.waitFor(1000)
			if (getScoreRes.score) {
				expect.assertions(2);
				expect(getScoreRes.score).not.toBeUndefined();
				expect(getScoreRes.balance).toBeGreaterThanOrEqual(getScoreRes.score);
			} else {
				console.log("签到失败");
			}
		})
	}
Anne_LXM's avatar
Anne_LXM 已提交
57
	it('screenshot',async()=>{
58 59 60
		// await program.screenshot({
		// 	path: "static/screenshot/ucenter.png" 
		// })
Anne_LXM's avatar
Anne_LXM 已提交
61 62
    const image = await program.screenshot({
      fullPage: true
63
    })
Anne_LXM's avatar
Anne_LXM 已提交
64 65
    expect(image).toSaveImageSnapshot();
    await page.waitFor(500);
Anne_LXM's avatar
Anne_LXM 已提交
66
	})
study夏羽's avatar
study夏羽 已提交
67
})
A
Anne_LXM 已提交
68