ucenter.test.js 2.2 KB
Newer Older
A
Anne_LXM 已提交
1
jest.setTimeout(20000);
study夏羽's avatar
study夏羽 已提交
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
		try{
			page = await program.switchTab('/pages/ucenter/ucenter')
A
Anne_LXM 已提交
7
			await page.waitFor('view')
A
Anne_LXM 已提交
8
			uniToken = await program.callUniMethod('getStorageSync', 'uni_id_token')
A
Anne_LXM 已提交
9 10 11 12
			platform = process.env.UNI_PLATFORM
			console.log("uniToken: ",platform,uniToken);
			if(!uniToken){
				console.log("未登录");
A
Anne_LXM 已提交
13
				await program.navigateTo('/uni_modules/uni-id-pages/pages/login/login-withpwd')
A
Anne_LXM 已提交
14
			}
study夏羽's avatar
study夏羽 已提交
15 16
		}catch(err){
			console.log("err: ",err);
study夏羽's avatar
study夏羽 已提交
17
		}
study夏羽's avatar
study夏羽 已提交
18 19
	})
	it('宫格', async () => {
study夏羽's avatar
study夏羽 已提交
20
		expect.assertions(1);
study夏羽's avatar
study夏羽 已提交
21
		const getGrid = await page.data('gridList')
study夏羽's avatar
study夏羽 已提交
22
		expect(getGrid.length).toBe(4)
study夏羽's avatar
study夏羽 已提交
23 24 25
	})
	it('列表', async () => {
		const getUcenterList = await page.data('ucenterList')
A
Anne_LXM 已提交
26
		if(platform.startsWith("app") || platform === "h5"){
study夏羽's avatar
study夏羽 已提交
27
			expect(getUcenterList.length).toBe(3)
A
Anne_LXM 已提交
28 29
		}else if(platform === "mp-weixin"){
			expect(getUcenterList.length).toBe(2)
study夏羽's avatar
study夏羽 已提交
30
		}
study夏羽's avatar
study夏羽 已提交
31
	})
study夏羽's avatar
study夏羽 已提交
32
	it('普通签到', async () => {
A
Anne_LXM 已提交
33 34
		console.log("普通签到");
		// await page.waitFor('uni-sign-in')
A
Anne_LXM 已提交
35 36 37
		if(!uniToken)return;
		if(platform.startsWith("app")){
			await page.callMethod('signInByAd')
A
Anne_LXM 已提交
38
			await page.waitFor(500)
A
Anne_LXM 已提交
39 40 41 42 43 44 45 46 47 48
			await page.callMethod('share')
			// await program.screenshot({
			// 	path: "static/screenshot/sign-app.png" 
			// })
		}else if(platform === "h5"){
			await page.callMethod('signIn')
			// await page.waitFor(500)
			// await program.screenshot({
			// 	path: "static/screenshot/sign-h5.png" 
			// })
A
Anne_LXM 已提交
49 50
		}else{
			await page.callMethod('signIn')
A
Anne_LXM 已提交
51 52 53 54
			// await page.waitFor(500)
			// await program.screenshot({
			// 	path: "static/screenshot/sign-weixin.png" 
			// })
study夏羽's avatar
study夏羽 已提交
55
		}
study夏羽's avatar
study夏羽 已提交
56
	})
study夏羽's avatar
study夏羽 已提交
57
	it('我的积分', async () => {
A
Anne_LXM 已提交
58 59
		if(!uniToken)return;
		const getScoreRes = await page.callMethod('getScore')
A
Anne_LXM 已提交
60
		console.log('getScoreRes: ',getScoreRes);
A
Anne_LXM 已提交
61
		await page.waitFor(500)
A
Anne_LXM 已提交
62
		if (getScoreRes.score) {
A
Anne_LXM 已提交
63
			expect.assertions(2);
A
Anne_LXM 已提交
64 65
			expect(getScoreRes.score).not.toBeUndefined();
			expect(getScoreRes.balance).toBeGreaterThanOrEqual(getScoreRes.score);
A
Anne_LXM 已提交
66 67
		} else {
			console.log("签到失败");
study夏羽's avatar
study夏羽 已提交
68
		}
study夏羽's avatar
study夏羽 已提交
69
	})
A
Anne_LXM 已提交
70 71 72 73 74 75 76
	it('screenshot',async()=>{
		await program.screenshot({
			path: "static/screenshot/ucenter.png" 
		})
		await page.waitFor(500);
	})
	
study夏羽's avatar
study夏羽 已提交
77
})
A
Anne_LXM 已提交
78