ucenter.test.js 2.1 KB
Newer Older
study夏羽's avatar
study夏羽 已提交
1 2
describe('pages/ucenter/ucenter.vue', () => {

A
Anne_LXM 已提交
3
	let page,uniToken,platform;
study夏羽's avatar
study夏羽 已提交
4
	beforeAll(async () => {
study夏羽's avatar
study夏羽 已提交
5 6 7 8
		try{
			page = await program.switchTab('/pages/ucenter/ucenter')
			await page.waitFor(300)
			uniToken = await page.data('uniToken')
A
Anne_LXM 已提交
9 10 11 12 13 14 15
			platform = process.env.UNI_PLATFORM
			console.log("uniToken: ",platform,uniToken);
			
			if(!uniToken){
				console.log("未登录");
				// await program.navigateTo('/uni_modules/uni-id-pages/pages/login/login-withpwd')
			}
study夏羽's avatar
study夏羽 已提交
16 17
		}catch(err){
			console.log("err: ",err);
study夏羽's avatar
study夏羽 已提交
18
		}
study夏羽's avatar
study夏羽 已提交
19
	})
study夏羽's avatar
update  
study夏羽 已提交
20
	
study夏羽's avatar
study夏羽 已提交
21
	it('宫格', async () => {
study夏羽's avatar
study夏羽 已提交
22
		expect.assertions(1);
study夏羽's avatar
study夏羽 已提交
23
		const getGrid = await page.data('gridList')
study夏羽's avatar
study夏羽 已提交
24
		expect(getGrid.length).toBe(4)
study夏羽's avatar
study夏羽 已提交
25 26 27 28
	})

	it('列表', async () => {
		const getUcenterList = await page.data('ucenterList')
A
Anne_LXM 已提交
29
		if(platform.startsWith("app") || platform === "h5"){
study夏羽's avatar
study夏羽 已提交
30
			expect(getUcenterList.length).toBe(3)
A
Anne_LXM 已提交
31 32
		}else if(platform === "mp-weixin"){
			expect(getUcenterList.length).toBe(2)
study夏羽's avatar
study夏羽 已提交
33
		}
study夏羽's avatar
study夏羽 已提交
34
	})
study夏羽's avatar
study夏羽 已提交
35
	
study夏羽's avatar
study夏羽 已提交
36
	it('普通签到', async () => {
study夏羽's avatar
study夏羽 已提交
37
		
A
Anne_LXM 已提交
38 39 40 41
		if(uniToken && platform.startsWith("app")){
				await page.callMethod('signInByAd')
				await page.waitFor(300)
				await page.callMethod('share')
study夏羽's avatar
study夏羽 已提交
42
				await program.screenshot({
A
Anne_LXM 已提交
43
					path: "static/screenshot/sign-app.png" 
study夏羽's avatar
study夏羽 已提交
44
				})
A
Anne_LXM 已提交
45 46 47 48 49 50 51 52 53 54 55
		}else if(uniToken && platform === "h5"){
			await page.callMethod('signIn')
			await program.screenshot({
				path: "static/screenshot/sign-h5.png" 
			})
		}else{
			await page.callMethod('signIn')
			await page.waitFor(1000)
			await program.screenshot({
				path: "static/screenshot/sign-weixin.png" 
			})
study夏羽's avatar
study夏羽 已提交
56
		}
study夏羽's avatar
study夏羽 已提交
57
	})
study夏羽's avatar
study夏羽 已提交
58 59

	it('我的积分', async () => {
study夏羽's avatar
study夏羽 已提交
60 61
		if(uniToken){
			const getScoreRes = await page.callMethod('getScore')
A
Anne_LXM 已提交
62
			let scoreInfo = getScoreRes && getScoreRes.result.data[0]
study夏羽's avatar
study夏羽 已提交
63
			await page.waitFor(500)
A
Anne_LXM 已提交
64
			if (scoreInfo) {
study夏羽's avatar
study夏羽 已提交
65
				expect.assertions(2);
A
Anne_LXM 已提交
66 67
				expect(scoreInfo.score).not.toBeUndefined();
				expect(scoreInfo.balance).toBeGreaterThanOrEqual(scoreInfo.score);
study夏羽's avatar
study夏羽 已提交
68 69 70 71 72
			} else {
				console.log("签到失败");
			}
		}else{
			console.log("getScoreRes: 未登录");
study夏羽's avatar
study夏羽 已提交
73
			try{
study夏羽's avatar
study夏羽 已提交
74
				await program.navigateTo('/uni_modules/uni-id-pages/pages/login/login-withpwd')
study夏羽's avatar
study夏羽 已提交
75 76 77 78
				await page.waitFor(500)
			}catch(e){
				console.log("e: ",e);
			}
study夏羽's avatar
study夏羽 已提交
79
		}
study夏羽's avatar
study夏羽 已提交
80 81
	})
})