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

study夏羽's avatar
study夏羽 已提交
3
	let page,uniToken;
study夏羽's avatar
study夏羽 已提交
4 5 6
	beforeAll(async () => {
		page = await program.switchTab('/pages/ucenter/ucenter')
		await page.waitFor(300)
study夏羽's avatar
study夏羽 已提交
7
		console.log("page:2 ",page);
study夏羽's avatar
study夏羽 已提交
8 9 10
		
		uniToken = await page.data('uniToken')
		console.log("uniToken: ",uniToken);
study夏羽's avatar
study夏羽 已提交
11
	})
study夏羽's avatar
update  
study夏羽 已提交
12
	
study夏羽's avatar
study夏羽 已提交
13 14
	it('宫格', async () => {
		const getGrid = await page.data('gridList')
study夏羽's avatar
study夏羽 已提交
15 16
		console.log("getGrid: ",getGrid);
		// expect(getGrid.length).toBe(4)
study夏羽's avatar
study夏羽 已提交
17 18 19 20
	})

	it('列表', async () => {
		const getUcenterList = await page.data('ucenterList')
study夏羽's avatar
study夏羽 已提交
21 22
		console.log("getUcenterList: ",getUcenterList);
		// expect(getUcenterList.length).toBe(3)
study夏羽's avatar
study夏羽 已提交
23
	})
study夏羽's avatar
study夏羽 已提交
24 25
	

study夏羽's avatar
study夏羽 已提交
26
	it('普通签到', async () => {
study夏羽's avatar
study夏羽 已提交
27
		
study夏羽's avatar
update  
study夏羽 已提交
28
		console.log("process.env.UNI_PLATFORM: ",process.env.UNI_PLATFORM);
study夏羽's avatar
study夏羽 已提交
29
		if (process.env.UNI_PLATFORM == "mp-weixin" || process.env.UNI_PLATFORM == "h5"){
study夏羽's avatar
study夏羽 已提交
30
			await page.callMethod('signIn')
study夏羽's avatar
study夏羽 已提交
31
			await page.waitFor(500)
study夏羽's avatar
update  
study夏羽 已提交
32
			await program.screenshot({
study夏羽's avatar
study夏羽 已提交
33
				path: "static/screenshot/sign-weixin-h5.png" 
study夏羽's avatar
study夏羽 已提交
34 35
			})
		}
study夏羽's avatar
study夏羽 已提交
36
		if(process.env.UNI_PLATFORM === "app-plus"&& uniToken){
study夏羽's avatar
study夏羽 已提交
37 38
				console.log('app-plus');
				const signInByAdRes = await page.callMethod('signInByAd')
study夏羽's avatar
study夏羽 已提交
39 40 41 42
				console.log("signInByAdRes: ",signInByAdRes);
				await page.waitFor(300)
				
				console.log(await program.currentPage(),"1111111");
study夏羽's avatar
study夏羽 已提交
43 44 45 46 47
				const shareRes = await page.callMethod('share')
				
				await program.screenshot({
					path: "static/screenshot/sign-app.png" 
				})
study夏羽's avatar
study夏羽 已提交
48
		}
study夏羽's avatar
study夏羽 已提交
49 50

	})
study夏羽's avatar
study夏羽 已提交
51 52 53

	it('我的积分', async () => {
		// expect.assertions(1);
study夏羽's avatar
study夏羽 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
		// await page.waitFor(300)
		
		if(uniToken){
			const getScoreRes = await page.callMethod('getScore')
			console.log("getScoreRes: ", getScoreRes);
			if (getScoreRes.score) {
				console.log("已登录--今日已签到");
				expect.assertions(1);
				expect(getScoreRes.score).not.toBeUndefined();
				expect(getScoreRes.balance).toBeGreaterThanOrEqual(getScoreRes.score);
			} else {
				console.log("签到失败");
			}
		}else{
			console.log("getScoreRes: 未登录");
			await program.navigateTo('/pages/ucenter/login-page/pwd-login/pwd-login')
			await page.waitFor(500)
study夏羽's avatar
study夏羽 已提交
71
		}
study夏羽's avatar
study夏羽 已提交
72 73
	})
})