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