diff --git a/pages/list/list.nvue b/pages/list/list.nvue index 48113f92e9d2554e07c0cd50842eaf5e66eeac55..ff096d83875d5f4d7d0a314199fee6af0a49b234 100644 --- a/pages/list/list.nvue +++ b/pages/list/list.nvue @@ -77,7 +77,7 @@ keyword(keyword, oldValue) { let where = '"article_status" == 1 ' if (keyword) { - this.where = where + `/${keyword}/.test(title)`; + this.where = where + `&& /${keyword}/.test(title)`; } else { this.where = where; } diff --git a/pages/list/search/search.test.js b/pages/list/search/search.test.js index 1dba4b7f25389d2cf6ea0416140143a3e7d088fb..cfbb98f730f9a7b372ffc3e13795b37cee787721 100644 --- a/pages/list/search/search.test.js +++ b/pages/list/search/search.test.js @@ -22,15 +22,14 @@ describe('pages/list/search/search.vue', () => { }) it('搜索内容', async () => { - expect.assertions(1); + // expect.assertions(1); const setSearchTest = await page.setData({ searchText: '小程序', }) - // console.log(await page.data('searchText')); + console.log(await page.data('searchText')); await page.callMethod('search', '小程序') await page.waitFor(300) + console.log(await program.currentPage(),"-----------------------"); expect((await program.currentPage()).path).toBe('pages/list/list') - // 执行 navigateBack 验证是否返回 - // expect((await program.navigateBack()).path).toBe('pages/list/search/search') }) }); diff --git a/pages/ucenter/about/about.test.js b/pages/ucenter/about/about.test.js index e8879c501468c75794898d16a6f3828012a71d0f..dd4d3cbd24b0ccdf6bdd25723a629499b0288797 100644 --- a/pages/ucenter/about/about.test.js +++ b/pages/ucenter/about/about.test.js @@ -4,7 +4,7 @@ describe('pages/ucenter/about/about.vue', () => { let page beforeAll(async () => { - page = await program.navigateTo('/pages/ucenter/about/about') + page = await program.redirectTo('/pages/ucenter/about/about') await page.waitFor(500) }) diff --git a/pages/ucenter/login-page/pwd-login/pwd-login.test.js b/pages/ucenter/login-page/pwd-login/pwd-login.test.js index ca19cc3b2ae1a2dc21bac519b69115af011c7d67..8f9bc86292f1dbf159f1b0579e2d7b1f3722f8cc 100644 --- a/pages/ucenter/login-page/pwd-login/pwd-login.test.js +++ b/pages/ucenter/login-page/pwd-login/pwd-login.test.js @@ -5,7 +5,7 @@ describe('pages/ucenter/login-page/pwd-login/pwd-login.vue', () => { let page beforeAll(async () => { - page = await program.redirectTo('/pages/ucenter/login-page/pwd-login/pwd-login') + page = await program.navigateTo('/pages/ucenter/login-page/pwd-login/pwd-login') await page.waitFor(500) }) @@ -43,7 +43,29 @@ describe('pages/ucenter/login-page/pwd-login/pwd-login.vue', () => { }) const resLogin = await page.callMethod('pwdLogin') console.log("resLogin: ", resLogin.msg); - expect(resLogin.msg).toBe("登录成功"); + + switch (resLogin.msg){ + case 10102: + expect(resLogin.msg).toBe("密码错误"); + const setForm = await page.setData({ + "password": "222222", + "username": "数字天堂", + "agree": true, + }) + const resLogin = await page.callMethod('pwdLogin') + break; + case 10103: + expect(resLogin.msg).toBe("密码错误次数过多"); + break; + case 10002: + expect(resLogin.msg).toBe("验证码不可为空"); + break; + case 0: + expect(resLogin.msg).toBe("登录成功"); + break; + default: + break; + } }) }) diff --git a/pages/ucenter/settings/settings.test.js b/pages/ucenter/settings/settings.test.js index 8cb05e5d9c803f50599b6a4e00968e924108ad09..f28ae0f1bbd764900125cc7adbf82ec5c2d86208 100644 --- a/pages/ucenter/settings/settings.test.js +++ b/pages/ucenter/settings/settings.test.js @@ -8,55 +8,35 @@ describe('pages/ucenter/settings/settings', () => { page = await program.navigateTo('/pages/ucenter/settings/settings') await page.waitFor(500) }) - - - + + it('切换语言', async () => { - console.log(await page.data('uniToken'),'uniToken-------------------------'); - // await page.callMethod('changeLanguage') 弹框不支持点击 - console.log((await program.currentPage()).path); - if (process.env.UNI_PLATFORM === "app-plus") { //清理缓存 await page.callMethod('clearTmp') console.log("clearTmp: -------------"); - - - - console.log(await page.data('pushIsOn'),"pushIsOn-------------"); - - - const pushRes = await page.data('pushIsOn') - - if(pushRes == "wait"){ + console.log(await page.data('pushIsOn'), "pushIsOn-------------"); + const pushRes = await page.data('pushIsOn') + if (pushRes == "wait") { await page.callMethod('pushServer.off') - console.log("pushServer---------"); } - - } - - - - - - }) - - - it('退出登录', async () => { - const perPage = await page.$('.content') - const uList = await perPage.$('.userInfo-class') - await page.waitFor(300) - const getTokenRes = await page.waitFor(async()=>{ + + + /* it('退出登录', async () => { + const getTokenRes = await page.waitFor(async () => { return await page.data('uniToken') }) - console.log("getTokenRes: ",getTokenRes); - await page.callMethod('clickLogout') - console.log((await program.currentPage()).path); + console.log("getTokenRes: ", getTokenRes); + + console.log(await page.data('uniToken'), 'uniToken-------------------------'); + if(getTokenRes){ + await page.callMethod('clickLogout') + } }) - - -}); \ No newline at end of file + */ + +}); diff --git a/pages/ucenter/userinfo/bind-mobile/bind-mobile.test.js b/pages/ucenter/userinfo/bind-mobile/bind-mobile.test.js index c96f3b318384cd0435023ae50e86e4b19fd97db2..2c87550f20bdedee9fdf201d51e147677f99052e 100644 --- a/pages/ucenter/userinfo/bind-mobile/bind-mobile.test.js +++ b/pages/ucenter/userinfo/bind-mobile/bind-mobile.test.js @@ -22,6 +22,7 @@ describe('pages/ucenter/userinfo/bind-mobile/bind-mobile.vue', () => { await page.waitFor(300) }else{ const codebtn = await page.$('.short-code-btn') + console.log("codebtn: ",codebtn); const sendMsgRes = await codebtn.callMethod('sendMsg') await page.waitFor(300) } diff --git a/pages/ucenter/userinfo/userinfo.test.js b/pages/ucenter/userinfo/userinfo.test.js index 2ee282aa58e6d72e52c49571f697112d51b90d70..0523001884fcadc4227747fed988a9164e4a39bf 100644 --- a/pages/ucenter/userinfo/userinfo.test.js +++ b/pages/ucenter/userinfo/userinfo.test.js @@ -4,7 +4,7 @@ describe('pages/ucenter/userinfo/userinfo.vue', () => { let page beforeAll(async () => { - page = await program.redirectTo('/pages/ucenter/userinfo/userinfo') + page = await program.navigateTo('/pages/ucenter/userinfo/userinfo') await page.waitFor(500) }) @@ -15,15 +15,19 @@ describe('pages/ucenter/userinfo/userinfo.vue', () => { }) console.log("getTokenRes: ",getTokenRes); - // if(getTokenRes){ - // const nicknameRes = await page.callMethod("setNickname","数字天堂DCloud") - // await page.waitFor(300) - // console.log("nicknameRes: ",nicknameRes); - // expect(nicknameRes.updated).toBe(1) - // } + var name = "数字天堂DCloud" + Math.round(Math.random()*10); + console.log("name: ",name); + + if(getTokenRes){ + const nicknameRes = await page.callMethod("setNickname",name) + await page.waitFor(300) + console.log("nicknameRes: ",nicknameRes); + expect(nicknameRes.updated).toBe(1) + } }) it('绑定手机号', async () => { + console.log(await page.data('uniToken'),"-------------------------"); await page.callMethod('bindMobileBySmsCode') await page.waitFor(300) console.log((await program.currentPage()).path); diff --git a/static/screenshot/about.png b/static/screenshot/about.png index 77d80e2fc2634d9de8559a9b4442eff5bf16c005..714703fb28cc83a9dbed50c1a119ef90c9001dd5 100644 Binary files a/static/screenshot/about.png and b/static/screenshot/about.png differ diff --git a/testSequencer.js b/testSequencer.js index 7206f0e52a5b21dfdbc0a6d2b9f0a14566b5518d..54c11ff5deaa4a950bc288da6e4258ea8d7bf610 100644 --- a/testSequencer.js +++ b/testSequencer.js @@ -1,5 +1,5 @@ const Sequencer = require("@jest/test-sequencer").default; -const sortTestFilenames = ["register.test.js","pwd-login.test.js","userinfo.test.js"]; +const sortTestFilenames = ["register.test.js","pwd-login.test.js","userinfo.test.js","search.test.js"]; class CustomSequencer extends Sequencer { sort(tests) { // 测试例排序