ucenter.test.js 2.1 KB
Newer Older
Anne_LXM's avatar
Anne_LXM 已提交
1
jest.setTimeout(30000);
A
Anne_LXM 已提交
2 3
const PAGE_PATH = '/pages/ucenter/ucenter'
describe('ucenter', () => {
Anne_LXM's avatar
Anne_LXM 已提交
4
	let page,platform,hasLogin;
A
Anne_LXM 已提交
5
	platform = process.env.UNI_PLATFORM
Anne_LXM's avatar
Anne_LXM 已提交
6 7 8 9 10 11 12
  console.log('uniTestPlatformInfo',process.env.uniTestPlatformInfo,process.env.uniTestPlatformInfo == 'ios_simulator 13.7')
  if(process.env.uniTestPlatformInfo == 'ios_simulator 13.7'){
    it('ios', async () => {
    	expect(1).toBe(1)
      return
    })
  }
study夏羽's avatar
study夏羽 已提交
13
	beforeAll(async () => {
A
Anne_LXM 已提交
14
		try{
A
Anne_LXM 已提交
15
			page = await program.switchTab(PAGE_PATH)
A
Anne_LXM 已提交
16
			await page.waitFor('view')
Anne_LXM's avatar
Anne_LXM 已提交
17 18
      hasLogin = await page.callMethod('hasLoginTest')
      console.log("登录状态",hasLogin,platform)
A
Anne_LXM 已提交
19 20
		}catch(err){
			console.log('err: ',err);
study夏羽's avatar
study夏羽 已提交
21
		}
study夏羽's avatar
study夏羽 已提交
22 23
	})
	it('宫格', async () => {
study夏羽's avatar
study夏羽 已提交
24
		expect.assertions(1);
study夏羽's avatar
study夏羽 已提交
25
		const getGrid = await page.data('gridList')
Anne_LXM's avatar
Anne_LXM 已提交
26
    console.log('getGrid',getGrid.length)
study夏羽's avatar
study夏羽 已提交
27
		expect(getGrid.length).toBe(4)
study夏羽's avatar
study夏羽 已提交
28 29 30
	})
	it('列表', async () => {
		const getUcenterList = await page.data('ucenterList')
Anne_LXM's avatar
Anne_LXM 已提交
31
    console.log('getUcenterList',getUcenterList.length)
A
Anne_LXM 已提交
32
		if(platform === "mp-weixin"){
Anne_LXM's avatar
Anne_LXM 已提交
33
			expect(getUcenterList.length).toBe(2);
A
Anne_LXM 已提交
34
		}else{
Anne_LXM's avatar
Anne_LXM 已提交
35
			expect(getUcenterList.length).toBe(3);
study夏羽's avatar
study夏羽 已提交
36
		}
study夏羽's avatar
study夏羽 已提交
37
	})
Anne_LXM's avatar
Anne_LXM 已提交
38
	if(hasLogin){
A
Anne_LXM 已提交
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
		it('普通签到', async () => {
			if(platform.startsWith("app")){
				await page.callMethod('signInByAd')
				await page.waitFor(1000)
				await page.callMethod('share')
				// await program.screenshot({
				// 	path: "static/screenshot/sign-app.png" 
				// })
			}else{
				await page.callMethod('signIn')
			}
		})
		it('我的积分', async () => {
			const getScoreRes = await page.callMethod('getScore')
			console.log('getScoreRes: ',getScoreRes);
			await page.waitFor(1000)
			if (getScoreRes.score) {
				expect.assertions(2);
				expect(getScoreRes.score).not.toBeUndefined();
				expect(getScoreRes.balance).toBeGreaterThanOrEqual(getScoreRes.score);
			} else {
				console.log("签到失败");
			}
		})
	}
Anne_LXM's avatar
Anne_LXM 已提交
64 65 66 67 68 69 70 71 72 73
	// it('screenshot',async()=>{
	// 	await program.screenshot({
	// 		path: "static/screenshot/ucenter.png" 
	// 	})
 //    const image = await program.screenshot({
 //      fullPage: true
 //    })
 //    expect(image).toSaveImageSnapshot();
 //    await page.waitFor(500);
	// })
study夏羽's avatar
study夏羽 已提交
74
})
A
Anne_LXM 已提交
75