ucenter.test.js 2.2 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
	beforeAll(async () => {
study夏羽's avatar
study夏羽 已提交
5 6 7 8 9 10 11 12 13 14 15 16
		try{
			page = await program.switchTab('/pages/ucenter/ucenter')
			await page.waitFor(300)
			
			uniToken = await page.data('uniToken')
			console.log("uniToken: ",uniToken);
			
			const pageStack = await program.pageStack()
			console.log("pageStack: ",pageStack);
		}catch(e){
			console.log("e: ",e);
		}
study夏羽's avatar
study夏羽 已提交
17
		
study夏羽's avatar
study夏羽 已提交
18
	})
study夏羽's avatar
update  
study夏羽 已提交
19
	
study夏羽's avatar
study夏羽 已提交
20 21
	it('宫格', async () => {
		const getGrid = await page.data('gridList')
study夏羽's avatar
study夏羽 已提交
22 23
		console.log("getGrid: ",getGrid);
		// expect(getGrid.length).toBe(4)
study夏羽's avatar
study夏羽 已提交
24 25 26 27
	})

	it('列表', async () => {
		const getUcenterList = await page.data('ucenterList')
study夏羽's avatar
study夏羽 已提交
28 29
		console.log("getUcenterList: ",getUcenterList);
		// expect(getUcenterList.length).toBe(3)
study夏羽's avatar
study夏羽 已提交
30
	})
study夏羽's avatar
study夏羽 已提交
31 32
	

study夏羽's avatar
study夏羽 已提交
33
	it('普通签到', async () => {
study夏羽's avatar
study夏羽 已提交
34
		console.log(await program.currentPage(),"1-----------");
study夏羽's avatar
update  
study夏羽 已提交
35
		console.log("process.env.UNI_PLATFORM: ",process.env.UNI_PLATFORM);
study夏羽's avatar
study夏羽 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
		if(uniToken){
			if(process.env.UNI_PLATFORM === "app-plus"){
					console.log('app-plus----普通签到');
					const signInByAdRes = await page.callMethod('signInByAd')
					console.log("signInByAdRes: ",signInByAdRes);
					await page.waitFor(300)
					
					const shareRes = await page.callMethod('share')
					
					await program.screenshot({
						path: "static/screenshot/sign-app.png" 
					})
			}else{
				console.log('else----普通签到');
				await page.callMethod('signIn')
				// await page.waitFor(1000)
				// await program.screenshot({
				// 	path: "static/screenshot/sign-weixin-h5.png" 
				// })
			}
study夏羽's avatar
study夏羽 已提交
56
		}
study夏羽's avatar
study夏羽 已提交
57 58

	})
study夏羽's avatar
study夏羽 已提交
59 60 61

	it('我的积分', async () => {
		// expect.assertions(1);
study夏羽's avatar
study夏羽 已提交
62 63 64 65
		
		if(uniToken){
			const getScoreRes = await page.callMethod('getScore')
			console.log("getScoreRes: ", getScoreRes);
study夏羽's avatar
study夏羽 已提交
66
			if (getScoreRes && getScoreRes.score) {
study夏羽's avatar
study夏羽 已提交
67
				console.log("已登录--今日已签到");
study夏羽's avatar
study夏羽 已提交
68
				expect.assertions(2);
study夏羽's avatar
study夏羽 已提交
69 70 71 72 73 74 75
				expect(getScoreRes.score).not.toBeUndefined();
				expect(getScoreRes.balance).toBeGreaterThanOrEqual(getScoreRes.score);
			} else {
				console.log("签到失败");
			}
		}else{
			console.log("getScoreRes: 未登录");
study夏羽's avatar
study夏羽 已提交
76 77 78 79 80 81
			try{
				await program.navigateTo('/pages/ucenter/login-page/pwd-login/pwd-login')
				await page.waitFor(500)
			}catch(e){
				console.log("e: ",e);
			}
study夏羽's avatar
study夏羽 已提交
82
		}
study夏羽's avatar
study夏羽 已提交
83 84
	})
})