提交 2350677f 编写于 作者: A Anne_LXM

update test

上级 25de9c71
...@@ -4,19 +4,14 @@ describe('pages/clientDB/clientDB-api/clientDB-api.nvue', () => { ...@@ -4,19 +4,14 @@ describe('pages/clientDB/clientDB-api/clientDB-api.nvue', () => {
beforeAll(async () => { beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/clientDB/clientDB-api/clientDB-api') page = await program.reLaunch('/pages/clientDB/clientDB-api/clientDB-api')
if (process.env.UNI_PLATFORM === "h5"|| process.env.UNI_PLATFORM === "app-plus") { await page.waitFor(1000)
await page.waitFor(1000)
}
if (process.env.UNI_PLATFORM === "mp-weixin") {
await page.waitFor(1000);//微信等待
}
page = await program.currentPage() page = await program.currentPage()
}) })
beforeEach(async()=>{ // beforeEach(async()=>{
jest.setTimeout(30000) // jest.setTimeout(30000)
return false // return false
}) // })
it('查图书book表的数据', async () => { it('查图书book表的数据', async () => {
expect.assertions(1); expect.assertions(1);
...@@ -36,11 +31,9 @@ describe('pages/clientDB/clientDB-api/clientDB-api.nvue', () => { ...@@ -36,11 +31,9 @@ describe('pages/clientDB/clientDB-api/clientDB-api.nvue', () => {
const numBox1 = await page.$('.num-box1') const numBox1 = await page.$('.num-box1')
const pageSize = await numBox1.property('value') const pageSize = await numBox1.property('value')
console.log("pageSize: ",pageSize);
//获取当前页 //获取当前页
const numBox2 = await page.$('.num-box2') const numBox2 = await page.$('.num-box2')
const pageCurrent = await numBox2.property('value') const pageCurrent = await numBox2.property('value')
console.log("pageCurrent: ",pageCurrent);
if (pageSize === 1 && pageCurrent == 2) { if (pageSize === 1 && pageCurrent == 2) {
const orderData = await page.callMethod('getPageData', 'order') const orderData = await page.callMethod('getPageData', 'order')
......
...@@ -222,21 +222,24 @@ ...@@ -222,21 +222,24 @@
uni.hideLoading() uni.hideLoading()
} }
}, },
getData(tableName) { async getData(tableName) {
console.log(tableName); console.log(tableName);
uni.showLoading({ uni.showLoading({
mask: true mask: true
}); });
// 客户端联表查询 // 客户端联表查询
db.collection(tableName) return await db.collection(tableName)
.get() .get()
.then(res => { .then(res => {
this.$refs.alertCode.open(res.result) this.$refs.alertCode.open(res.result)
return res.result.data
}).catch(err => { }).catch(err => {
console.error(err) console.error(err)
return err
}) })
.finally((e) => { .finally((e) => {
uni.hideLoading() uni.hideLoading()
console.log(e);
}) })
}, },
async getOrderByGetTemp() { async getOrderByGetTemp() {
...@@ -248,107 +251,119 @@ ...@@ -248,107 +251,119 @@
uni.hideLoading() uni.hideLoading()
this.$refs.alertCode.open(res.result) this.$refs.alertCode.open(res.result)
}, },
getOrder() { async getOrder() {
//直接关联多个表为虚拟表再进行查询。仅数据表字段内容较少时使用,否者将查询超时 //直接关联多个表为虚拟表再进行查询。仅数据表字段内容较少时使用,否者将查询超时
uni.showLoading({mask: true}); uni.showLoading({mask: true});
// 客户端联表查询 // 客户端联表查询
db.collection('order,book') // 注意collection方法内需要传入所有用到的表名,用逗号分隔,主表需要放在第一位 return await db.collection('order,book') // 注意collection方法内需要传入所有用到的表名,用逗号分隔,主表需要放在第一位
//.where('book_id.title == "三国演义"') // 查询order表内书名为“三国演义”的订单 //.where('book_id.title == "三国演义"') // 查询order表内书名为“三国演义”的订单
.field('book_id{title,author} as books_info,quantity') // 这里联表查询book表返回book表内的title、book表内的author、order表内的quantity .field('book_id{title,author} as books_info,quantity') // 这里联表查询book表返回book表内的title、book表内的author、order表内的quantity
.get() .get()
.then(res => { .then(res => {
this.$refs.alertCode.open(res.result) this.$refs.alertCode.open(res.result)
return res.result.data
}).catch(err => { }).catch(err => {
console.error(err) console.error(err)
return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
}, },
getOneBook() { async getOneBook() {
uni.showLoading({ uni.showLoading({
mask: true mask: true
}); });
// 客户端联表查询 // 客户端联表查询
db.collection('book') return await db.collection('book')
.get({ .get({
getOne: true getOne: true
}) })
.then(res => { .then(res => {
this.$refs.alertCode.open(res.result) this.$refs.alertCode.open(res.result)
return res.result.data
}).catch(err => { }).catch(err => {
console.error(err) console.error(err)
return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
}, },
getBookTitle() { async getBookTitle() {
uni.showLoading({ uni.showLoading({
mask: true mask: true
}); });
// 客户端联表查询 // 客户端联表查询
db.collection('book') return await db.collection('book')
.field('title') .field('title')
.get() .get()
.then(res => { .then(res => {
this.$refs.alertCode.open(res.result) this.$refs.alertCode.open(res.result)
return res.result.data
}).catch(err => { }).catch(err => {
console.error(err) console.error(err)
return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
}, },
getBookAs() { async getBookAs() {
uni.showLoading({ uni.showLoading({
mask: true mask: true
}); });
// 客户端联表查询 // 客户端联表查询
db.collection('book') return await db.collection('book')
.field('title,author as book_author') .field('title,author as book_author')
.get() .get()
.then(res => { .then(res => {
this.$refs.alertCode.open(res.result) this.$refs.alertCode.open(res.result)
return res.result.data
}).catch(err => { }).catch(err => {
console.error(err) console.error(err)
return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
}, },
getOrderOrderBy(str) { async getOrderOrderBy(str) {
uni.showLoading({ uni.showLoading({
mask: true mask: true
}); });
db.collection('order') return await db.collection('order')
.orderBy(str) .orderBy(str)
.get() .get()
.then(res => { .then(res => {
this.$refs.alertCode.open(res.result) this.$refs.alertCode.open(res.result)
return res.result.data
}).catch(err => { }).catch(err => {
console.error(err) console.error(err)
return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
}, },
getBookHasCount() { async getBookHasCount() {
uni.showLoading({ uni.showLoading({
mask: true mask: true
}); });
db.collection('book') return await db.collection('book')
.get({ .get({
"getCount": true "getCount": true
}) })
.then(res => { .then(res => {
this.$refs.alertCode.open(res.result) this.$refs.alertCode.open(res.result)
return res.result
}).catch(err => { }).catch(err => {
console.error(err) console.error(err)
return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
}, },
getTreeFn() { async getTreeFn() {
uni.showLoading({ uni.showLoading({
mask: true mask: true
}); });
db.collection("department").get({ return await db.collection("department").get({
getTree: { getTree: {
limitLevel: 10, // 最大查询层级(不包含当前层级),可以省略默认10级,最大15,最小1 limitLevel: 10, // 最大查询层级(不包含当前层级),可以省略默认10级,最大15,最小1
// startWith: "parent_code==''" // 第一层级条件,此初始条件可以省略,不传startWith时默认从最顶级开始查询 // startWith: "parent_code==''" // 第一层级条件,此初始条件可以省略,不传startWith时默认从最顶级开始查询
...@@ -358,11 +373,13 @@ ...@@ -358,11 +373,13 @@
console.log("res: ",res); console.log("res: ",res);
const resdata = res.result.data const resdata = res.result.data
this.$refs.alertCode.open(resdata) this.$refs.alertCode.open(resdata)
return resdata
}).catch((err) => { }).catch((err) => {
uni.showModal({ uni.showModal({
content: err.message || '请求服务失败', content: err.message || '请求服务失败',
showCancel: false showCancel: false
}) })
return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
...@@ -378,6 +395,7 @@ ...@@ -378,6 +395,7 @@
console.log(res); console.log(res);
this.$refs.alertCode.open(res.result.data) this.$refs.alertCode.open(res.result.data)
uni.hideLoading() uni.hideLoading()
return res.result.data
} }
} }
} }
......
...@@ -3,14 +3,7 @@ describe('pages/clientDB/clientDB.vue', () => { ...@@ -3,14 +3,7 @@ describe('pages/clientDB/clientDB.vue', () => {
beforeAll(async () => { beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/clientDB/clientDB') page = await program.reLaunch('/pages/clientDB/clientDB')
await page.waitFor(1000)
if (process.env.UNI_PLATFORM === "h5" || process.env.UNI_PLATFORM === "app-plus") {
await page.waitFor(1000)
}
if (process.env.UNI_PLATFORM === "mp-weixin") {
await page.waitFor(1000)
}
page = await program.currentPage() page = await program.currentPage()
}) })
......
...@@ -4,14 +4,8 @@ describe('pages/clientDB/demo/demo.vue', () => { ...@@ -4,14 +4,8 @@ describe('pages/clientDB/demo/demo.vue', () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch( page = await program.reLaunch(
'/pages/clientDB/demo/demo') '/pages/clientDB/demo/demo')
if (process.env.UNI_PLATFORM === "h5"|| process.env.UNI_PLATFORM === "app-plus") { await page.waitFor(1000)
await page.waitFor(1000)
}
if (process.env.UNI_PLATFORM === "mp-weixin") {
await page.waitFor(1000);//微信等待
}
page = await program.currentPage() page = await program.currentPage()
// console.log("page-------------: ",page);
}) })
beforeEach(async()=>{ beforeEach(async()=>{
...@@ -20,7 +14,6 @@ describe('pages/clientDB/demo/demo.vue', () => { ...@@ -20,7 +14,6 @@ describe('pages/clientDB/demo/demo.vue', () => {
}) })
it('未登陆', async () => { it('未登陆', async () => {
const perPage = await page.$('.page') const perPage = await page.$('.page')
//底部角色控制条 //底部角色控制条
...@@ -91,7 +84,7 @@ describe('pages/clientDB/demo/demo.vue', () => { ...@@ -91,7 +84,7 @@ describe('pages/clientDB/demo/demo.vue', () => {
const auditorWrite = await page.callMethod('submitComment', '我是审核员11') const auditorWrite = await page.callMethod('submitComment', '我是审核员11')
const audId = auditorWrite.id const audId = auditorWrite.id
expect(audId).not.toBeUndefined(); expect(audId).not.toBeUndefined();
await page.waitFor(1000) await page.waitFor(800)
// 审核一条为通过 // 审核一条为通过
await page.callMethod('updateState', await page.callMethod('updateState',
{ {
...@@ -101,7 +94,7 @@ describe('pages/clientDB/demo/demo.vue', () => { ...@@ -101,7 +94,7 @@ describe('pages/clientDB/demo/demo.vue', () => {
}, },
audId audId
) )
await page.waitFor(1000) await page.waitFor(800)
//审核员更改留言 //审核员更改留言
const setUid = await page.setData({ const setUid = await page.setData({
...@@ -110,7 +103,7 @@ describe('pages/clientDB/demo/demo.vue', () => { ...@@ -110,7 +103,7 @@ describe('pages/clientDB/demo/demo.vue', () => {
const auditorUpdate = await page.callMethod('updateComment', const auditorUpdate = await page.callMethod('updateComment',
"我是审核员123" "我是审核员123"
) )
await page.waitFor(1000) await page.waitFor(800)
} }
......
...@@ -129,7 +129,6 @@ ...@@ -129,7 +129,6 @@
console.log("this.currentRole: ", this.currentRole); console.log("this.currentRole: ", this.currentRole);
}, },
async getNoticeData() { async getNoticeData() {
console.log('111111111111');
let res = await db.action('add_view_count') let res = await db.action('add_view_count')
.collection('notice') .collection('notice')
.field('data,_id,update_time,view_count') .field('data,_id,update_time,view_count')
...@@ -146,12 +145,12 @@ ...@@ -146,12 +145,12 @@
this.$refs.upDataDialog.open() this.$refs.upDataDialog.open()
} }
}, },
updateState(e, _id) { async updateState(e, _id) {
console.log(e.detail.value, _id); console.log(e.detail.value, _id);
uni.showLoading({ uni.showLoading({
mask: true mask: true
}); });
db.collection('comment') return await db.collection('comment')
.doc(_id) .doc(_id)
.update({ .update({
"state": e.detail.value / 1 "state": e.detail.value / 1
...@@ -163,11 +162,14 @@ ...@@ -163,11 +162,14 @@
duration: 3000 duration: 3000
}); });
console.log(code, message); console.log(code, message);
return message
}).catch(({code,message}) => { }).catch(({code,message}) => {
console.log(code, message); console.log(code, message);
return message
}).finally(e => { }).finally(e => {
uni.hideLoading() uni.hideLoading()
this.$refs.upDataDialog.close() this.$refs.upDataDialog.close()
return e
}) })
}, },
async updateComment(text) { async updateComment(text) {
...@@ -185,7 +187,7 @@ ...@@ -185,7 +187,7 @@
uni.showLoading({ uni.showLoading({
mask: true mask: true
}); });
await this.$refs.udb.update(this.activeNoticeId, {text}, { return await this.$refs.udb.update(this.activeNoticeId, {text}, {
action: "up_comment", action: "up_comment",
toastTitle: '修改成功', // toast提示语 toastTitle: '修改成功', // toast提示语
success: (res) => { // 更新成功后的回调 success: (res) => { // 更新成功后的回调
...@@ -203,10 +205,12 @@ ...@@ -203,10 +205,12 @@
} }
} }
}) })
return message
}, },
fail: (err) => { // 更新失败后的回调 fail: (err) => { // 更新失败后的回调
console.log("err: ",err); console.log("err: ",err);
const {message} = err const {message} = err
return message
}, },
complete: () => { // 完成后的回调 complete: () => { // 完成后的回调
uni.hideLoading() uni.hideLoading()
...@@ -224,11 +228,12 @@ ...@@ -224,11 +228,12 @@
return false return false
} }
this.$refs.dialog.close() this.$refs.dialog.close()
await db.collection('comment').add({ return await db.collection('comment').add({
text text
}).then(res => { }).then(res => {
console.log(res); console.log(res);
this.getNewData() this.getNewData()
return res.result
}).catch(({ }).catch(({
code, code,
message message
...@@ -246,6 +251,7 @@ ...@@ -246,6 +251,7 @@
}); });
} }
console.log(code, message); console.log(code, message);
return message
}) })
}, },
getNewData() { getNewData() {
......
...@@ -13,10 +13,10 @@ describe('pages/clientDB/permission-demo/permission-demo.vue', () => { ...@@ -13,10 +13,10 @@ describe('pages/clientDB/permission-demo/permission-demo.vue', () => {
page = await program.currentPage() page = await program.currentPage()
}) })
beforeEach(async()=>{ // beforeEach(async()=>{
jest.setTimeout(30000) // jest.setTimeout(30000)
return false // return false
}) // })
it('未登陆', async () => { it('未登陆', async () => {
......
...@@ -5,19 +5,14 @@ describe('pages/clientDB/permission-demo/readme.vue', () => { ...@@ -5,19 +5,14 @@ describe('pages/clientDB/permission-demo/readme.vue', () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch( page = await program.reLaunch(
'/pages/clientDB/permission-demo/readme') '/pages/clientDB/permission-demo/readme')
if (process.env.UNI_PLATFORM === "h5"|| process.env.UNI_PLATFORM === "app-plus" ) { await page.waitFor(1000)
await page.waitFor(1000)
}
if (process.env.UNI_PLATFORM === "mp-weixin") {
await page.waitFor(1000);//微信等待
}
// page = await program.currentPage() // page = await program.currentPage()
}) })
beforeEach(async()=>{ // beforeEach(async()=>{
jest.setTimeout(30000) // jest.setTimeout(30000)
return false // return false
}) // })
it('用户', async () => { it('用户', async () => {
...@@ -199,7 +194,7 @@ describe('pages/clientDB/permission-demo/readme.vue', () => { ...@@ -199,7 +194,7 @@ describe('pages/clientDB/permission-demo/readme.vue', () => {
const auditorRole = await page.data('currentRole') const auditorRole = await page.data('currentRole')
return auditorRole == 'auditor' return auditorRole == 'auditor'
}) })
console.log(auditor); // console.log(auditor);
if(auditor){ if(auditor){
...@@ -330,9 +325,6 @@ describe('pages/clientDB/permission-demo/readme.vue', () => { ...@@ -330,9 +325,6 @@ describe('pages/clientDB/permission-demo/readme.vue', () => {
} }
}) })
}) })
\ No newline at end of file
...@@ -221,9 +221,9 @@ ...@@ -221,9 +221,9 @@
urls:[url] urls:[url]
}) })
}, },
addFn(){ async addFn(){
uni.showLoading({mask:true}) uni.showLoading({mask:true})
ptDb.add({ return await ptDb.add({
nickname:"默认昵称", nickname:"默认昵称",
username:"默认姓名", username:"默认姓名",
phone:"18888888888" phone:"18888888888"
...@@ -234,6 +234,7 @@ ...@@ -234,6 +234,7 @@
showCancel: false, showCancel: false,
confirmText:"知道了" confirmText:"知道了"
}); });
return e
}).catch(err=>{ }).catch(err=>{
console.log(err); console.log(err);
uni.showModal({ uni.showModal({
...@@ -242,19 +243,21 @@ ...@@ -242,19 +243,21 @@
showCancel: false, showCancel: false,
confirmText:"知道了" confirmText:"知道了"
}); });
return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
}, },
removeFn(){ async removeFn(){
uni.showLoading({mask:true}) uni.showLoading({mask:true})
ptDb.remove().then(e=>{ return await ptDb.remove().then(e=>{
console.log(e,"123"); console.log(e,"123");
uni.showModal({ uni.showModal({
content: JSON.stringify(e.result), content: JSON.stringify(e.result),
showCancel: false, showCancel: false,
confirmText:"知道了" confirmText:"知道了"
}); });
return e
}).catch(err=>{ }).catch(err=>{
console.log(JSON.stringify(err)); console.log(JSON.stringify(err));
uni.showModal({ uni.showModal({
...@@ -263,6 +266,7 @@ ...@@ -263,6 +266,7 @@
showCancel: false, showCancel: false,
confirmText:"知道了" confirmText:"知道了"
}); });
return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
...@@ -270,10 +274,10 @@ ...@@ -270,10 +274,10 @@
updateNickname(self){ updateNickname(self){
}, },
updateFn(data,where={}){ async updateFn(data,where={}){
console.log(data); console.log(data);
uni.showLoading({mask:true}) uni.showLoading({mask:true})
ptDb.where(where).update(data) return await ptDb.where(where).update(data)
.then(e=>{ .then(e=>{
console.log(e); console.log(e);
uni.showModal({ uni.showModal({
...@@ -281,6 +285,7 @@ ...@@ -281,6 +285,7 @@
showCancel: false, showCancel: false,
confirmText:"知道了" confirmText:"知道了"
}); });
return e
}).catch(err=>{ }).catch(err=>{
if('nickname' in data){ if('nickname' in data){
uni.showModal({ uni.showModal({
...@@ -320,6 +325,7 @@ ...@@ -320,6 +325,7 @@
}); });
} }
console.log("错误------",err); console.log("错误------",err);
return err
/* uni.showModal({ /* uni.showModal({
title:"执行更新操作失败!", title:"执行更新操作失败!",
content: "schema配置了,更新该字段限:\n 1、数据创建者,2、审核员,3、当然还有无任何权限限制的管理员", content: "schema配置了,更新该字段限:\n 1、数据创建者,2、审核员,3、当然还有无任何权限限制的管理员",
...@@ -330,10 +336,10 @@ ...@@ -330,10 +336,10 @@
uni.hideLoading() uni.hideLoading()
}) })
}, },
getFn(field='uid,username,nickname,state'){ async getFn(field='uid,username,nickname,state'){
// console.time('getFn'); // console.time('getFn');
uni.showLoading({mask:true}) uni.showLoading({mask:true})
ptDb.field(field).get() return await ptDb.field(field).get()
.then(e=>{ .then(e=>{
// console.timeEnd('getFn'); // console.timeEnd('getFn');
console.log(e); console.log(e);
...@@ -347,6 +353,7 @@ ...@@ -347,6 +353,7 @@
confirmText:"知道了" confirmText:"知道了"
}); });
} }
return e.result
}).catch(err=>{ }).catch(err=>{
// console.timeEnd('getFn'); // console.timeEnd('getFn');
console.log(err,"err---"); console.log(err,"err---");
...@@ -356,6 +363,7 @@ ...@@ -356,6 +363,7 @@
showCancel: false, showCancel: false,
confirmText:"知道了" confirmText:"知道了"
}); });
return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
......
describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', () => { describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', () => {
let page let page,errMsgA,errMsgB;
beforeAll(async () => { beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch( page = await program.reLaunch(
'/pages/clientDB/permission-field-simple/permission-field-simple') '/pages/clientDB/permission-field-simple/permission-field-simple')
if (process.env.UNI_PLATFORM === "h5" || process.env.UNI_PLATFORM === "app-plus") { await page.waitFor(1000)
await page.waitFor(1000)
}
if (process.env.UNI_PLATFORM === "mp-weixin") {
await page.waitFor(1000);//微信等待
}
page = await program.currentPage() page = await program.currentPage()
// 权限校验未通过
// 未能获取当前用户信息:30205 | 当前用户为匿名身份
errMsgA = "权限校验未通过,参与权限校验的集合:[],请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error"
errMsgB = "权限校验未通过,未能获取当前用户信息,当前用户为匿名身份 ,参与权限校验的集合:[],请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error"
}) })
// beforeEach(async()=>{ // beforeEach(async()=>{
...@@ -34,7 +36,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -34,7 +36,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
return createUnloginIndex === 0 && createUnloginRole === 0 return createUnloginIndex === 0 && createUnloginRole === 0
}) })
console.log("createUnlogin: ",createUnlogin); // console.log("createUnlogin: ",createUnlogin);
const createA = await page.callMethod('myFn', { const createA = await page.callMethod('myFn', {
"type": "create", "type": "create",
...@@ -64,7 +66,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -64,7 +66,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
"type": "create", "type": "create",
"index": 2, "index": 2,
}) })
expect(createC).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(createC).toBe(errMsgB)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "create", "type": "create",
...@@ -91,14 +93,14 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -91,14 +93,14 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
const readUnloginRole = await page.data('currentRole') const readUnloginRole = await page.data('currentRole')
return readUnloginIndex === 1 && readUnloginRole === 0 return readUnloginIndex === 1 && readUnloginRole === 0
}) })
console.log("readUnlogin: ",readUnlogin); // console.log("readUnlogin: ",readUnlogin);
const readA = await page.callMethod('myFn', { const readA = await page.callMethod('myFn', {
"type": "read", "type": "read",
"index": 0 "index": 0
}) })
console.log("readA: ",readA); // console.log("readA: ",readA);
// expect(readA).toBe('权限校验未通过') expect(readA).toBe(errMsgB)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "read", "type": "read",
...@@ -110,7 +112,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -110,7 +112,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
"type": "read", "type": "read",
"index": 1 "index": 1
}) })
expect(readB).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(readB).toBe(errMsgB)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "read", "type": "read",
...@@ -122,7 +124,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -122,7 +124,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
"type": "read", "type": "read",
"index": 2 "index": 2
}) })
expect(readC).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(readC).toBe(errMsgB)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "read", "type": "read",
...@@ -146,14 +148,14 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -146,14 +148,14 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
const updateUnloginRole = await page.data('currentRole') const updateUnloginRole = await page.data('currentRole')
return updateUnloginIndex === 2 && updateUnloginRole === 0 return updateUnloginIndex === 2 && updateUnloginRole === 0
}) })
console.log("updateUnlogin: ",updateUnlogin); // console.log("updateUnlogin: ",updateUnlogin);
const updateA = await page.callMethod('myFn', { const updateA = await page.callMethod('myFn', {
"type": "update", "type": "update",
"index": 0 "index": 0
}) })
console.log("updateA: ",updateA); // console.log("updateA: ",updateA);
// expect(updateA).toBe('权限校验未通过') expect(updateA).toBe(errMsgB)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "update", "type": "update",
...@@ -165,7 +167,8 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -165,7 +167,8 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
"type": "update", "type": "update",
"index": 1 "index": 1
}) })
expect(updateB).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') // expect(updateB).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份')
expect(updateB).toBe(errMsgB)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "update", "type": "update",
...@@ -177,7 +180,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -177,7 +180,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
"type": "update", "type": "update",
"index": 2 "index": 2
}) })
expect(updateC).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(updateC).toBe(errMsgB)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "update", "type": "update",
...@@ -211,8 +214,8 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -211,8 +214,8 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
"type": "create", "type": "create",
"index": 0, "index": 0,
}) })
console.log("createUserA: ",createUserA); // console.log("createUserA: ",createUserA);
// expect(createUserA).toBe('[permission-test-10.ip.write]权限校验未通过') expect(createUserA).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "create", "type": "create",
...@@ -260,13 +263,13 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -260,13 +263,13 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
return readUserIndex === 1 && readUserRole == 'user' return readUserIndex === 1 && readUserRole == 'user'
}) })
console.log("readUser: ",readUser); // console.log("readUser: ",readUser);
const readUserA = await page.callMethod('myFn', { const readUserA = await page.callMethod('myFn', {
"type": "read", "type": "read",
"index": 0 "index": 0
}) })
expect(readUserA).toBe('权限校验未通过') expect(readUserA).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "read", "type": "read",
...@@ -289,7 +292,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -289,7 +292,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
"type": "read", "type": "read",
"index": 2 "index": 2
}) })
expect(readUserB).toBe('权限校验未通过') expect(readUserB).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "read", "type": "read",
...@@ -320,7 +323,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -320,7 +323,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
"type": "update", "type": "update",
"index": 0 "index": 0
}) })
expect(updateUserA).toBe('权限校验未通过') expect(updateUserA).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "update", "type": "update",
...@@ -343,7 +346,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -343,7 +346,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
"type": "update", "type": "update",
"index": 2 "index": 2
}) })
expect(updateUserB).toBe('权限校验未通过') expect(updateUserB).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "update", "type": "update",
...@@ -375,8 +378,9 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -375,8 +378,9 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
"type": "create", "type": "create",
"index": 0, "index": 0,
}) })
console.log("createAuditorA: ",createAuditorA); // console.log("createAuditorA: ",createAuditorA);
// expect(createAuditorA).toBe('[permission-test-10.ip.write]权限校验未通过') // expect(createAuditorA).toBe('[permission-test-10.ip.write]权限校验未通过')
expect(createAuditorA).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "create", "type": "create",
...@@ -428,7 +432,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -428,7 +432,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
"type": "read", "type": "read",
"index": 0 "index": 0
}) })
expect(readAuditorA).toBe('权限校验未通过') expect(readAuditorA).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "read", "type": "read",
...@@ -479,7 +483,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', ...@@ -479,7 +483,7 @@ describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue',
"type": "update", "type": "update",
"index": 0 "index": 0
}) })
expect(updateAuditorA).toBe('权限校验未通过') expect(updateAuditorA).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "update", "type": "update",
......
...@@ -184,6 +184,7 @@ ...@@ -184,6 +184,7 @@
} }
console.log("res: ",res); console.log("res: ",res);
this.$refs.alertCode.open(res.result) this.$refs.alertCode.open(res.result)
return res
} catch (err) { } catch (err) {
console.log('TODO handle the exception', err); console.log('TODO handle the exception', err);
uni.showModal({ uni.showModal({
...@@ -191,6 +192,7 @@ ...@@ -191,6 +192,7 @@
content: item.explain +''+ this.typeText+'字段'+item.field+'' + (item.explain_end?item.explain_end:''), content: item.explain +''+ this.typeText+'字段'+item.field+'' + (item.explain_end?item.explain_end:''),
showCancel: false showCancel: false
}); });
return err.message
} finally{ } finally{
uni.hideLoading() uni.hideLoading()
} }
......
describe('pages/clientDB/permission-table-compound/permission-table-compound.vue', () => { describe('pages/clientDB/permission-table-compound/permission-table-compound.vue', () => {
let page let page,errMsgA,errMsgB;
beforeAll(async () => { beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch( page = await program.reLaunch(
'/pages/clientDB/permission-table-compound/permission-table-compound') '/pages/clientDB/permission-table-compound/permission-table-compound')
if (process.env.UNI_PLATFORM === "h5" || process.env.UNI_PLATFORM === "app-plus") { if (process.env.UNI_PLATFORM === "h5" || process.env.UNI_PLATFORM === "app-plus") {
await page.waitFor(1000) await page.waitFor(500)
} }
if (process.env.UNI_PLATFORM === "mp-weixin") { if (process.env.UNI_PLATFORM === "mp-weixin") {
await page.waitFor(1000);//微信等待 await page.waitFor(1000);//微信等待
} }
// page = await program.currentPage()
// console.log("page------------------: ",page); errMsgA = "权限校验未通过,参与权限校验的集合:[],请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error"
errMsgB = "权限校验未通过,未能获取当前用户信息,当前用户为匿名身份 ,参与权限校验的集合:[],请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error"
// page = await program.currentPage()
}) })
// beforeEach(async()=>{
// jest.setTimeout(30000)
// return false
// })
it('创建--未登陆', async () => { it('创建--未登陆', async () => {
const perPage = await page.$('.page') const perPage = await page.$('.page')
...@@ -44,7 +41,7 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue ...@@ -44,7 +41,7 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue
"type": "create", "type": "create",
"index": 1 "index": 1
}) })
// expect(createA).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(createA).toBe(errMsgB)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "create", "type": "create",
...@@ -91,13 +88,13 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue ...@@ -91,13 +88,13 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue
"type": "read", "type": "read",
"index": 0 "index": 0
}) })
expect(readB).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(readB).toBe(errMsgB)
const readC = await page.callMethod('myFn', { const readC = await page.callMethod('myFn', {
"type": "read", "type": "read",
"index": 1 "index": 1
}) })
expect(readC).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(readC).toBe(errMsgB)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "read", "type": "read",
...@@ -105,8 +102,6 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue ...@@ -105,8 +102,6 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue
"action": "add_view_count" "action": "add_view_count"
}) })
}) })
it('更新--未登陆', async () => { it('更新--未登陆', async () => {
...@@ -137,20 +132,20 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue ...@@ -137,20 +132,20 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue
"index": 0, "index": 0,
"where": "create_time > 1613534788761" "where": "create_time > 1613534788761"
}) })
expect(updateA).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(updateA).toBe(errMsgB)
const updateB = await page.callMethod('myFn', { const updateB = await page.callMethod('myFn', {
"type": "update", "type": "update",
"index": 0 "index": 0
}) })
console.log("updateB: ",updateB); // console.log("updateB: ",updateB);
// expect(updateB).toBe('权限校验未通过') // expect(updateB).toBe('权限校验未通过')
const updateC = await page.callMethod('myFn', { const updateC = await page.callMethod('myFn', {
"type": "update", "type": "update",
"index": 1 "index": 1
}) })
expect(updateC).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(updateC).toBe(errMsgB)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "update", "type": "update",
...@@ -159,7 +154,6 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue ...@@ -159,7 +154,6 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue
}) })
}) })
it('删除--未登陆', async () => { it('删除--未登陆', async () => {
...@@ -191,7 +185,7 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue ...@@ -191,7 +185,7 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue
"index": 0, "index": 0,
"where": "create_time > 1613534788761" "where": "create_time > 1613534788761"
}) })
expect(deleteA).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(deleteA).toBe(errMsgB)
const deleteB = await page.callMethod('myFn', { const deleteB = await page.callMethod('myFn', {
"type": "delete", "type": "delete",
...@@ -204,7 +198,7 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue ...@@ -204,7 +198,7 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue
"type": "delete", "type": "delete",
"index": 1 "index": 1
}) })
expect(deleteC).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(deleteC).toBe(errMsgB)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "delete", "type": "delete",
...@@ -212,13 +206,10 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue ...@@ -212,13 +206,10 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue
"action": "add_view_count" "action": "add_view_count"
}) })
}) })
it('创建--用户', async () => { it('创建--用户', async () => {
const perPage = await page.$('.page') const perPage = await page.$('.page')
//头部操作控制条 //头部操作控制条
...@@ -344,7 +335,7 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue ...@@ -344,7 +335,7 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue
"type": "update", "type": "update",
"index": 0 "index": 0
}) })
expect(updateUserB).toBe('权限校验未通过') expect(updateUserB).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "update", "type": "update",
...@@ -389,13 +380,13 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue ...@@ -389,13 +380,13 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue
"index": 0, "index": 0,
"where": "create_time > 1613534788761" "where": "create_time > 1613534788761"
}) })
expect(deleteUserA).toBe('权限校验未通过') expect(deleteUserA).toBe(errMsgA)
const deleteUserB = await page.callMethod('myFn', { const deleteUserB = await page.callMethod('myFn', {
"type": "delete", "type": "delete",
"index": 0 "index": 0
}) })
expect(deleteUserB).toBe('权限校验未通过') expect(deleteUserB).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "delete", "type": "delete",
...@@ -532,7 +523,7 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue ...@@ -532,7 +523,7 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue
"type": "update", "type": "update",
"index": 0 "index": 0
}) })
expect(updateAuditorA).toBe('权限校验未通过') expect(updateAuditorA).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "update", "type": "update",
...@@ -582,7 +573,7 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue ...@@ -582,7 +573,7 @@ describe('pages/clientDB/permission-table-compound/permission-table-compound.vue
"type": "delete", "type": "delete",
"index": 0 "index": 0
}) })
expect(deleteAuditorB).toBe('权限校验未通过') expect(deleteAuditorB).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "delete", "type": "delete",
......
...@@ -158,6 +158,7 @@ ...@@ -158,6 +158,7 @@
} }
console.log("res: ",res); console.log("res: ",res);
this.$refs.alertCode.open(res.result) this.$refs.alertCode.open(res.result)
return res
} catch (err) { } catch (err) {
console.log('TODO handle the exception', err); console.log('TODO handle the exception', err);
uni.showModal({ uni.showModal({
...@@ -165,6 +166,7 @@ ...@@ -165,6 +166,7 @@
content: item.explain +''+ this.typeText+'数据】' + (item.explain_end?item.explain_end:''), content: item.explain +''+ this.typeText+'数据】' + (item.explain_end?item.explain_end:''),
showCancel: false showCancel: false
}); });
return err.message
} finally{ } finally{
uni.hideLoading() uni.hideLoading()
} }
......
describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', () => { describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', () => {
let page let page,errMsgA,errMsgB,errMsgC;
beforeAll(async () => { beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch( page = await program.reLaunch(
'/pages/clientDB/permission-table-simple/permission-table-simple') '/pages/clientDB/permission-table-simple/permission-table-simple')
if (process.env.UNI_PLATFORM === "h5" || process.env.UNI_PLATFORM === "app-plus") {
await page.waitFor(1000) await page.waitFor(1000)
}
if (process.env.UNI_PLATFORM === "mp-weixin") { errMsgA = "权限校验未通过,参与权限校验的集合:[],请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error"
await page.waitFor(1000);//微信等待
} errMsgB = "权限校验未通过,未能获取当前用户信息,当前用户为匿名身份 ,参与权限校验的集合:[],请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error"
errMsgC = "未能获取当前用户信息:当前用户为匿名身份"
page = await program.currentPage() page = await program.currentPage()
}) })
// beforeEach(async()=>{ beforeEach(async()=>{
// jest.setTimeout(30000) jest.setTimeout(20000)
// return false return false
// }) })
it('创建--未登陆', async () => { it('创建--未登陆', async () => {
...@@ -43,12 +46,13 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -43,12 +46,13 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
console.log(createUnlogin, "创建--未登陆"); console.log(createUnlogin, "创建--未登陆");
if (createUnlogin) { if (createUnlogin) {
// 允许任何角色创建本表
await page.callMethod('myFn', { const createData = await page.callMethod('myFn', {
"type": "create", "type": "create",
"index": 0 "index": 0
}) })
expect(createData.success).toBeTruthy()
const createA = await page.callMethod('myFn', { const createA = await page.callMethod('myFn', {
"type": "create", "type": "create",
"index": 1 "index": 1
...@@ -65,7 +69,6 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -65,7 +69,6 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "create", "type": "create",
"index": 5 "index": 5
}) })
// console.log("createC: ", createC);
// expect(createC).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') // expect(createC).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份')
...@@ -73,10 +76,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -73,10 +76,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "create", "type": "create",
"index": 6 "index": 6
}) })
// expect(createD.errMsg).toBe(errMsgB)
console.log("createD: =================",createD);
// expect(createD.id).toBeTruthy()
// expect(createD).toBe('[permission-test-7.create]权限校验未通过')
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "create", "type": "create",
...@@ -107,52 +107,53 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -107,52 +107,53 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
//console.log(readUnlogin, '读取--未登陆'); //console.log(readUnlogin, '读取--未登陆');
if (readUnlogin) { if (readUnlogin) {
// 含义解释:允许任何角色【读取】
await page.callMethod('myFn', { const readAll = await page.callMethod('myFn', {
"type": "read", "type": "read",
"index": 0 "index": 0
}) })
expect(readAll.errCode).toBe(0)
// 禁止任何角色读取
const readA = await page.callMethod('myFn', { const readA = await page.callMethod('myFn', {
"type": "read", "type": "read",
"index": 1 "index": 1
}) })
//console.log(readA,"readA---------");
//expect(readA).toBe('权限校验未通过') //expect(readA).toBe('权限校验未通过')
const readB = await page.callMethod('myFn', { const readB = await page.callMethod('myFn', {
"type": "read", "type": "read",
"index": 2 "index": 2
}) })
expect(readB).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(readB.errMsg).toBe(errMsgB)
// 只能读取自己创建的数据
const readC = await page.callMethod('myFn', { const readC = await page.callMethod('myFn', {
"type": "create", "type": "create",
"index": 3 "index": 3
}) })
expect(readC).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') // expect(readC.errMsg).toBe(errMsgB)
const readD = await page.callMethod('myFn', { const readD = await page.callMethod('myFn', {
"type": "read", "type": "read",
"index": 3, "index": 3,
"where": "uid == $env.uid" "where": "uid == $env.uid"
}) })
expect(readD).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(readD.errMsg).toBe(errMsgC)
const readE = await page.callMethod('myFn', { const readE = await page.callMethod('myFn', {
"type": "read", "type": "read",
"index": 3 "index": 3
}) })
expect(readE).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') // expect(readE.errCode).toBe(0)
const readF = await page.callMethod('myFn', { const readF = await page.callMethod('myFn', {
"type": "create", "type": "create",
"index": 4 "index": 4
}) })
expect(readF).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') // expect(readF.errCode).toBe(0)
await page.callMethod('myFn', { await page.callMethod('myFn', {
...@@ -165,29 +166,27 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -165,29 +166,27 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "read", "type": "read",
"index": 4 "index": 4
}) })
// 限审核员读取
const readG = await page.callMethod('myFn', { const readG = await page.callMethod('myFn', {
"type": "create", "type": "create",
"index": 5 "index": 5
}) })
expect(readG).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(readG.errMsg).toBe(errMsgC)
const readH = await page.callMethod('myFn', { const readH = await page.callMethod('myFn', {
"type": "create", "type": "create",
"index": 6 "index": 6
}) })
console.log("readH: =================",readH); expect(readH.errMsg).toBe(errMsgB)
expect(readH).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份')
// expect(readH).toBe('[permission-test-7.create]权限校验未通过') // expect(readH).toBe('[permission-test-7.create]权限校验未通过')
await page.callMethod('myFn', { const actionRead = await page.callMethod('myFn', {
"type": "read", "type": "read",
"index": 6, "index": 6,
"action": "add_view_count" "action": "add_view_count"
}) })
expect(actionRead.errCode).toBe(0)
} }
}) })
...@@ -222,42 +221,40 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -222,42 +221,40 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "update", "type": "update",
"index": 1 "index": 1
}) })
console.log("updateA:----------------- ",updateA); expect(updateA.errMsg).toBe(errMsgB)
expect(updateA).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份')
// expect(updateA).toBe('权限校验未通过')
const updateB = await page.callMethod('myFn', { const updateB = await page.callMethod('myFn', {
"type": "update", "type": "update",
"index": 2 "index": 2
}) })
expect(updateB).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(updateB.errMsg).toBe(errMsgB)
const updateC = await page.callMethod('myFn', { const updateC = await page.callMethod('myFn', {
"type": "create", "type": "create",
"index": 3 "index": 3
}) })
expect(updateC).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(updateC.errMsg).toBe(errMsgC)
const updateD = await page.callMethod('myFn', { const updateD = await page.callMethod('myFn', {
"type": "update", "type": "update",
"index": 3, "index": 3,
"where": "uid == $env.uid" "where": "uid == $env.uid"
}) })
expect(updateD).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(updateD.errMsg).toBe(errMsgC)
const updateE = await page.callMethod('myFn', { const updateE = await page.callMethod('myFn', {
"type": "update", "type": "update",
"index": 3 "index": 3
}) })
expect(updateE).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(updateE.success).toBeTruthy()
const updateF = await page.callMethod('myFn', { const updateF = await page.callMethod('myFn', {
"type": "create", "type": "create",
"index": 4 "index": 4
}) })
expect(updateF).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') // expect(updateF.errCode).toBe(0)
await page.callMethod('myFn', { await page.callMethod('myFn', {
...@@ -276,14 +273,13 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -276,14 +273,13 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "update", "type": "update",
"index": 5 "index": 5
}) })
expect(updateG).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(updateG.errMsg).toBe(errMsgB)
const updateH = await page.callMethod('myFn', { const updateH = await page.callMethod('myFn', {
"type": "update", "type": "update",
"index": 6 "index": 6
}) })
// expect(updateH).toBe('权限校验未通过') // expect(updateH.errMsg).toBe(errMsgB)
expect(updateH).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份')
await page.callMethod('myFn', { await page.callMethod('myFn', {
...@@ -326,42 +322,42 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -326,42 +322,42 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "delete", "type": "delete",
"index": 1 "index": 1
}) })
console.log("deleteA: -------------------",deleteA); expect(deleteA.errMsg).toBe(errMsgB)
expect(deleteA).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份')
// expect(deleteA).toBe('权限校验未通过') // expect(deleteA).toBe('权限校验未通过')
const deleteB = await page.callMethod('myFn', { const deleteB = await page.callMethod('myFn', {
"type": "delete", "type": "delete",
"index": 2 "index": 2
}) })
expect(deleteB).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(deleteB.errMsg).toBe(errMsgB)
const deleteC = await page.callMethod('myFn', { const deleteC = await page.callMethod('myFn', {
"type": "create", "type": "create",
"index": 3 "index": 3
}) })
expect(deleteC).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(deleteC.errMsg).toBe(errMsgC)
const deleteD = await page.callMethod('myFn', { const deleteD = await page.callMethod('myFn', {
"type": "delete", "type": "delete",
"index": 3, "index": 3,
"where": "uid == $env.uid" "where": "uid == $env.uid"
}) })
expect(deleteD).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(deleteD.errMsg).toBe(errMsgC)
const deleteE = await page.callMethod('myFn', { const deleteE = await page.callMethod('myFn', {
"type": "delete", "type": "delete",
"index": 3 "index": 3
}) })
expect(deleteE).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(deleteE.success).toBeTruthy()
const deleteF = await page.callMethod('myFn', { const deleteF = await page.callMethod('myFn', {
"type": "create", "type": "create",
"index": 4 "index": 4
}) })
expect(deleteF).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') console.log('deleteF: ',deleteF);
expect(deleteF.errMsg).toBe(errMsgC)
await page.callMethod('myFn', { await page.callMethod('myFn', {
...@@ -380,14 +376,14 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -380,14 +376,14 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "delete", "type": "delete",
"index": 5 "index": 5
}) })
expect(deleteG).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') // expect(deleteG).toBe(errMsgB)
const deleteH = await page.callMethod('myFn', { const deleteH = await page.callMethod('myFn', {
"type": "delete", "type": "delete",
"index": 6 "index": 6
}) })
// expect(deleteH).toBe('权限校验未通过') console.log('deleteH: ',deleteH);
expect(deleteH).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份') expect(deleteH.errMsg).toBe(errMsgB)
await page.callMethod('myFn', { await page.callMethod('myFn', {
...@@ -432,9 +428,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -432,9 +428,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "create", "type": "create",
"index": 1 "index": 1
}) })
console.log("createUserA:---------------- ",createUserA); console.log('createUserA: ',createUserA);
expect(createUserA).toBe('权限校验未通过')
// expect(createUserA).toBe('[permission-test-2.create]权限校验未通过')
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "create", "type": "create",
...@@ -446,13 +440,11 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -446,13 +440,11 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"index": 5 "index": 5
}) })
// expect(createUserB).toBe('[permission-test-6.create]权限校验未通过') // expect(createUserB).toBe('[permission-test-6.create]权限校验未通过')
//未能获取当前用户信息:30205 | 当前用户为匿名身份
const createUserC = await page.callMethod('myFn', { const createUserC = await page.callMethod('myFn', {
"type": "create", "type": "create",
"index": 6 "index": 6
}) })
console.log("createUserC: ",createUserC);
// expect(createUserC.id).toBeTruthy() // expect(createUserC.id).toBeTruthy()
// expect(createUserC).toBe('[permission-test-7.create]权限校验未通过') // expect(createUserC).toBe('[permission-test-7.create]权限校验未通过')
...@@ -492,7 +484,8 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -492,7 +484,8 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "read", "type": "read",
"index": 1 "index": 1
}) })
expect(readUserA).toBe('权限校验未通过') // console.log('readUserA: ',readUserA);
// expect(readUserA.errMsg).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "read", "type": "read",
...@@ -535,14 +528,14 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -535,14 +528,14 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "read", "type": "read",
"index": 5 "index": 5
}) })
expect(readUserB).toBe('权限校验未通过') expect(readUserB.errMsg).toBe(errMsgA)
const readUserC = await page.callMethod('myFn', { const readUserC = await page.callMethod('myFn', {
"type": "read", "type": "read",
"index": 6 "index": 6
}) })
expect(readUserC).toBe('权限校验未通过') expect(readUserC.errMsg).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "read", "type": "read",
...@@ -583,7 +576,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -583,7 +576,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "update", "type": "update",
"index": 1 "index": 1
}) })
expect(updateUserA).toBe('权限校验未通过') expect(updateUserA.errMsg).toBe(errMsgA)
const updateUserB = await page.callMethod('myFn', { const updateUserB = await page.callMethod('myFn', {
"type": "update", "type": "update",
...@@ -631,13 +624,13 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -631,13 +624,13 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "update", "type": "update",
"index": 5 "index": 5
}) })
expect(updateUserC).toBe('权限校验未通过') expect(updateUserC.errMsg).toBe(errMsgA)
const updateUserD = await page.callMethod('myFn', { const updateUserD = await page.callMethod('myFn', {
"type": "update", "type": "update",
"index": 6 "index": 6
}) })
expect(updateUserD).toBe('权限校验未通过') expect(updateUserD.errMsg).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
...@@ -678,7 +671,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -678,7 +671,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "delete", "type": "delete",
"index": 1 "index": 1
}) })
expect(deleteUserA).toBe('权限校验未通过') expect(deleteUserA.errMsg).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "delete", "type": "delete",
...@@ -721,13 +714,13 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -721,13 +714,13 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "delete", "type": "delete",
"index": 5 "index": 5
}) })
expect(deleteUserB).toBe('权限校验未通过') expect(deleteUserB.errMsg).toBe(errMsgA)
const deleteUserC = await page.callMethod('myFn', { const deleteUserC = await page.callMethod('myFn', {
"type": "delete", "type": "delete",
"index": 6 "index": 6
}) })
expect(deleteUserC).toBe('权限校验未通过') expect(deleteUserC.errMsg).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "delete", "type": "delete",
...@@ -735,11 +728,6 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -735,11 +728,6 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"action": "add_view_count" "action": "add_view_count"
}) })
}) })
...@@ -772,9 +760,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -772,9 +760,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "create", "type": "create",
"index": 1 "index": 1
}) })
console.log("createAuditorA:------------",createAuditorA); expect(createAuditorA.errMsg).toBe(errMsgA)
expect(createAuditorA).toBe('权限校验未通过')
// expect(createAuditorA).toBe('[permission-test-2.create]权限校验未通过')
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "create", "type": "create",
...@@ -791,7 +777,6 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -791,7 +777,6 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "create", "type": "create",
"index": 6 "index": 6
}) })
console.log("createAuditorB: ",createAuditorB);
// expect(createAuditorB.id).toBeTruthy() // expect(createAuditorB.id).toBeTruthy()
// expect(createAuditorB).toBe('[permission-test-7.create]权限校验未通过') // expect(createAuditorB).toBe('[permission-test-7.create]权限校验未通过')
...@@ -831,7 +816,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -831,7 +816,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "read", "type": "read",
"index": 1 "index": 1
}) })
expect(readAuditorA).toBe('权限校验未通过') expect(readAuditorA.errMsg).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "read", "type": "read",
...@@ -882,7 +867,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -882,7 +867,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "read", "type": "read",
"index": 6 "index": 6
}) })
expect(readAuditorB).toBe('权限校验未通过') expect(readAuditorB.errMsg).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "read", "type": "read",
...@@ -924,7 +909,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -924,7 +909,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "update", "type": "update",
"index": 1 "index": 1
}) })
expect(updateAuditorA).toBe('权限校验未通过') expect(updateAuditorA.errMsg).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "update", "type": "update",
...@@ -973,7 +958,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -973,7 +958,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "update", "type": "update",
"index": 6 "index": 6
}) })
expect(updateAuditorB).toBe('权限校验未通过') expect(updateAuditorB.errMsg).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "update", "type": "update",
...@@ -1014,7 +999,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -1014,7 +999,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "delete", "type": "delete",
"index": 1 "index": 1
}) })
expect(deleteAuditorA).toBe('权限校验未通过') expect(deleteAuditorA.errMsg).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "delete", "type": "delete",
...@@ -1066,7 +1051,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -1066,7 +1051,7 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"type": "delete", "type": "delete",
"index": 6 "index": 6
}) })
expect(deleteAuditorB).toBe('权限校验未通过') expect(deleteAuditorB.errMsg).toBe(errMsgA)
await page.callMethod('myFn', { await page.callMethod('myFn', {
"type": "delete", "type": "delete",
...@@ -1398,12 +1383,6 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', ( ...@@ -1398,12 +1383,6 @@ describe('pages/clientDB/permission-table-simple/permission-table-simple.vue', (
"action": "add_view_count" "action": "add_view_count"
}) })
}) })
}) })
...@@ -203,6 +203,7 @@ ...@@ -203,6 +203,7 @@
} }
console.log("res: ",res); console.log("res: ",res);
this.$refs.alertCode.open(res.result) this.$refs.alertCode.open(res.result)
return res
} catch (err) { } catch (err) {
console.log('TODO handle the exception', err); console.log('TODO handle the exception', err);
uni.showModal({ uni.showModal({
...@@ -210,6 +211,7 @@ ...@@ -210,6 +211,7 @@
content: item.explain + '' + this.typeText + '数据】' + (item.explain_end ? item.explain_end : ''), content: item.explain + '' + this.typeText + '数据】' + (item.explain_end ? item.explain_end : ''),
showCancel: false showCancel: false
}); });
return err
} finally { } finally {
uni.hideLoading() uni.hideLoading()
} }
......
...@@ -3,12 +3,7 @@ describe('pages/clientDB/permission/permission.vue', () => { ...@@ -3,12 +3,7 @@ describe('pages/clientDB/permission/permission.vue', () => {
beforeAll(async () => { beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/clientDB/permission/permission') page = await program.reLaunch('/pages/clientDB/permission/permission')
if (process.env.UNI_PLATFORM === "h5"|| process.env.UNI_PLATFORM === "app-plus") { await page.waitFor(1000)
await page.waitFor(1000)
}
if (process.env.UNI_PLATFORM === "mp-weixin") {
await page.waitFor(1000);//微信等待
}
page = await program.currentPage() page = await program.currentPage()
}) })
......
...@@ -201,7 +201,7 @@ ...@@ -201,7 +201,7 @@
return arrJson return arrJson
}, },
async add(){ async add(){
await udb.add({ return await udb.add({
book_id:"add-test", book_id:"add-test",
quantity:Date.now() quantity:Date.now()
},{ },{
...@@ -212,13 +212,13 @@ ...@@ -212,13 +212,13 @@
} }
}) })
}, },
remove(){ async remove(){
const _id = udb.dataList[0]._id const _id = udb.dataList[0]._id
udb.remove(_id) return await udb.remove(_id)
}, },
update(){ async update(){
const _id = udb.dataList[0]._id const _id = udb.dataList[0]._id
udb.update(_id,{book_id:"这条数据被改"}, return await udb.update(_id,{book_id:"这条数据被改"},
{ {
success: (res) => { // 新增成功后的回调 success: (res) => { // 新增成功后的回调
this.getFn() this.getFn()
......
describe('pages/clientDB/validate/validate.vue', () => {
let page
beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/clientDB/validate/validate')
await page.waitFor(1000)
page = await program.currentPage()
})
beforeEach(async()=>{
jest.setTimeout(5000)
return false
})
it('点击切换navBar', async () => {
//expect.assertions(1);
const segmentedControl = await page.$('.segmented-control')
const seControl = await segmentedControl.$$('.segmented-control__item')
// console.log(await seControl[0].text());
expect(await seControl[0].text()).toBe('实例demo')
await seControl[1].tap()
await page.waitFor(300)
await seControl[2].tap()
await page.waitFor(300)
})
})
...@@ -4,12 +4,7 @@ describe('pages/cloudFunction/cloudFunction.vue', () => { ...@@ -4,12 +4,7 @@ describe('pages/cloudFunction/cloudFunction.vue', () => {
beforeAll(async () => { beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/cloudFunction/cloudFunction') page = await program.reLaunch('/pages/cloudFunction/cloudFunction')
if (process.env.UNI_PLATFORM === "h5"|| process.env.UNI_PLATFORM === "app-plus") { await page.waitFor(1000)
await page.waitFor(1000)
}
if (process.env.UNI_PLATFORM === "mp-weixin") {
await page.waitFor(1000);//微信等待
}
page = await program.currentPage() page = await program.currentPage()
}) })
......
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
return {} return {}
}, },
methods: { methods: {
add() { async add() {
uni.showLoading({ uni.showLoading({
title: '处理中...' title: '处理中...'
}) })
uniCloud.callFunction({ return await uniCloud.callFunction({
name: 'add', name: 'add',
data: { data: {
name: 'DCloud', name: 'DCloud',
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
showCancel: false showCancel: false
}) })
console.log(res) console.log(res)
return res.result.id
}).catch((err) => { }).catch((err) => {
uni.hideLoading() uni.hideLoading()
uni.showModal({ uni.showModal({
...@@ -52,7 +53,7 @@ ...@@ -52,7 +53,7 @@
return err return err
}) })
}, },
remove() { async remove() {
uni.showLoading({ uni.showLoading({
title: '处理中...' title: '处理中...'
}) })
...@@ -65,6 +66,7 @@ ...@@ -65,6 +66,7 @@
showCancel: false showCancel: false
}) })
console.log(res) console.log(res)
return res.result.msg
}).catch((err) => { }).catch((err) => {
uni.hideLoading() uni.hideLoading()
uni.showModal({ uni.showModal({
...@@ -72,13 +74,14 @@ ...@@ -72,13 +74,14 @@
showCancel: false showCancel: false
}) })
console.error(err) console.error(err)
return err
}) })
}, },
update() { async update() {
uni.showLoading({ uni.showLoading({
title: '处理中...' title: '处理中...'
}) })
uniCloud.callFunction({ return await uniCloud.callFunction({
name: 'update', name: 'update',
data: { data: {
name: 'DCloud', name: 'DCloud',
...@@ -92,6 +95,7 @@ ...@@ -92,6 +95,7 @@
showCancel: false showCancel: false
}) })
console.log(res) console.log(res)
return res.result.msg
}).catch((err) => { }).catch((err) => {
uni.hideLoading() uni.hideLoading()
uni.showModal({ uni.showModal({
...@@ -102,11 +106,11 @@ ...@@ -102,11 +106,11 @@
return err return err
}) })
}, },
get() { async get() {
uni.showLoading({ uni.showLoading({
title: '处理中...' title: '处理中...'
}) })
uniCloud.callFunction({ return await uniCloud.callFunction({
name: 'get' name: 'get'
}).then((res) => { }).then((res) => {
uni.hideLoading() uni.hideLoading()
...@@ -115,6 +119,7 @@ ...@@ -115,6 +119,7 @@
showCancel: false showCancel: false
}) })
console.log(res) console.log(res)
return res.result.data
}).catch((err) => { }).catch((err) => {
uni.hideLoading() uni.hideLoading()
uni.showModal({ uni.showModal({
...@@ -122,11 +127,12 @@ ...@@ -122,11 +127,12 @@
showCancel: false showCancel: false
}) })
console.error(err) console.error(err)
return err
}) })
}, },
useCommon() { async useCommon() {
console.log('请确保自己已经阅读并按照公用模块文档操作 https://uniapp.dcloud.io/uniCloud/cf-common') console.log('请确保自己已经阅读并按照公用模块文档操作 https://uniapp.dcloud.io/uniCloud/cf-common')
uniCloud.callFunction({ return await uniCloud.callFunction({
name: 'use-common' name: 'use-common'
}).then((res) => { }).then((res) => {
uni.hideLoading() uni.hideLoading()
...@@ -135,6 +141,7 @@ ...@@ -135,6 +141,7 @@
showCancel: false showCancel: false
}) })
console.log(res) console.log(res)
return res.result
}).catch((err) => { }).catch((err) => {
uni.hideLoading() uni.hideLoading()
uni.showModal({ uni.showModal({
...@@ -142,6 +149,7 @@ ...@@ -142,6 +149,7 @@
showCancel: false showCancel: false
}) })
console.error(err) console.error(err)
return err
}) })
}, },
toRedisPage(){ toRedisPage(){
......
...@@ -5,42 +5,36 @@ describe('pages/cloudObject/cloudObject.vue', () => { ...@@ -5,42 +5,36 @@ describe('pages/cloudObject/cloudObject.vue', () => {
let page; let page;
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch('/pages/cloudObject/cloudObject') page = await program.reLaunch('/pages/cloudObject/cloudObject')
console.log("page: ",page);
await page.waitFor(500); await page.waitFor(500);
}); });
it('云对象-检查标题',async()=>{ it('云对象-检查标题',async()=>{
expect.assertions(1); expect.assertions(1);
const title = await page.$('.title') const title = await page.$('.title')
console.log("title: ",await title.text());
expect(await title.text()).toBe('基础示例-云对象'); expect(await title.text()).toBe('基础示例-云对象');
}) })
it('新增一条数据',async()=>{ it('新增一条数据',async()=>{
expect.assertions(1); expect.assertions(1);
const addData = await page.callMethod('add') const addData = await page.callMethod('add')
console.log("addData: ",addData);
expect(addData).toBeDefined(); expect(addData).toBeDefined();
}) })
it('删除一条数据',async()=>{ it('删除一条数据',async()=>{
expect.assertions(1); expect.assertions(1);
const removeData = await page.callMethod('remove') const removeData = await page.callMethod('remove')
console.log("removeData: ",removeData);
expect(removeData).toBe('成功删除unicloud-test内第一条数据'); expect(removeData).toBe('成功删除unicloud-test内第一条数据');
}) })
it('修改数据',async()=>{ it('修改数据',async()=>{
expect.assertions(1); expect.assertions(1);
const updateData = await page.callMethod('update') const updateData = await page.callMethod('update')
console.log("updateData: ",updateData);
expect(updateData).toBeDefined(); expect(updateData).toBeDefined();
}) })
it('查询前10条数据',async()=>{ it('查询前10条数据',async()=>{
// expect.assertions(1); // expect.assertions(1);
const getTenData = await page.callMethod('get') const getTenData = await page.callMethod('get')
console.log("getTenData: ",getTenData);
console.log("getTenData.data.length: ",getTenData.data.length); console.log("getTenData.data.length: ",getTenData.data.length);
// expect(getTenData.length).not.toBeUndefined(); // expect(getTenData.length).not.toBeUndefined();
expect(getTenData.data.length).toBeGreaterThanOrEqual(1); expect(getTenData.data.length).toBeGreaterThanOrEqual(1);
...@@ -51,11 +45,8 @@ describe('pages/cloudObject/cloudObject.vue', () => { ...@@ -51,11 +45,8 @@ describe('pages/cloudObject/cloudObject.vue', () => {
it('使用公用模块',async()=>{ it('使用公用模块',async()=>{
expect.assertions(1); expect.assertions(1);
const useCommon = await page.callMethod('useCommon') const useCommon = await page.callMethod('useCommon')
console.log("useCommon: ",useCommon);
const record = {"secret":"abcdefg","version":"1.0.0"} const record = {"secret":"abcdefg","version":"1.0.0"}
expect(useCommon).toEqual(record); expect(useCommon).toEqual(record);
}) })
}); });
...@@ -102,6 +102,7 @@ ...@@ -102,6 +102,7 @@
showCancel: false showCancel: false
}) })
console.log(res) console.log(res)
return res
}).catch((err) => { }).catch((err) => {
uni.hideLoading() uni.hideLoading()
uni.showModal({ uni.showModal({
......
...@@ -4,24 +4,21 @@ describe('pages/storage/storage.nvue', () => { ...@@ -4,24 +4,21 @@ describe('pages/storage/storage.nvue', () => {
beforeAll(async () => { beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/storage/storage') page = await program.reLaunch('/pages/storage/storage')
if (process.env.UNI_PLATFORM === "h5"|| process.env.UNI_PLATFORM === "app-plus") { await page.waitFor(300)
await page.waitFor(1000)
}
if (process.env.UNI_PLATFORM === "mp-weixin") {
await page.waitFor(1000);//微信等待
}
page = await program.currentPage() page = await program.currentPage()
}) })
beforeEach(async()=>{ // beforeEach(async()=>{
jest.setTimeout(5000) // console.log('beforeEach---')
return false // jest.setTimeout(300)
}) // return;
// })
it('云存储页-检查标题',async()=>{ it('云存储页-检查标题',async()=>{
//expect.assertions(1); //expect.assertions(1);
await page.waitFor(300) // await page.waitFor(300)
const content = await page.$('.content') const content = await page.$('.content')
console.log('content: ',content);
await page.waitFor(300) await page.waitFor(300)
const title = await content.$('.title') const title = await content.$('.title')
......
...@@ -56,12 +56,14 @@ ...@@ -56,12 +56,14 @@
content: JSON.stringify(res), content: JSON.stringify(res),
showCancel: false showCancel: false
}); });
return res
}).catch((err) => { }).catch((err) => {
console.log(err); console.log(err);
uni.showModal({ uni.showModal({
content: JSON.stringify(err), content: JSON.stringify(err),
showCancel: false showCancel: false
}); });
return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
......
...@@ -24,7 +24,7 @@ describe('pages/user-info/add.vue', () => { ...@@ -24,7 +24,7 @@ describe('pages/user-info/add.vue', () => {
const getForm = await page.data('formData') const getForm = await page.data('formData')
console.log("getForm: ",getForm); // console.log("getForm: ",getForm);
let username = "林小明" let username = "林小明"
let weight = 51 let weight = 51
......
...@@ -120,31 +120,35 @@ ...@@ -120,31 +120,35 @@
/** /**
* 触发表单提交 * 触发表单提交
*/ */
submit() { async submit() {
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
this.$refs.form.validate().then((res) => { return this.$refs.form.validate().then(async(res) => {
this.submitForm(res) console.log('res: ',res);
await this.submitForm(res)
return res
}).catch(() => { }).catch(() => {
uni.hideLoading() uni.hideLoading()
}) })
}, },
submitForm(value) { async submitForm(value) {
// 使用 clientDB 提交数据 // 使用 clientDB 提交数据
db.collection(dbCollectionName).add(value).then((res) => { return await db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '新增成功' title: '新增成功'
}) })
this.getOpenerEventChannel().emit('refreshData') this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500) setTimeout(() => uni.navigateBack(), 500)
return res
}).catch((err) => { }).catch((err) => {
uni.showModal({ uni.showModal({
content: err.message || '请求服务失败', content: err.message || '请求服务失败',
showCancel: false showCancel: false
}) })
return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
......
...@@ -3,26 +3,12 @@ describe('pages/user-info/detail.vue', () => { ...@@ -3,26 +3,12 @@ describe('pages/user-info/detail.vue', () => {
let page let page
beforeAll(async () => { beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
///pages/user-info/detail?id=601d044ac9e7be0001cc00b8
page = await program.reLaunch('/pages/user-info/detail') page = await program.reLaunch('/pages/user-info/detail')
if (process.env.UNI_PLATFORM === "h5"|| process.env.UNI_PLATFORM === "app-plus") { await page.waitFor(1000)
await page.waitFor(1000)
}
if (process.env.UNI_PLATFORM === "mp-weixin") {
await page.waitFor(1000);//微信等待
}
page = await program.currentPage() page = await program.currentPage()
}) })
// beforeEach(async()=>{
// jest.setTimeout(10000)
// return false
// })
it('点击修改',async()=>{ it('点击修改',async()=>{
const getId = await page.data('_id') const getId = await page.data('_id')
......
...@@ -79,10 +79,12 @@ ...@@ -79,10 +79,12 @@
options: { options: {
// 将scheme enum 属性静态数据中的value转成text // 将scheme enum 属性静态数据中的value转成text
...enumConverter ...enumConverter
} },
_id:''
} }
}, },
onLoad(e) { onLoad(e) {
console.log('e:-----id ',e);
this._id = e.id this._id = e.id
}, },
onReady() { onReady() {
......
...@@ -131,27 +131,29 @@ ...@@ -131,27 +131,29 @@
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
this.$refs.form.validate().then((res) => { return this.$refs.form.validate().then(async(res) => {
this.submitForm(res) return await this.submitForm(res)
}).catch(() => { }).catch(() => {
uni.hideLoading() uni.hideLoading()
}) })
}, },
submitForm(value) { async submitForm(value) {
// 使用 clientDB 提交数据 // 使用 clientDB 提交数据
db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => { return await db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '修改成功' title: '修改成功'
}) })
this.getOpenerEventChannel().emit('refreshData') this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500) setTimeout(() => uni.navigateBack(), 500)
return res
}).catch((err) => { }).catch((err) => {
uni.showModal({ uni.showModal({
content: err.message || '请求服务失败', content: err.message || '请求服务失败',
showCancel: false showCancel: false
}) })
return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
......
...@@ -119,21 +119,24 @@ ...@@ -119,21 +119,24 @@
/** /**
* 触发表单提交 * 触发表单提交
*/ */
submit() { async submit() {
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
this.$refs.form.submit().then((res) => { return this.$refs.form.submit().then(async(res) => {
console.log(res,"000"); console.log(res,"000");
this.submitForm(res) let msg = await this.submitForm(res)
console.log(msg,121399999);
return res
// this.submitForm(res)
}).catch((errors) => { }).catch((errors) => {
uni.hideLoading() uni.hideLoading()
}) })
}, },
submitForm(value) { async submitForm(value) {
// 使用 clientDB 提交数据 // 使用 clientDB 提交数据
db.collection(dbCollectionName).add(value).then((res) => { return await db.collection(dbCollectionName).add(value).then((res) => {
console.log("res:---- ",res); console.log("res:---- ",res);
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
...@@ -141,11 +144,13 @@ ...@@ -141,11 +144,13 @@
}) })
// this.getOpenerEventChannel().emit('refreshData') // this.getOpenerEventChannel().emit('refreshData')
// setTimeout(() => uni.navigateBack(), 500) // setTimeout(() => uni.navigateBack(), 500)
return res
}).catch((err) => { }).catch((err) => {
uni.showModal({ uni.showModal({
content: err.message || '请求服务失败', content: err.message || '请求服务失败',
showCancel: false showCancel: false
}) })
return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
......
{
"bsonType": "object",
"required": [],
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"mobile": {
"bsonType": "string",
"description": "手机号码"
},
"email": {
"bsonType": "string",
"description": "邮箱"
},
"code": {
"bsonType": "string",
"description": "验证码"
},
"type": {
"bsonType": "string",
"description": "验证类型:login, bind, unbind, pay"
},
"state": {
"bsonType": "int",
"description": "验证状态:0 未验证、1 已验证、2 已作废"
},
"ip": {
"bsonType": "string",
"description": "请求时客户端IP地址"
},
"created_at": {
"bsonType": "timestamp",
"description": "创建时间"
},
"expired_at": {
"bsonType": "timestamp",
"description": "过期时间"
}
}
}
// 在本文件中可配置云数据库初始化,数据格式见:https://uniapp.dcloud.io/uniCloud/hellodb?id=db-init
// 编写完毕后对本文件点右键,可按配置规则创建表和添加数据
{
"opendb-app-list": {
"data": [],
"index": [{
"IndexName": "appid",
"MgoKeySchema": {
"MgoIndexKeys": [{
"Name": "appid",
"Direction": "1"
}],
"MgoIsUnique": true
}
}, {
"IndexName": "name",
"MgoKeySchema": {
"MgoIndexKeys": [{
"Name": "name",
"Direction": "1"
}],
"MgoIsUnique": false
}
}]
},
"opendb-app-versions": {
"data": [],
"index": [{
"IndexName": "appid",
"MgoKeySchema": {
"MgoIndexKeys": [{
"Name": "appid",
"Direction": "1"
}],
"MgoIsUnique": false
}
}, {
"IndexName": "查找上线发行应用",
"MgoKeySchema": {
"MgoIndexKeys": [{
"Name": "appid",
"Direction": "1"
}, {
"Name": "platform",
"Direction": "1"
}, {
"Name": "stable_publish",
"Direction": "1"
}],
"MgoIsUnique": false
}
}]
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册