settings.test.js 1.4 KB
Newer Older
study夏羽's avatar
study夏羽 已提交
1
// uniapp自动化测试教程: https://uniapp-test.dcloud.net.cn/docs/testcase/start
A
Anne_LXM 已提交
2 3
const PAGE_PATH = '/pages/ucenter/settings/settings'
describe('settings', () => {
study夏羽's avatar
study夏羽 已提交
4
	let page,uniToken;
study夏羽's avatar
study夏羽 已提交
5
	beforeAll(async () => {
study夏羽's avatar
study夏羽 已提交
6
		try {
A
Anne_LXM 已提交
7
			page = await program.navigateTo(PAGE_PATH)
A
Anne_LXM 已提交
8
			await page.waitFor('view')
A
Anne_LXM 已提交
9
			uniToken = await program.callUniMethod('getStorageSync', 'uni_id_token')
A
Anne_LXM 已提交
10
			console.log("uniToken: ",uniToken);
study夏羽's avatar
study夏羽 已提交
11 12
		} catch (err) {
			console.log("err: ",err);
study夏羽's avatar
study夏羽 已提交
13
		}
study夏羽's avatar
study夏羽 已提交
14
	})
study夏羽's avatar
study夏羽 已提交
15
	it('settings', async () => {
A
Anne_LXM 已提交
16
		if(!uniToken)return;
17
		if (process.env.UNI_PLATFORM.startsWith("app")) {
study夏羽's avatar
study夏羽 已提交
18
			await page.callMethod('clearTmp')
study夏羽's avatar
study夏羽 已提交
19
			const pushRes = await page.data('pushIsOn')
A
Anne_LXM 已提交
20
			if (pushRes == "wait") {await page.callMethod('pushServer.off')}
study夏羽's avatar
study夏羽 已提交
21 22
		}else{
			const el = await page.$('.content')
A
Anne_LXM 已提交
23
			await page.waitFor('view')
study夏羽's avatar
study夏羽 已提交
24
			expect.assertions(1);
A
Anne_LXM 已提交
25
			expect((await el.$$('.mt10')).length).toBe(2)
study夏羽's avatar
study夏羽 已提交
26 27
		}
	})
A
Anne_LXM 已提交
28
	it('退出登录', async () => {
A
Anne_LXM 已提交
29
		if(!uniToken)return;
A
Anne_LXM 已提交
30 31 32 33 34 35 36
    const hasLoginTest = await page.callMethod('hasLoginTest')
    console.log("hasLoginTest",hasLoginTest)
    if(hasLoginTest){
      const bottomEl = await page.$('.bottom-back-text')
      console.log('bottom-back-text',bottomEl,await bottomEl.text())
      expect(await bottomEl.text()).toBe('退出登录')
    }
A
Anne_LXM 已提交
37 38
		await page.callMethod('changeLoginState')
		await page.waitFor(500)
A
Anne_LXM 已提交
39 40
		console.log(await program.currentPage());
	})
study夏羽's avatar
study夏羽 已提交
41 42

});