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

	it('列表', async () => {
		const getUcenterList = await page.data('ucenterList')
study夏羽's avatar
study夏羽 已提交
26
		console.log("getUcenterList: ",getUcenterList);
study夏羽's avatar
study夏羽 已提交
27 28 29 30
		if(process.env.UNI_PLATFORM === "app-plus"){
			expect(getUcenterList.length).toBe(3)
		}
		
study夏羽's avatar
study夏羽 已提交
31
	})
study夏羽's avatar
study夏羽 已提交
32 33
	

study夏羽's avatar
study夏羽 已提交
34
	it('普通签到', async () => {
study夏羽's avatar
study夏羽 已提交
35
		
study夏羽's avatar
study夏羽 已提交
36 37 38 39 40 41 42
		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)
					
study夏羽's avatar
study夏羽 已提交
43
					await page.callMethod('share')
study夏羽's avatar
study夏羽 已提交
44 45 46 47
					
					await program.screenshot({
						path: "static/screenshot/sign-app.png" 
					})
study夏羽's avatar
study夏羽 已提交
48
			}else if(process.env.UNI_PLATFORM === "h5"){
study夏羽's avatar
study夏羽 已提交
49 50
				console.log('else----普通签到');
				await page.callMethod('signIn')
study夏羽's avatar
study夏羽 已提交
51 52 53 54 55 56 57 58 59 60
				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夏羽 已提交
61
			}
study夏羽's avatar
study夏羽 已提交
62
		}
study夏羽's avatar
study夏羽 已提交
63 64

	})
study夏羽's avatar
study夏羽 已提交
65 66

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