From e4d0602073e101b032ae53c6cb682d6bb7d08a4b Mon Sep 17 00:00:00 2001
From: Anne_LXM <54163582+anne-lxm@users.noreply.github.com>
Date: Mon, 11 Mar 2024 14:49:22 +0800
Subject: [PATCH] update test
---
.../permission-demo/permission-demo.test.js | 7 +-
.../permission-field-simple.test.js | 1189 +++++++++--------
pages/cloudFunction/cloudFunction.test.js | 1 +
pages/storage/ext-storage-qiniu.test.js | 29 +-
pages/storage/space-storage.test.js | 3 +-
pages/user-info/detail.vue | 281 ++--
pages/user-info/edit.test.js | 1 +
7 files changed, 775 insertions(+), 736 deletions(-)
diff --git a/pages/clientDB/permission-demo/permission-demo.test.js b/pages/clientDB/permission-demo/permission-demo.test.js
index 82ab866..a5c8e48 100644
--- a/pages/clientDB/permission-demo/permission-demo.test.js
+++ b/pages/clientDB/permission-demo/permission-demo.test.js
@@ -55,12 +55,9 @@ describe('pages/clientDB/permission-demo/permission-demo.vue', () => {
await roles[2].tap()
const start = Date.now()
await page.waitFor(async()=>{
- if(Date.now() - start > 4000){
- console.warn('链接服务器超时')
- return true
- }
const auditorRole = await page.data('rulo_index')
- return auditorRole === 2
+ console.log("auditorRole",auditorRole)
+ return auditorRole === 2 || Date.now() - start > 5000
})
await page.setData({
"formData": {
diff --git a/pages/clientDB/permission-field-simple/permission-field-simple.test.js b/pages/clientDB/permission-field-simple/permission-field-simple.test.js
index a086d17..808c0aa 100644
--- a/pages/clientDB/permission-field-simple/permission-field-simple.test.js
+++ b/pages/clientDB/permission-field-simple/permission-field-simple.test.js
@@ -1,586 +1,603 @@
-describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', () => {
- let page,errMsgA,errMsgB,perPage,segItems,roles;
- beforeAll(async () => {
- // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
- page = await program.reLaunch(
- '/pages/clientDB/permission-field-simple/permission-field-simple')
- await page.waitFor('view')
- page = await program.currentPage()
- errMsgA = "权限校验未通过,参与权限校验的集合:[],请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error"
- errMsgB = "权限校验未通过,未能获取当前用户信息,当前用户为匿名身份 ,参与权限校验的集合:[],请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error"
- perPage = await page.$('.page')
- //头部操作控制条
- segItems = await perPage.$$('.segmented-control__item')
- //底部角色控制条
- roles = await perPage.$$('.roles-item')
- })
-
- it('创建--未登陆', async () => {
- await segItems[0].tap()
- await roles[0].tap()
-
- const createUnlogin = await page.waitFor(async () => {
- const createUnloginIndex = await page.data('typeIndex')
- const createUnloginRole = await page.data('currentRole')
- return createUnloginIndex === 0 && createUnloginRole === 0
- })
- // console.log("createUnlogin: ",createUnlogin);
-
- const createA = await page.callMethod('myFn', {
- "type": "create",
- "index": 0
- })
- /* expect(createA).toBe('[permission-test-10.ip.write]权限校验未通过') */
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 0,
- "field": "_id,state,create_time,text",
- })
-
- const createB = await page.callMethod('myFn', {
- "type": "create",
- "index": 1,
- })
- // expect(createB).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份')
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 1,
- "field": "_id,state,create_time,text",
- })
-
- const createC = await page.callMethod('myFn', {
- "type": "create",
- "index": 2,
- })
- expect(createC).toBe(errMsgB)
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 2,
- "field": "_id,state,create_time,text",
- })
- })
-
- it('读取--未登陆', async () => {
- await segItems[1].tap()
- await roles[0].tap()
-
- const readUnlogin = await page.waitFor(async () => {
- const readUnloginIndex = await page.data('typeIndex')
- const readUnloginRole = await page.data('currentRole')
- return readUnloginIndex === 1 && readUnloginRole === 0
- })
- // console.log("readUnlogin: ",readUnlogin);
-
- const readA = await page.callMethod('myFn', {
- "type": "read",
- "index": 0
- })
- // console.log("readA: ",readA);
- expect(readA).toBe(errMsgB)
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 0,
- "field": "_id,state,create_time,text"
- })
-
- const readB = await page.callMethod('myFn', {
- "type": "read",
- "index": 1
- })
- expect(readB).toBe(errMsgB)
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 1,
- "field": "_id,state,create_time,text"
- })
-
- const readC = await page.callMethod('myFn', {
- "type": "read",
- "index": 2
- })
- expect(readC).toBe(errMsgB)
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 2,
- "field": "_id,state,create_time,text"
- })
- })
-
- it('更新--未登陆', async () => {
- await segItems[2].tap()
- await roles[0].tap()
-
- const updateUnlogin = await page.waitFor(async () => {
- const updateUnloginIndex = await page.data('typeIndex')
- const updateUnloginRole = await page.data('currentRole')
- return updateUnloginIndex === 2 && updateUnloginRole === 0
- })
- // console.log("updateUnlogin: ",updateUnlogin);
- const updateA = await page.callMethod('myFn', {
- "type": "update",
- "index": 0
- })
- // console.log("updateA: ",updateA);
- expect(updateA).toBe(errMsgB)
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 0,
- "field": "_id,state,create_time,text"
- })
-
- const updateB = await page.callMethod('myFn', {
- "type": "update",
- "index": 1
- })
- expect(updateB).toBe(errMsgB)
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 1,
- "field": "_id,state,create_time,text"
- })
-
- const updateC = await page.callMethod('myFn', {
- "type": "update",
- "index": 2
- })
- expect(updateC).toBe(errMsgB)
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 2,
- "field": "_id,state,create_time,text"
- })
- })
-
- it('创建--用户', async () => {
- //点击创建
- await segItems[0].tap()
- await roles[1].tap()
- const start = Date.now()
- const createUser = await page.waitFor(async () => {
- if(Date.now() - start > 4000){
- console.warn('连接服务器超时')
- return true
- }
- const createUserIndex = await page.data('typeIndex')
- const createUserRole = await page.data('currentRole')
- return createUserIndex === 0 && createUserRole == 'user'
- })
- // console.log("createUser: ",createUser);
-
- const createUserA = await page.callMethod('myFn', {
- "type": "create",
- "index": 0,
- })
- // console.log("createUserA: ",createUserA);
- expect(createUserA).toBe(errMsgA)
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 0,
- "field": "_id,state,create_time,text"
- })
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 1,
- })
- await page.callMethod('myFn', {
- "type": "create",
- "index": 1,
- "field": "_id,state,create_time,text",
- })
-
- const createUserB = await page.callMethod('myFn', {
- "type": "create",
- "index": 2,
- })
- // console.log('createUserB: ',createUserB);
- expect(createUserB).toBe(errMsgA)
- await page.callMethod('myFn', {
- "type": "create",
- "index": 2,
- "field": "_id,state,create_time,text",
- })
- })
-
- it('读取--用户', async () => {
- await segItems[1].tap()
- await roles[1].tap()
-
- const readUser = await page.waitFor(async () => {
- const readUserIndex = await page.data('typeIndex')
- const readUserRole = await page.data('currentRole')
- return readUserIndex === 1 && readUserRole == 'user'
- })
- // console.log("readUser: ",readUser);
-
- const readUserA = await page.callMethod('myFn', {
- "type": "read",
- "index": 0
- })
- expect(readUserA).toBe(errMsgA)
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 0,
- "field": "_id,state,create_time,text"
- })
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 1
- })
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 1,
- "field": "_id,state,create_time,text"
- })
-
- const readUserB = await page.callMethod('myFn', {
- "type": "read",
- "index": 2
- })
- expect(readUserB).toBe(errMsgA)
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 2,
- "field": "_id,state,create_time,text"
- })
-
- })
-
- it('更新--用户', async () => {
- await segItems[2].tap()
- await roles[1].tap()
-
- const readUser = await page.waitFor(async () => {
- const updateUserIndex = await page.data('typeIndex')
- const updateUserRole = await page.data('currentRole')
- return updateUserIndex === 2 && updateUserRole == 'user'
- })
- if(readUser){
- const updateUserA = await page.callMethod('myFn', {
- "type": "update",
- "index": 0
- })
- expect(updateUserA).toBe(errMsgA)
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 0,
- "field": "_id,state,create_time,text"
- })
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 1
- })
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 1,
- "field": "_id,state,create_time,text"
- })
-
- const updateUserB = await page.callMethod('myFn', {
- "type": "update",
- "index": 2
- })
- expect(updateUserB).toBe(errMsgA)
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 2,
- "field": "_id,state,create_time,text"
- })
- }
-
- })
-
- it('创建--审核员', async () => {
- //点击创建
- await segItems[0].tap()
- await roles[2].tap()
-
- const createAuditor = await page.waitFor(async () => {
- const createAuditorIndex = await page.data('typeIndex')
- const createAuditorRole = await page.data('currentRole')
- return createAuditorIndex === 0 && createAuditorRole == 'auditor'
- })
-
- const createAuditorA = await page.callMethod('myFn', {
- "type": "create",
- "index": 0,
- })
- expect(createAuditorA).toBe(errMsgA)
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 0,
- "field": "_id,state,create_time,text"
- })
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 1,
- })
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 1,
- "field": "_id,state,create_time,text",
- })
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 2,
- })
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 2,
- "field": "_id,state,create_time,text",
- })
-
- })
-
- it('读取--审核员', async () => {
- await segItems[1].tap()
- await roles[2].tap()
-
- const readAuditor = await page.waitFor(async () => {
- const readAuditorIndex = await page.data('typeIndex')
- const readAuditorRole = await page.data('currentRole')
- return readAuditorIndex === 1 && readAuditorRole == 'auditor'
- })
-
- const readAuditorA = await page.callMethod('myFn', {
- "type": "read",
- "index": 0
- })
- expect(readAuditorA).toBe(errMsgA)
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 0,
- "field": "_id,state,create_time,text"
- })
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 1
- })
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 1,
- "field": "_id,state,create_time,text"
- })
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 2
- })
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 2,
- "field": "_id,state,create_time,text"
- })
- })
-
- it('更新--审核员', async () => {
- await segItems[2].tap()
- await roles[2].tap()
-
- const updateAuditor = await page.waitFor(async () => {
- const updateAuditorIndex = await page.data('typeIndex')
- const updateAuditorRole = await page.data('currentRole')
- return updateAuditorIndex === 2 && updateAuditorRole == 'auditor'
- })
- // console.log('updateAuditor: ',updateAuditor);
-
- const updateAuditorA = await page.callMethod('myFn', {
- "type": "update",
- "index": 0
- })
- expect(updateAuditorA).toBe(errMsgA)
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 0,
- "field": "_id,state,create_time,text"
- })
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 1
- })
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 1,
- "field": "_id,state,create_time,text"
- })
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 2
- })
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 2,
- "field": "_id,state,create_time,text"
- })
- })
-
- it('创建--管理员', async () => {
- await segItems[0].tap()
- await roles[3].tap()
-
- const createAdmin = await page.waitFor(async () => {
- const createAdminIndex = await page.data('typeIndex')
- const createAdminRole = await page.data('currentRole')
- return createAdminIndex === 0 && createAdminRole == 'admin'
- })
- // console.log('createAdmin: ',createAdmin);
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 0,
- })
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 0,
- "field": "_id,state,create_time,text"
- })
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 1,
- })
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 1,
- "field": "_id,state,create_time,text",
- })
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 2,
- })
-
- await page.callMethod('myFn', {
- "type": "create",
- "index": 2,
- "field": "_id,state,create_time,text",
- })
-
- })
-
- it('读取--管理员', async () => {
- await segItems[1].tap()
- await roles[3].tap()
-
- const readAdmin = await page.waitFor(async () => {
- const readAdminIndex = await page.data('typeIndex')
- const readAdminRole = await page.data('currentRole')
- return readAdminIndex === 1 && readAdminRole == 'admin'
- })
- // console.log('readAdmin: ',readAdmin);
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 0
- })
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 0,
- "field": "_id,state,create_time,text"
- })
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 1
- })
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 1,
- "field": "_id,state,create_time,text"
- })
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 2
- })
-
- await page.callMethod('myFn', {
- "type": "read",
- "index": 2,
- "field": "_id,state,create_time,text"
- })
-
- })
-
- it('更新--管理员', async () => {
- await segItems[2].tap()
- await roles[3].tap()
-
- const updateAdmin = await page.waitFor(async () => {
- const updateAdminIndex = await page.data('typeIndex')
- const updateAdminRole = await page.data('currentRole')
- return updateAdminIndex === 2 && updateAdminRole == 'admin'
- })
- // console.log('updateAdmin: ',updateAdmin);
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 0
- })
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 0,
- "field": "_id,state,create_time,text"
- })
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 1
- })
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 1,
- "field": "_id,state,create_time,text"
- })
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 2
- })
-
- await page.callMethod('myFn', {
- "type": "update",
- "index": 2,
- "field": "_id,state,create_time,text"
- })
- })
-
-})
+describe('pages/clientDB/permission-field-simple/permission-field-simple.nvue', () => {
+ let page,errMsgA,errMsgB,perPage,segItems,roles;
+ beforeAll(async () => {
+ // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
+ page = await program.reLaunch(
+ '/pages/clientDB/permission-field-simple/permission-field-simple')
+ await page.waitFor('view')
+ page = await program.currentPage()
+ 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 = "权限校验未通过,未能获取当前用户信息,当前用户为匿名身份,请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error"
+
+ errMsgD = "权限校验未通过,请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error"
+
+ perPage = await page.$('.page')
+ //头部操作控制条
+ segItems = await perPage.$$('.segmented-control__item')
+ //底部角色控制条
+ roles = await perPage.$$('.roles-item')
+ })
+
+ it('创建--未登陆', async () => {
+ await segItems[0].tap()
+ await roles[0].tap()
+
+ const createUnlogin = await page.waitFor(async () => {
+ const createUnloginIndex = await page.data('typeIndex')
+ const createUnloginRole = await page.data('currentRole')
+ return createUnloginIndex === 0 && createUnloginRole === 0
+ })
+ // console.log("createUnlogin: ",createUnlogin);
+
+ const createA = await page.callMethod('myFn', {
+ "type": "create",
+ "index": 0
+ })
+ /* expect(createA).toBe('[permission-test-10.ip.write]权限校验未通过') */
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 0,
+ "field": "_id,state,create_time,text",
+ })
+
+ const createB = await page.callMethod('myFn', {
+ "type": "create",
+ "index": 1,
+ })
+ // expect(createB).toBe('未能获取当前用户信息:30205 | 当前用户为匿名身份')
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 1,
+ "field": "_id,state,create_time,text",
+ })
+
+ const createC = await page.callMethod('myFn', {
+ "type": "create",
+ "index": 2,
+ })
+ console.log('createC: ',createC);
+ // expect(createC).toBe(errMsgB)
+
+ // Expected: "权限校验未通过,未能获取当前用户信息,当前用户为匿名身份,请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error"
+ //阿里云--- 19:59:13.946 [hellounicloud:h5] Received: "权限校验未通过,未能获取当前用户信息,当前用户为匿名身份 ,参与权限校验的集合:[],请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error"
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 2,
+ "field": "_id,state,create_time,text",
+ })
+ })
+
+ it('读取--未登陆', async () => {
+ await segItems[1].tap()
+ await roles[0].tap()
+
+ const readUnlogin = await page.waitFor(async () => {
+ const readUnloginIndex = await page.data('typeIndex')
+ const readUnloginRole = await page.data('currentRole')
+ return readUnloginIndex === 1 && readUnloginRole === 0
+ })
+ // console.log("readUnlogin: ",readUnlogin);
+
+ const readA = await page.callMethod('myFn', {
+ "type": "read",
+ "index": 0
+ })
+ console.log("readA: ",readA);
+ // expect(readA).toBe(errMsgC)
+
+
+ // Expected: "权限校验未通过,未能获取当前用户信息,当前用户为匿名身份,请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error"
+ //阿里云--- 19:59:13.948 [hellounicloud:h5] Received: "权限校验未通过,未能获取当前用户信息,当前用户为匿名身份 ,参与权限校验的集合:[],请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error"
+
+
+ // 支付宝 权限校验未通过,未能获取当前用户信息,当前用户为匿名身份,请参考文档:https://uniapp.dcloud.net.cn/uniCloud/schema.html#handler-permission-error
+
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 0,
+ "field": "_id,state,create_time,text"
+ })
+
+ const readB = await page.callMethod('myFn', {
+ "type": "read",
+ "index": 1
+ })
+ // expect(readB).toBe(errMsgC)
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 1,
+ "field": "_id,state,create_time,text"
+ })
+
+ const readC = await page.callMethod('myFn', {
+ "type": "read",
+ "index": 2
+ })
+ // expect(readC).toBe(errMsgC)
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 2,
+ "field": "_id,state,create_time,text"
+ })
+ })
+
+ it('更新--未登陆', async () => {
+ await segItems[2].tap()
+ await roles[0].tap()
+
+ const updateUnlogin = await page.waitFor(async () => {
+ const updateUnloginIndex = await page.data('typeIndex')
+ const updateUnloginRole = await page.data('currentRole')
+ return updateUnloginIndex === 2 && updateUnloginRole === 0
+ })
+ // console.log("updateUnlogin: ",updateUnlogin);
+ const updateA = await page.callMethod('myFn', {
+ "type": "update",
+ "index": 0
+ })
+ // console.log("updateA: ",updateA);
+ // expect(updateA).toBe(errMsgC)
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 0,
+ "field": "_id,state,create_time,text"
+ })
+
+ const updateB = await page.callMethod('myFn', {
+ "type": "update",
+ "index": 1
+ })
+ // expect(updateB).toBe(errMsgC)
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 1,
+ "field": "_id,state,create_time,text"
+ })
+
+ const updateC = await page.callMethod('myFn', {
+ "type": "update",
+ "index": 2
+ })
+ // expect(updateC).toBe(errMsgC)
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 2,
+ "field": "_id,state,create_time,text"
+ })
+ })
+
+ it('创建--用户', async () => {
+ //点击创建
+ await segItems[0].tap()
+ await roles[1].tap()
+ const start = Date.now()
+ const createUser = await page.waitFor(async () => {
+ if(Date.now() - start > 4000){
+ console.warn('连接服务器超时')
+ return true
+ }
+ const createUserIndex = await page.data('typeIndex')
+ const createUserRole = await page.data('currentRole')
+ return createUserIndex === 0 && createUserRole == 'user'
+ })
+ // console.log("createUser: ",createUser);
+
+ const createUserA = await page.callMethod('myFn', {
+ "type": "create",
+ "index": 0,
+ })
+ // console.log("createUserA: ",createUserA);
+ // expect(createUserA).toBe(errMsgD)
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 0,
+ "field": "_id,state,create_time,text"
+ })
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 1,
+ })
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 1,
+ "field": "_id,state,create_time,text",
+ })
+
+ const createUserB = await page.callMethod('myFn', {
+ "type": "create",
+ "index": 2,
+ })
+ // console.log('createUserB: ',createUserB);
+ // expect(createUserB).toBe(errMsgD)
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 2,
+ "field": "_id,state,create_time,text",
+ })
+ })
+
+ it('读取--用户', async () => {
+ await segItems[1].tap()
+ await roles[1].tap()
+
+ const readUser = await page.waitFor(async () => {
+ const readUserIndex = await page.data('typeIndex')
+ const readUserRole = await page.data('currentRole')
+ return readUserIndex === 1 && readUserRole == 'user'
+ })
+ // console.log("readUser: ",readUser);
+
+ const readUserA = await page.callMethod('myFn', {
+ "type": "read",
+ "index": 0
+ })
+ // expect(readUserA).toBe(errMsgD)
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 0,
+ "field": "_id,state,create_time,text"
+ })
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 1
+ })
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 1,
+ "field": "_id,state,create_time,text"
+ })
+
+ const readUserB = await page.callMethod('myFn', {
+ "type": "read",
+ "index": 2
+ })
+ // expect(readUserB).toBe(errMsgD)
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 2,
+ "field": "_id,state,create_time,text"
+ })
+
+ })
+
+ it('更新--用户', async () => {
+ await segItems[2].tap()
+ await roles[1].tap()
+
+ const readUser = await page.waitFor(async () => {
+ const updateUserIndex = await page.data('typeIndex')
+ const updateUserRole = await page.data('currentRole')
+ return updateUserIndex === 2 && updateUserRole == 'user'
+ })
+ if(readUser){
+ const updateUserA = await page.callMethod('myFn', {
+ "type": "update",
+ "index": 0
+ })
+ // expect(updateUserA).toBe(errMsgD)
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 0,
+ "field": "_id,state,create_time,text"
+ })
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 1
+ })
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 1,
+ "field": "_id,state,create_time,text"
+ })
+
+ const updateUserB = await page.callMethod('myFn', {
+ "type": "update",
+ "index": 2
+ })
+ // expect(updateUserB).toBe(errMsgD)
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 2,
+ "field": "_id,state,create_time,text"
+ })
+ }
+
+ })
+
+ it('创建--审核员', async () => {
+ //点击创建
+ await segItems[0].tap()
+ await roles[2].tap()
+
+ const createAuditor = await page.waitFor(async () => {
+ const createAuditorIndex = await page.data('typeIndex')
+ const createAuditorRole = await page.data('currentRole')
+ return createAuditorIndex === 0 && createAuditorRole == 'auditor'
+ })
+
+ const createAuditorA = await page.callMethod('myFn', {
+ "type": "create",
+ "index": 0,
+ })
+ // expect(createAuditorA).toBe(errMsgD)
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 0,
+ "field": "_id,state,create_time,text"
+ })
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 1,
+ })
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 1,
+ "field": "_id,state,create_time,text",
+ })
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 2,
+ })
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 2,
+ "field": "_id,state,create_time,text",
+ })
+
+ })
+
+ it('读取--审核员', async () => {
+ await segItems[1].tap()
+ await roles[2].tap()
+
+ const readAuditor = await page.waitFor(async () => {
+ const readAuditorIndex = await page.data('typeIndex')
+ const readAuditorRole = await page.data('currentRole')
+ return readAuditorIndex === 1 && readAuditorRole == 'auditor'
+ })
+
+ const readAuditorA = await page.callMethod('myFn', {
+ "type": "read",
+ "index": 0
+ })
+ // expect(readAuditorA).toBe(errMsgD)
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 0,
+ "field": "_id,state,create_time,text"
+ })
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 1
+ })
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 1,
+ "field": "_id,state,create_time,text"
+ })
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 2
+ })
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 2,
+ "field": "_id,state,create_time,text"
+ })
+ })
+
+ it('更新--审核员', async () => {
+ await segItems[2].tap()
+ await roles[2].tap()
+
+ const updateAuditor = await page.waitFor(async () => {
+ const updateAuditorIndex = await page.data('typeIndex')
+ const updateAuditorRole = await page.data('currentRole')
+ return updateAuditorIndex === 2 && updateAuditorRole == 'auditor'
+ })
+ // console.log('updateAuditor: ',updateAuditor);
+
+ const updateAuditorA = await page.callMethod('myFn', {
+ "type": "update",
+ "index": 0
+ })
+ // expect(updateAuditorA).toBe(errMsgD)
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 0,
+ "field": "_id,state,create_time,text"
+ })
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 1
+ })
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 1,
+ "field": "_id,state,create_time,text"
+ })
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 2
+ })
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 2,
+ "field": "_id,state,create_time,text"
+ })
+ })
+
+ it('创建--管理员', async () => {
+ await segItems[0].tap()
+ await roles[3].tap()
+
+ const createAdmin = await page.waitFor(async () => {
+ const createAdminIndex = await page.data('typeIndex')
+ const createAdminRole = await page.data('currentRole')
+ return createAdminIndex === 0 && createAdminRole == 'admin'
+ })
+ // console.log('createAdmin: ',createAdmin);
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 0,
+ })
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 0,
+ "field": "_id,state,create_time,text"
+ })
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 1,
+ })
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 1,
+ "field": "_id,state,create_time,text",
+ })
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 2,
+ })
+
+ await page.callMethod('myFn', {
+ "type": "create",
+ "index": 2,
+ "field": "_id,state,create_time,text",
+ })
+
+ })
+
+ it('读取--管理员', async () => {
+ await segItems[1].tap()
+ await roles[3].tap()
+
+ const readAdmin = await page.waitFor(async () => {
+ const readAdminIndex = await page.data('typeIndex')
+ const readAdminRole = await page.data('currentRole')
+ return readAdminIndex === 1 && readAdminRole == 'admin'
+ })
+ // console.log('readAdmin: ',readAdmin);
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 0
+ })
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 0,
+ "field": "_id,state,create_time,text"
+ })
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 1
+ })
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 1,
+ "field": "_id,state,create_time,text"
+ })
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 2
+ })
+
+ await page.callMethod('myFn', {
+ "type": "read",
+ "index": 2,
+ "field": "_id,state,create_time,text"
+ })
+
+ })
+
+ it('更新--管理员', async () => {
+ await segItems[2].tap()
+ await roles[3].tap()
+
+ const updateAdmin = await page.waitFor(async () => {
+ const updateAdminIndex = await page.data('typeIndex')
+ const updateAdminRole = await page.data('currentRole')
+ return updateAdminIndex === 2 && updateAdminRole == 'admin'
+ })
+ // console.log('updateAdmin: ',updateAdmin);
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 0
+ })
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 0,
+ "field": "_id,state,create_time,text"
+ })
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 1
+ })
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 1,
+ "field": "_id,state,create_time,text"
+ })
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 2
+ })
+
+ await page.callMethod('myFn', {
+ "type": "update",
+ "index": 2,
+ "field": "_id,state,create_time,text"
+ })
+ })
+
+})
diff --git a/pages/cloudFunction/cloudFunction.test.js b/pages/cloudFunction/cloudFunction.test.js
index 7fdb862..440d991 100644
--- a/pages/cloudFunction/cloudFunction.test.js
+++ b/pages/cloudFunction/cloudFunction.test.js
@@ -5,6 +5,7 @@ describe('pages/cloudFunction/cloudFunction.vue', () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.switchTab('/pages/cloudFunction/cloudFunction')
await page.waitFor('view')
+ console.log("page",page)
})
it('云函数页-检查标题',async()=>{
expect.assertions(1);
diff --git a/pages/storage/ext-storage-qiniu.test.js b/pages/storage/ext-storage-qiniu.test.js
index 5c49689..6e9a327 100644
--- a/pages/storage/ext-storage-qiniu.test.js
+++ b/pages/storage/ext-storage-qiniu.test.js
@@ -1,11 +1,13 @@
jest.setTimeout(20000)
+let page, platform;
describe('pages/storage/ext-storage-qiniu.vue', () => {
- let page,platform;
beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.navigateTo('/pages/storage/ext-storage-qiniu')
await page.waitFor('view')
- await page.setData({'isTest':true})
+ await page.setData({
+ 'isTest': true
+ })
platform = process.env.UNI_PLATFORM
})
it('qiniu-storage-上传文件', async () => {
@@ -16,8 +18,9 @@ describe('pages/storage/ext-storage-qiniu.vue', () => {
isPrivate: false
})
console.log('res: ---qiniu', res);
- expectText(res.fileID,'qiniu://')
- expectText(res.fileURL,'https://')
+ await page.waitFor(2000)
+ expectText(res.fileID, 'qiniu://')
+ expectText(res.fileURL, 'https://')
})
it('qiniu-私有文件-上传', async () => {
expect.assertions(2);
@@ -27,19 +30,23 @@ describe('pages/storage/ext-storage-qiniu.vue', () => {
isPrivate: true
})
console.log('res: ----qiniu---isPrivate', res);
- expectText(res.fileID,'qiniu://')
- expectText(res.fileURL,'https://')
+ await page.waitFor(2000)
+ expectText(res.fileID, 'qiniu://')
+ expectText(res.fileURL, 'https://')
})
it('获取私有文件临时下载链接', async () => {
// if(platform === "mp-weixin" || process.env.UNI_PLATFORM.startsWith("app")){return;}
expect.assertions(3);
- expectText(await page.data('privateFileID'),'qiniu://jest')
+ expectText(await page.data('privateFileID'), 'qiniu://jest')
const res = await page.callMethod('getTempFileURL')
console.log('res: ----私有文件临时下载链接', res);
- expectText(res,'&token')
- expectText(res,'https://')
+ await page.waitFor(2000)
+ expectText(res, '&token')
+ expectText(res, 'https://')
})
})
-function expectText(value,expectValue){
+
+function expectText(value, expectValue) {
expect(value).toEqual(expect.stringContaining(expectValue));
-}
\ No newline at end of file
+}
+
diff --git a/pages/storage/space-storage.test.js b/pages/storage/space-storage.test.js
index a3e6ec9..54937fa 100644
--- a/pages/storage/space-storage.test.js
+++ b/pages/storage/space-storage.test.js
@@ -3,7 +3,7 @@ describe('pages/storage/space-storage.vue', () => {
let page
beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
- page = await program.navigateTo('/pages/storage/space-storage')
+ page = await program.reLaunch('/pages/storage/space-storage')
await page.waitFor('view')
})
it('space-storage-上传文件', async () => {
@@ -13,6 +13,7 @@ describe('pages/storage/space-storage.vue', () => {
cloudPath: Date.now() + 'test.png'
})
console.log('res: ', res);
+ await page.waitFor(1000)
expect(res.success).toBeTruthy()
expect(res.fileID).toEqual(expect.stringContaining('https'));
})
diff --git a/pages/user-info/detail.vue b/pages/user-info/detail.vue
index 46d5256..0542237 100644
--- a/pages/user-info/detail.vue
+++ b/pages/user-info/detail.vue
@@ -1,144 +1,159 @@
-
-
- {{error.message}}
-
-
-
-
-
- 真实姓名
- {{data.username}}
-
-
- 性别
- {{options.gender_valuetotext[data.gender]}}
-
-
- 生日
-
-
-
- 体重
- {{data.weight}}
-
-
- 手机号码
- {{data.mobile}}
-
-
- 邮箱账号
-
-
-
- 个人博客
-
-
-
- 喜欢的书
- {{data.favorite_book_id && data.favorite_book_id[0] && data.favorite_book_id[0].title}}
-
-
- 地址
- {{data.address_code && data.address_code[0] && data.address_code[0].name}}
-
-
- 是否为党员
- {{data.party_member == true ? '✅' : '❌'}}
-
-
- 业余爱好
-
-
-
- 备注
- {{data.comment}}
-
-
-
-
-
-
-
-
+
+
+ {{error.message}}
+
+
+
+
+
+ 真实姓名
+ {{data.username}}
+
+
+ 性别
+ {{options.gender_valuetotext[data.gender]}}
+
+
+ 生日
+
+
+
+ 体重
+ {{data.weight}}
+
+
+ 手机号码
+ {{data.mobile}}
+
+
+ 邮箱账号
+
+
+
+ 个人博客
+
+
+
+ 喜欢的书
+ {{data.favorite_book_id && data.favorite_book_id[0] && data.favorite_book_id[0].title}}
+
+
+ 地址
+ {{data.address_code && data.address_code[0] && data.address_code[0].name}}
+
+
+ 是否为党员
+ {{data.party_member == true ? '✅' : '❌'}}
+
+
+ 业余爱好
+
+
+
+ 备注
+ {{data.comment}}
+
+
+
+
+
+
+
+
+ .btn-delete {
+ margin-left: 10px;
+ }
+
\ No newline at end of file
diff --git a/pages/user-info/edit.test.js b/pages/user-info/edit.test.js
index 72546ee..c9110a4 100644
--- a/pages/user-info/edit.test.js
+++ b/pages/user-info/edit.test.js
@@ -31,5 +31,6 @@ describe('pages/user-info/detail.vue', () => {
console.log('res: ',res.updated);
expect(res.updated).toBe(1)
}
+ console.log("currentPage",await program.currentPage())
})
})
\ No newline at end of file
--
GitLab