pwd-retrieve.test.js 1.6 KB
Newer Older
study夏羽's avatar
study夏羽 已提交
1 2 3 4
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
describe('pages/ucenter/login-page/pwd-retrieve/pwd-retrieve.vue', () => {

study夏羽's avatar
study夏羽 已提交
5
	let page,abled;
study夏羽's avatar
study夏羽 已提交
6
	beforeAll(async () => {
study夏羽's avatar
study夏羽 已提交
7 8 9 10 11 12 13 14
		try {
			page = await program.navigateTo(
				'/pages/ucenter/login-page/pwd-retrieve/pwd-retrieve?phoneNumber=17769516019')
			await page.waitFor(500)
			console.log("await program.pageStack(): ", await program.pageStack());
		} catch (e) {
			console.log("e: ", e);
		}
study夏羽's avatar
study夏羽 已提交
15 16
	})

study夏羽's avatar
study夏羽 已提交
17 18 19 20 21
	it('重置密码之前', async () => {

		const element = await page.$('.send-btn-box')
		abled = await element.attribute('disabled')
		
study夏羽's avatar
study夏羽 已提交
22 23 24
		await page.setData({
			formData: {
				"phone": "17769516019",
study夏羽's avatar
study夏羽 已提交
25
				'code': '123456',
study夏羽's avatar
study夏羽 已提交
26 27
				'pwd': '222222',
				'pwd2': '222222',
study夏羽's avatar
study夏羽 已提交
28
		
study夏羽's avatar
study夏羽 已提交
29 30
			}
		})
study夏羽's avatar
study夏羽 已提交
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
	});

	it('重置密码', async () => {

		if(abled){
			const submitRes = await page.callMethod('submit')
			console.log("submitRes: ", submitRes);
			
			if (submitRes) {
				switch (submitRes.code) {
					case 0:
						console.log("密码重置成功")
						expect(submitRes.errCode).toBe(0)
						// expect(submitRes.errMsg).toBe('密码重置成功')
						break;
					case 10202:
study夏羽's avatar
study夏羽 已提交
47
						expect(submitRes.errMsg).toBe('此账号尚未注册')
study夏羽's avatar
study夏羽 已提交
48 49 50 51 52 53 54 55 56 57 58
						break;
					case 50202:
						expect(submitRes.errCode).toBe("uni-id-invalid-verify-code")
						expect(submitRes.errMsg).toBe("短信验证码错误或已失效")
						console.log("process.env.UNI_PLATFORM",process.env.UNI_PLATFORM)
						break;
					default:
						break;
				}
			}else{
				console.log("err")
study夏羽's avatar
study夏羽 已提交
59
			}
study夏羽's avatar
study夏羽 已提交
60
		}
study夏羽's avatar
study夏羽 已提交
61 62
	})
})