ucenter.test.js 2.0 KB
Newer Older
Anne_LXM's avatar
Anne_LXM 已提交
1 2 3 4 5
jest.setTimeout(30000);
const PAGE_PATH = '/pages/ucenter/ucenter'
describe('ucenter', () => {
	let page, platform, hasLogin;
	platform = process.env.UNI_PLATFORM
Anne_LXM's avatar
Anne_LXM 已提交
6
	console.log('uniTestPlatformInfo', process.env.uniTestPlatformInfo)
Anne_LXM's avatar
Anne_LXM 已提交
7 8 9 10 11 12 13
	if (process.env.uniTestPlatformInfo == 'ios_simulator 13.7') {
		it('ucenter-ios13.7', async () => {
			expect(1).toBe(1)
		})
		return
	}
	beforeAll(async () => {
Anne_LXM's avatar
Anne_LXM 已提交
14 15 16 17 18 19 20
		page = await program.switchTab(PAGE_PATH)
		await page.waitFor('view')
		hasLogin = await page.callMethod('hasLoginTest')
		console.log("登录状态", hasLogin, platform)
		if (!hasLogin) {
			console.log('hasLogin--err')
			return
Anne_LXM's avatar
Anne_LXM 已提交
21 22 23 24 25 26 27 28 29 30 31 32 33 34
		}
	})
	it('宫格', async () => {
		expect.assertions(1);
		const getGrid = await page.data('gridList')
		expect(getGrid.length).toBe(4)
	})
	it('列表', async () => {
		const getUcenterList = await page.data('ucenterList')
		if (platform === "mp-weixin") {
			expect(getUcenterList.length).toBe(2);
		} else {
			expect(getUcenterList.length).toBe(3);
		}
Anne_LXM's avatar
Anne_LXM 已提交
35
	})
Anne_LXM's avatar
Anne_LXM 已提交
36 37 38 39 40 41 42 43 44 45
	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')
study夏羽's avatar
study夏羽 已提交
46
		}
study夏羽's avatar
study夏羽 已提交
47
	})
Anne_LXM's avatar
Anne_LXM 已提交
48 49 50 51 52 53 54 55 56 57
	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("签到失败");
study夏羽's avatar
study夏羽 已提交
58
		}
Anne_LXM's avatar
Anne_LXM 已提交
59 60 61 62 63 64 65 66 67 68 69 70
	})
	// 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);
	// })
})