提交 4efc45b4 编写于 作者: A Anne_LXM

update test

上级 84e919c0
......@@ -7,23 +7,12 @@ describe('pages/list/list.vue', () => {
})
it('检测标题', async () => {
// expect.assertions(1);
const getData = await page.data('dataList')
console.log("getData: ",getData);
// expect(getData.title).toBe('阿里小程序IDE官方内嵌uni-app,为开发者提供多端开发服务')
expect.assertions(1);
expect((await page.data('dataList')).title).toBe('阿里小程序IDE官方内嵌uni-app,为开发者提供多端开发服务')
})
it('点击搜索跳转', async () => {
await page.callMethod('searchClick')
await page.waitFor(1000)
// if (process.env.UNI_PLATFORM != "mp-weixin") {
// expect.assertions(1);
// expect((await program.currentPage()).path).toBe('pages/list/search/search')
// await page.waitFor(500)
// await program.navigateBack()
// expect((await program.navigateBack()).path).toBe('pages/list/list')
// }
await page.waitFor(300)
})
})
\ No newline at end of file
......@@ -6,7 +6,6 @@ describe('pages/list/search/search.vue', () => {
beforeAll(async () => {
page = await program.navigateTo('/pages/list/search/search')
await page.waitFor(500)
console.log(await program.pageStack());
})
it('搜索发现-显示-隐藏', async () => {
expect.assertions(2);
......@@ -22,18 +21,9 @@ describe('pages/list/search/search.vue', () => {
expect(await page.data('netHotListIsHide')).toBeTruthy()
}
})
it('搜索内容', async () => {
await page.setData({searchText: '小程序'})
// console.log(await page.data('searchText'),"searchText--------");
await page.callMethod('search', '小程序')
await page.waitFor(300)
console.log(await program.currentPage(),"currentPage---------");
// if (process.env.UNI_PLATFORM != "mp-weixin") {
// expect.assertions(1);
// expect((await program.currentPage()).path).toBe('pages/list/list')
// }
})
});
......@@ -9,36 +9,19 @@ describe('pages/ucenter/about/about.vue', () => {
if(!isWX){
page = await program.reLaunch('/pages/ucenter/about/about')
await page.waitFor(500)
console.log(await program.pageStack());
}
} catch (err) {
console.log("err: ",err);
}
})
it('screenshot', async () => {
if(isWX){
return
}
console.log("process.env.UNI_PLATFORM: ",process.env.UNI_PLATFORM);
it('navigateTo-protocol', async () => {
if(isWX){return}
expect.assertions(1);
expect((await page.data('about')).appName).toBe('uni-starter')
await page.waitFor(1000)
if (process.env.UNI_PLATFORM.startsWith("app")) {
await program.screenshot({
path: "static/screenshot/about-app.png" // 默认项目根目录
})
await page.waitFor(1000)
await page.callMethod('navigateTo', {
url: "https://ask.dcloud.net.cn/protocol.html",
title: "用户服务条款"
})
}else if(process.env.UNI_PLATFORM === "h5"){
await program.screenshot({
path: "static/screenshot/about-h5.png" // 默认项目根目录
})
}
await page.waitFor(500)
await page.callMethod('navigateTo', {
url: "https://ask.dcloud.net.cn/protocol.html",
title: "用户服务条款"
})
})
});
......@@ -6,7 +6,6 @@ describe('pages/ucenter/settings/settings', () => {
try {
page = await program.navigateTo('/pages/ucenter/settings/settings')
await page.waitFor(1000)
// console.log(await program.pageStack());
uniToken = await page.data('uniToken')
console.log('uniToken:',uniToken);
} catch (err) {
......@@ -17,28 +16,19 @@ describe('pages/ucenter/settings/settings', () => {
it('settings', async () => {
if (process.env.UNI_PLATFORM.startsWith("app")) {
await page.callMethod('clearTmp')
// console.log(await page.data('pushIsOn'), "pushIsOn-------------");
const pushRes = await page.data('pushIsOn')
if (pushRes == "wait") {
await page.callMethod('pushServer.off')
}
if (pushRes == "wait") {await page.callMethod('pushServer.off')}
}else{
const el = await page.$('.content')
const elList = await el.$$('.mt10')
console.log("elList: ",elList.length);
expect.assertions(1);
expect(elList.length).toBe(2)
expect((await el.$$('.mt10')).length).toBe(2)
}
await page.waitFor(300)
})
// it('退出登录', async () => {
// if(uniToken){
// await page.callMethod('clickLogout')
// }
// console.log(await program.currentPage(),"333333");
// })
it('退出登录', async () => {
if(uniToken){await page.callMethod('changeLoginState')}
await page.waitFor(300)
console.log(await program.currentPage());
})
});
describe('pages/ucenter/ucenter.vue', () => {
let page,uniToken;
let page,uniToken,platform;
beforeAll(async () => {
try{
page = await program.switchTab('/pages/ucenter/ucenter')
await page.waitFor(300)
uniToken = await page.data('uniToken')
console.log("uniToken: ",uniToken);
console.log(await program.pageStack());
platform = process.env.UNI_PLATFORM
console.log("uniToken: ",platform,uniToken);
if(!uniToken){
console.log("未登录");
// await program.navigateTo('/uni_modules/uni-id-pages/pages/login/login-withpwd')
}
}catch(err){
console.log("err: ",err);
}
})
it('宫格', async () => {
......@@ -23,56 +26,45 @@ describe('pages/ucenter/ucenter.vue', () => {
it('列表', async () => {
const getUcenterList = await page.data('ucenterList')
console.log("getUcenterList: ",getUcenterList);
if(process.env.UNI_PLATFORM.startsWith("app")){
if(platform.startsWith("app") || platform === "h5"){
expect(getUcenterList.length).toBe(3)
}else if(platform === "mp-weixin"){
expect(getUcenterList.length).toBe(2)
}
})
it('普通签到', async () => {
if(uniToken){
if(process.env.UNI_PLATFORM.startsWith("app")){
console.log('app-plus----普通签到');
const signInByAdRes = await page.callMethod('signInByAd')
console.log("signInByAdRes: ",signInByAdRes);
await page.waitFor(300)
await page.callMethod('share')
await program.screenshot({
path: "static/screenshot/sign-app.png"
})
}else if(process.env.UNI_PLATFORM === "h5"){
console.log('else----普通签到');
await page.callMethod('signIn')
if(uniToken && platform.startsWith("app")){
await page.callMethod('signInByAd')
await page.waitFor(300)
await page.callMethod('share')
await program.screenshot({
path: "static/screenshot/sign-h5.png"
path: "static/screenshot/sign-app.png"
})
}else{
await page.callMethod('signIn')
await page.waitFor(1000)
await program.screenshot({
path: "static/screenshot/sign-weixin.png"
})
}
}else if(uniToken && platform === "h5"){
await page.callMethod('signIn')
await program.screenshot({
path: "static/screenshot/sign-h5.png"
})
}else{
await page.callMethod('signIn')
await page.waitFor(1000)
await program.screenshot({
path: "static/screenshot/sign-weixin.png"
})
}
})
it('我的积分', async () => {
if(uniToken){
const getScoreRes = await page.callMethod('getScore')
let scoreInfo = getScoreRes && getScoreRes.result.data[0]
await page.waitFor(500)
console.log("getScoreRes: ", getScoreRes);
if (getScoreRes && getScoreRes.score) {
console.log("已登录--今日已签到");
if (scoreInfo) {
expect.assertions(2);
expect(getScoreRes.score).not.toBeUndefined();
expect(getScoreRes.balance).toBeGreaterThanOrEqual(getScoreRes.score);
expect(scoreInfo.score).not.toBeUndefined();
expect(scoreInfo.balance).toBeGreaterThanOrEqual(scoreInfo.score);
} else {
console.log("签到失败");
}
......
......@@ -7,11 +7,9 @@ describe('uni_modules/uni-id-pages/pages/login/login-withpwd.vue', () => {
page = await program.navigateTo('/uni_modules/uni-id-pages/pages/login/login-withpwd')
await page.waitFor(500)
page = await program.currentPage()
});
it('账号密码登录', async () => {
// expect.assertions(1);
await page.setData({
"username": "DCloud",
"password": "dcloud2022",
......@@ -21,16 +19,12 @@ describe('uni_modules/uni-id-pages/pages/login/login-withpwd.vue', () => {
})
const needCaptcha = await page.data('needCaptcha')
console.log("needCaptcha---1: : ",needCaptcha);
if(needCaptcha){
await page.setData({
"captcha":"1234"
})
console.log("needCaptcha---2: ",await page.data('needCaptcha'));
}
const resLogin = await page.callMethod('pwdLogin')
console.log("resLogin: ", resLogin);
......@@ -53,9 +47,7 @@ describe('uni_modules/uni-id-pages/pages/login/login-withpwd.vue', () => {
"password": "unistarter2022",
"agree": true,
})
const resLoginA = await page.callMethod('pwdLogin')
console.log("resLoginA: ", resLoginA);
await page.callMethod('pwdLogin')
break;
case "uni-id-captcha-required":
const expectCaptchaStr = ["请输入图形验证码","Captcha required"]
......@@ -63,9 +55,7 @@ describe('uni_modules/uni-id-pages/pages/login/login-withpwd.vue', () => {
await page.setData({
"captcha":"1234"
})
// console.log("needCaptcha---3: ",await page.data('needCaptcha'));
const resLoginaa = await page.callMethod('pwdLogin')
console.log("resLoginaa: ", resLoginaa);
if(resLoginaa.errCode == 0){
console.log('登录成功');
}else{
......@@ -75,9 +65,7 @@ describe('uni_modules/uni-id-pages/pages/login/login-withpwd.vue', () => {
"captcha":"1234",
"agree": true
})
const resLoginbb = await page.callMethod('pwdLogin')
console.log("resLoginbb: ", resLoginbb);
await page.callMethod('pwdLogin')
}
break;
case "uni-captcha-verify-fail":
......@@ -93,7 +81,7 @@ describe('uni_modules/uni-id-pages/pages/login/login-withpwd.vue', () => {
console.log("未知错误---SYS_ERR",resLogin)//[uni-id-co]: request:fail
break;
default:
// console.log(await program.currentPage(),"currentPage---------");
console.log(await program.currentPage());
break;
}
})
......
......@@ -4,7 +4,6 @@ describe('uni_modules/uni-id-pages/pages/register/register.vue', () => {
beforeAll(async () => {
page = await program.navigateTo('/uni_modules/uni-id-pages/pages/register/register')
await page.waitFor(500)
console.log(await program.pageStack());
})
it('注册账号', async () => {
......@@ -26,7 +25,6 @@ describe('uni_modules/uni-id-pages/pages/register/register.vue', () => {
needPopupAgreements:false
},
})
console.log(await page.data('formData'), "setData----formData");
// expect(username).toMatch(/^1\d{10}$/);
expect(password).toMatch(/^.{6,20}$/);
......@@ -35,10 +33,8 @@ describe('uni_modules/uni-id-pages/pages/register/register.vue', () => {
if (process.env.UNI_PLATFORM != "mp-weixin") {
console.log(process.env.UNI_PLATFORM);
const element = await page.$('.uni-content')
const agreeEl = await element.$('.root')
console.log(await agreeEl.data('isAgree'), "isAgree----")
await agreeEl.setData({
isAgree: true
})
......@@ -63,7 +59,6 @@ describe('uni_modules/uni-id-pages/pages/register/register.vue', () => {
expect(resLogin.errMsg).toBe("[uni-id-co]: 请求云函数超时");
await page.waitFor(300)
const captchaEl = await page.$('.captcha-box')
console.log('captchaEl',captchaEl)
await captchaEl.callMethod('getImageCaptcha')
break;
case "uni-captcha-verify-fail":
......@@ -73,7 +68,7 @@ describe('uni_modules/uni-id-pages/pages/register/register.vue', () => {
console.log("未知错误---SYS_ERR")//[uni-id-co]: request:ok
break;
default:
// console.log(await program.currentPage(), "----------");
console.log(await program.currentPage());
break;
}
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册