提交 e4d06020 编写于 作者: A Anne_LXM

update test

上级 efe7f718
...@@ -55,12 +55,9 @@ describe('pages/clientDB/permission-demo/permission-demo.vue', () => { ...@@ -55,12 +55,9 @@ describe('pages/clientDB/permission-demo/permission-demo.vue', () => {
await roles[2].tap() await roles[2].tap()
const start = Date.now() const start = Date.now()
await page.waitFor(async()=>{ await page.waitFor(async()=>{
if(Date.now() - start > 4000){
console.warn('链接服务器超时')
return true
}
const auditorRole = await page.data('rulo_index') const auditorRole = await page.data('rulo_index')
return auditorRole === 2 console.log("auditorRole",auditorRole)
return auditorRole === 2 || Date.now() - start > 5000
}) })
await page.setData({ await page.setData({
"formData": { "formData": {
......
...@@ -5,6 +5,7 @@ describe('pages/cloudFunction/cloudFunction.vue', () => { ...@@ -5,6 +5,7 @@ describe('pages/cloudFunction/cloudFunction.vue', () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.switchTab('/pages/cloudFunction/cloudFunction') page = await program.switchTab('/pages/cloudFunction/cloudFunction')
await page.waitFor('view') await page.waitFor('view')
console.log("page",page)
}) })
it('云函数页-检查标题',async()=>{ it('云函数页-检查标题',async()=>{
expect.assertions(1); expect.assertions(1);
......
jest.setTimeout(20000) jest.setTimeout(20000)
let page, platform;
describe('pages/storage/ext-storage-qiniu.vue', () => { describe('pages/storage/ext-storage-qiniu.vue', () => {
let page,platform;
beforeAll(async () => { beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.navigateTo('/pages/storage/ext-storage-qiniu') page = await program.navigateTo('/pages/storage/ext-storage-qiniu')
await page.waitFor('view') await page.waitFor('view')
await page.setData({'isTest':true}) await page.setData({
'isTest': true
})
platform = process.env.UNI_PLATFORM platform = process.env.UNI_PLATFORM
}) })
it('qiniu-storage-上传文件', async () => { it('qiniu-storage-上传文件', async () => {
...@@ -16,8 +18,9 @@ describe('pages/storage/ext-storage-qiniu.vue', () => { ...@@ -16,8 +18,9 @@ describe('pages/storage/ext-storage-qiniu.vue', () => {
isPrivate: false isPrivate: false
}) })
console.log('res: ---qiniu', res); console.log('res: ---qiniu', res);
expectText(res.fileID,'qiniu://') await page.waitFor(2000)
expectText(res.fileURL,'https://') expectText(res.fileID, 'qiniu://')
expectText(res.fileURL, 'https://')
}) })
it('qiniu-私有文件-上传', async () => { it('qiniu-私有文件-上传', async () => {
expect.assertions(2); expect.assertions(2);
...@@ -27,19 +30,23 @@ describe('pages/storage/ext-storage-qiniu.vue', () => { ...@@ -27,19 +30,23 @@ describe('pages/storage/ext-storage-qiniu.vue', () => {
isPrivate: true isPrivate: true
}) })
console.log('res: ----qiniu---isPrivate', res); console.log('res: ----qiniu---isPrivate', res);
expectText(res.fileID,'qiniu://') await page.waitFor(2000)
expectText(res.fileURL,'https://') expectText(res.fileID, 'qiniu://')
expectText(res.fileURL, 'https://')
}) })
it('获取私有文件临时下载链接', async () => { it('获取私有文件临时下载链接', async () => {
// if(platform === "mp-weixin" || process.env.UNI_PLATFORM.startsWith("app")){return;} // if(platform === "mp-weixin" || process.env.UNI_PLATFORM.startsWith("app")){return;}
expect.assertions(3); expect.assertions(3);
expectText(await page.data('privateFileID'),'qiniu://jest') expectText(await page.data('privateFileID'), 'qiniu://jest')
const res = await page.callMethod('getTempFileURL') const res = await page.callMethod('getTempFileURL')
console.log('res: ----私有文件临时下载链接', res); console.log('res: ----私有文件临时下载链接', res);
expectText(res,'&token') await page.waitFor(2000)
expectText(res,'https://') expectText(res, '&token')
expectText(res, 'https://')
}) })
}) })
function expectText(value,expectValue){
function expectText(value, expectValue) {
expect(value).toEqual(expect.stringContaining(expectValue)); expect(value).toEqual(expect.stringContaining(expectValue));
} }
\ No newline at end of file
...@@ -3,7 +3,7 @@ describe('pages/storage/space-storage.vue', () => { ...@@ -3,7 +3,7 @@ describe('pages/storage/space-storage.vue', () => {
let page let page
beforeAll(async () => { beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新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') await page.waitFor('view')
}) })
it('space-storage-上传文件', async () => { it('space-storage-上传文件', async () => {
...@@ -13,6 +13,7 @@ describe('pages/storage/space-storage.vue', () => { ...@@ -13,6 +13,7 @@ describe('pages/storage/space-storage.vue', () => {
cloudPath: Date.now() + 'test.png' cloudPath: Date.now() + 'test.png'
}) })
console.log('res: ', res); console.log('res: ', res);
await page.waitFor(1000)
expect(res.success).toBeTruthy() expect(res.success).toBeTruthy()
expect(res.fileID).toEqual(expect.stringContaining('https')); expect(res.fileID).toEqual(expect.stringContaining('https'));
}) })
......
<template> <template>
<view class="container"> <view class="container">
<unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="options" collection="user-info,book,opendb-city-china" field="username,gender,birth_date,weight,mobile,email,url,favorite_book_id{title},address_code{name},party_member,hobby,comment" :where="queryWhere" :getone="true" :manual="true"> <unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="options"
<view v-if="error">{{error.message}}</view> collection="user-info,book,opendb-city-china"
<view v-else-if="loading"> field="username,gender,birth_date,weight,mobile,email,url,favorite_book_id{title},address_code{name},party_member,hobby,comment"
<uni-load-more :contentText="loadMore" status="loading"></uni-load-more> :where="queryWhere" :getone="true" :manual="true">
</view> <view v-if="error">{{error.message}}</view>
<view v-else-if="data"> <view v-else-if="loading">
<view> <uni-load-more :contentText="loadMore" status="loading"></uni-load-more>
<text>真实姓名</text> </view>
<text>{{data.username}}</text> <view v-else-if="data">
</view> <view>
<view> <text>真实姓名</text>
<text>性别</text> <text>{{data.username}}</text>
<text>{{options.gender_valuetotext[data.gender]}}</text> </view>
</view> <view>
<view> <text>性别</text>
<text>生日</text> <text>{{options.gender_valuetotext[data.gender]}}</text>
<uni-dateformat :threshold="[0, 0]" :date="data.birth_date"></uni-dateformat> </view>
</view> <view>
<view> <text>生日</text>
<text>体重</text> <uni-dateformat :threshold="[0, 0]" :date="data.birth_date"></uni-dateformat>
<text>{{data.weight}}</text> </view>
</view> <view>
<view> <text>体重</text>
<text>手机号码</text> <text>{{data.weight}}</text>
<text>{{data.mobile}}</text> </view>
</view> <view>
<view> <text>手机号码</text>
<text>邮箱账号</text> <text>{{data.mobile}}</text>
<uni-link :href="'mailto:'+data.email" :text="data.email"></uni-link> </view>
</view> <view>
<view> <text>邮箱账号</text>
<text>个人博客</text> <uni-link :href="'mailto:'+data.email" :text="data.email"></uni-link>
<uni-link :href="data.url" :download="data.url" :text="data.url"></uni-link> </view>
</view> <view>
<view> <text>个人博客</text>
<text>喜欢的书</text> <uni-link :href="data.url" :download="data.url" :text="data.url"></uni-link>
<text>{{data.favorite_book_id && data.favorite_book_id[0] && data.favorite_book_id[0].title}}</text> </view>
</view> <view>
<view> <text>喜欢的书</text>
<text>地址</text> <text>{{data.favorite_book_id && data.favorite_book_id[0] && data.favorite_book_id[0].title}}</text>
<text>{{data.address_code && data.address_code[0] && data.address_code[0].name}}</text> </view>
</view> <view>
<view> <text>地址</text>
<text>是否为党员</text> <text>{{data.address_code && data.address_code[0] && data.address_code[0].name}}</text>
<text>{{data.party_member == true ? '' : ''}}</text> </view>
</view> <view>
<view> <text>是否为党员</text>
<text>业余爱好</text> <text>{{data.party_member == true ? '' : ''}}</text>
<uni-data-picker :localdata="options.hobby_valuetotext" :value="data.hobby" :multiple="false" :readonly="true" :arrow="false" split=","></uni-data-picker> </view>
</view> <view>
<view> <text>业余爱好</text>
<text>备注</text> <uni-data-picker :localdata="options.hobby_valuetotext" :value="data.hobby" :multiple="false"
<text>{{data.comment}}</text> :readonly="true" :arrow="false" split=","></uni-data-picker>
</view> </view>
</view> <view>
</unicloud-db> <text>备注</text>
<view class="btns"> <text>{{data.comment}}</text>
<button type="primary" @click="handleUpdate">修改</button> </view>
<button type="warn" class="btn-delete" @click="handleDelete">删除</button> </view>
</view> </unicloud-db>
</view> <view class="btns">
<button type="primary" @click="handleUpdate">修改</button>
<button type="warn" class="btn-delete" @click="handleDelete">删除</button>
</view>
</view>
</template> </template>
<script> <script>
// 由schema2code生成,包含校验规则和enum静态数据 // 由schema2code生成,包含校验规则和enum静态数据
import { enumConverter } from '../../js_sdk/validator/user-info.js'; import {
enumConverter
} from '../../js_sdk/validator/user-info.js';
export default { export default {
data() { data() {
return { return {
queryWhere: '', queryWhere: '',
loadMore: { loadMore: {
contentdown: '', contentdown: '',
contentrefresh: '', contentrefresh: '',
contentnomore: '' contentnomore: ''
}, },
options: { options: {
// 将scheme enum 属性静态数据中的value转成text // 将scheme enum 属性静态数据中的value转成text
...enumConverter ...enumConverter
}, },
_id:'' _id: ''
} }
}, },
onLoad(e) { onLoad(e) {
console.log('e:-----id ',e); console.log('e:-----id ', e);
this._id = e.id this._id = e.id
}, },
onReady() { onReady() {
if (this._id) { if (this._id) {
this.queryWhere = '_id=="' + this._id + '"' this.queryWhere = '_id=="' + this._id + '"'
} }
}, },
methods: { methods: {
handleUpdate() { handleUpdate() {
// 打开修改页面 // 打开修改页面
uni.navigateTo({ uni.navigateTo({
url: './edit?id=' + this._id, url: './edit?id=' + this._id,
events: { events: {
// 监听修改页面成功修改数据后, 刷新当前页面数据 // 监听修改页面成功修改数据后, 刷新当前页面数据
refreshData: () => { refreshData: () => {
this.$refs.udb.loadData({ this.$refs.udb.loadData({
clear: true clear: true
}) })
} }
} }
}) })
}, },
handleDelete() { handleDelete() {
this.$refs.udb.remove(this._id, { console.log('handleDelete:-----');
success: (res) => { this.$refs.udb.remove(this._id, {
// 删除数据成功后跳转到list页面 success: (res) => {
uni.navigateTo({ console.log('res:-----', res);
url: './list' // 删除数据成功后跳转到list页面
}) uni.navigateTo({
} url: './list'
}) })
} },
} fail: (err) => {
} console.log('err:-----', err);
uni.showToast({
title: '删除失败',
icon: 'none'
})
}
})
}
}
}
</script> </script>
<style> <style>
.container { .container {
padding: 10px; padding: 10px;
} }
.btns { .btns {
margin-top: 10px; margin-top: 10px;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
/* #endif */ /* #endif */
flex-direction: row; flex-direction: row;
} }
.btns button { .btns button {
flex: 1; flex: 1;
} }
.btn-delete { .btn-delete {
margin-left: 10px; margin-left: 10px;
} }
</style> </style>
\ No newline at end of file
...@@ -31,5 +31,6 @@ describe('pages/user-info/detail.vue', () => { ...@@ -31,5 +31,6 @@ describe('pages/user-info/detail.vue', () => {
console.log('res: ',res.updated); console.log('res: ',res.updated);
expect(res.updated).toBe(1) expect(res.updated).toBe(1)
} }
console.log("currentPage",await program.currentPage())
}) })
}) })
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册