提交 131b0724 编写于 作者: Anne_LXM's avatar Anne_LXM

test update

上级 c255655a
...@@ -3,7 +3,7 @@ import App from './App' ...@@ -3,7 +3,7 @@ import App from './App'
// #ifndef VUE3 // #ifndef VUE3
import Vue from 'vue' import Vue from 'vue'
Vue.config.productionTip = false Vue.config.productionTip = false
//自动化测试
uni.showModal = ()=>{}; uni.showModal = ()=>{};
App.mpType = 'app' App.mpType = 'app'
......
...@@ -2,8 +2,7 @@ describe('pages/clientDB/demo/demo.vue', () => { ...@@ -2,8 +2,7 @@ describe('pages/clientDB/demo/demo.vue', () => {
let page,perPage,roles; let page,perPage,roles;
beforeAll(async () => { beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch( page = await program.reLaunch('/pages/clientDB/demo/demo')
'/pages/clientDB/demo/demo')
await page.waitFor("view") await page.waitFor("view")
perPage = await page.$('.page') perPage = await page.$('.page')
//底部角色控制条 //底部角色控制条
......
...@@ -64,26 +64,23 @@ describe('pages/clientDB/unicloud-db-demo/unicloud-db-demo', () => { ...@@ -64,26 +64,23 @@ describe('pages/clientDB/unicloud-db-demo/unicloud-db-demo', () => {
//改变分页策略为add //改变分页策略为add
// const pageCheckbox = await page.$('.page-checkbox') // const pageCheckbox = await page.$('.page-checkbox')
await page.setData({"pageData": "add"}) await page.setData({"pageData": "add"})
// console.log('pageData---add: ',await page.data('pageData')); console.log('pageData---: ',await page.data('pageData'));
const isAdd = await page.waitFor(async()=>{ await page.waitFor(1000)
const addText = await page.data('pageData')
return addText === 'add' //加载更多
}) /* if (process.env.UNI_PLATFORM === "mp-weixin") {
if(isAdd){//加载更多 const toLoadMore = await page.$('.toLoadMore')
/* if (process.env.UNI_PLATFORM === "mp-weixin") { const loadMore = await toLoadMore.$('.loadMore')
const toLoadMore = await page.$('.toLoadMore') await loadMore.tap()
const loadMore = await toLoadMore.$('.loadMore') await page.waitFor(300)
await loadMore.tap() } */
await page.waitFor(300) if (process.env.UNI_PLATFORM === "h5" || process.env.UNI_PLATFORM.startsWith("app")) {
} */ const loadMore = await page.$('.loadMore')
if (process.env.UNI_PLATFORM === "h5" || process.env.UNI_PLATFORM.startsWith("app")) { console.log('loadMore: ',loadMore);
const loadMore = await page.$('.loadMore') await loadMore.tap()
// console.log('loadMore: ',loadMore); await page.waitFor(300)
// await page.waitFor(300)
await loadMore.tap()
await page.waitFor(300)
}
} }
//每页数据数量减去1 //每页数据数量减去1
const pageSizeSubBefore = await page.data('pageSize') const pageSizeSubBefore = await page.data('pageSize')
const numBox2 = await page.$('.num-box2') const numBox2 = await page.$('.num-box2')
......
...@@ -3,25 +3,12 @@ describe('pages/schema2code/schema2code.nvue', () => { ...@@ -3,25 +3,12 @@ describe('pages/schema2code/schema2code.nvue', () => {
beforeAll(async () => { beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/schema2code/schema2code') page = await program.reLaunch('/pages/schema2code/schema2code')
await page.setData({ isTest: true })
await page.waitFor('view') await page.waitFor('view')
}) })
it('schema2code-点击', async () => { it('schema2code-点击', async () => {
const title = await page.$('.uni-title') const title = await page.$('.uni-title')
const showSchemaCode = await title.$('.showSchemaCode') const showSchemaCode = await title.$('.showSchemaCode')
await showSchemaCode.tap() await showSchemaCode.tap()
await page.waitFor(300) await page.waitFor(300)
// const showSchemaCode = await page.callMethod('showSchemaCode')
})
it('前往生成的云端一体页面', async () => {
const toForm = await page.$('.toForm')
await toForm.tap()
await page.waitFor(1000)
// expect( (await program.currentPage()).path).toBe('pages/user-info/list')
// await page.waitFor(500)
// //返回navigateBack 验证是否返回
// expect((await program.navigateBack()).path).toBe('pages/schema2code/schema2code')
}) })
}) })
<template> <template>
<view class="root"> <view class="root">
<view class="uni-title dashed-box"> <view class="uni-title dashed-box">
<text class="tip"> <text class="tip">
schema2code是一个根据数据库schema自动生成代码的工具。它可以直接生成云端一体的列表、详情、新建、修改页面,云端一体直接可用。大幅提升开发效率。 schema2code是一个根据数据库schema自动生成代码的工具。它可以直接生成云端一体的列表、详情、新建、修改页面,云端一体直接可用。大幅提升开发效率。
</text> </text>
<text>\n schema路径:uniCloud/database/user-info.schema.json \n</text> <text>\n schema路径:uniCloud/database/user-info.schema.json \n</text>
<button class="showSchemaCode" size="mini" @click="showSchemaCode" type="primary" plain>查看schema代码</button> <button class="showSchemaCode" size="mini" @click="showSchemaCode" type="primary" plain>查看schema代码</button>
</view> </view>
<j-video v-if="showVideo" :src="videoUrl" title="schema2code步骤演示" height="421rpx" width="750rpx"></j-video> <j-video v-if="showVideo" :src="videoUrl" title="schema2code步骤演示" height="421rpx" width="750rpx"></j-video>
<alertCode ref="alertCode"></alertCode> <alertCode ref="alertCode"></alertCode>
<button class="toForm" @click="toForm" type="primary" size="mini" plain>前往生成的云端一体页面</button> <button class="toForm" @click="toForm" type="primary" size="mini" plain>前往生成的云端一体页面</button>
</view> </view>
</template> </template>
<script> <script>
import schemaCode from './schemaCode'; import schemaCode from './schemaCode';
export default { export default {
data() { data() {
return { return {
schemaCode: schemaCode, schemaCode: schemaCode,
videoUrl: "https://web-assets.dcloud.net.cn/unidoc/zh/schema2code%E7%9A%84%E4%B8%A4%E7%A7%8D%E6%96%B9%E5%BC%8F.mp4", videoUrl: "https://web-assets.dcloud.net.cn/unidoc/zh/schema2code%E7%9A%84%E4%B8%A4%E7%A7%8D%E6%96%B9%E5%BC%8F.mp4",
// https://web-assets.dcloud.net.cn/unidoc/zh/create-schema2code-video.mp4, // https://web-assets.dcloud.net.cn/unidoc/zh/create-schema2code-video.mp4,
showVideo: false, showVideo: false,
isTest: false }
} },
}, onReady() {
onReady() { this.showVideo = true;
setTimeout(() => { },
if(!this.isTest){ methods: {
this.showVideo = true; async showSchemaCode() {
} return this.$refs.alertCode.open(schemaCode)
},1000) },
}, toForm() {
methods: { uni.navigateTo({
async showSchemaCode() { url: '../user-info/list'
return this.$refs.alertCode.open(schemaCode) })
}, }
toForm() { }
uni.navigateTo({ }
url: '../user-info/list'
})
}
}
}
</script> </script>
<style scoped> <style scoped>
.code-view { .code-view {
height: 750rpx; height: 750rpx;
width: 750rpx; width: 750rpx;
padding: 5px 8px; padding: 5px 8px;
overflow: scroll; overflow: scroll;
background-color: #fffae7; background-color: #fffae7;
} }
.code-box { .code-box {
white-space: nowrap; white-space: nowrap;
color: #447315; color: #447315;
font-size: 12px; font-size: 12px;
} }
.root { .root {
flex-direction: column; flex-direction: column;
} }
.dashed-box { .dashed-box {
border: dashed 1px #EEEEEE; border: dashed 1px #EEEEEE;
border-radius: 5px; border-radius: 5px;
width: 750rpx; width: 750rpx;
position: relative; position: relative;
} }
.uni-title { .uni-title {
width: 680rpx; width: 680rpx;
margin: 15rpx; margin: 15rpx;
font-size: 26rpx; font-size: 26rpx;
padding: 20rpx; padding: 20rpx;
line-height: 1.5; line-height: 1.5;
background-color: #FFFFFF; background-color: #FFFFFF;
} }
.uni-title text { .uni-title text {
font-size: 24rpx; font-size: 24rpx;
color: #888; color: #888;
} }
.toForm { .toForm {
width: 500rpx; width: 500rpx;
margin: 30px 125rpx; margin: 30px 125rpx;
} }
.uni-title text.link { .uni-title text.link {
color: #586b95; color: #586b95;
} }
text.tip { text.tip {
background-color: #FFFFFF; background-color: #FFFFFF;
color: #333; color: #333;
height: 80px; height: 80px;
width: 750rpx; width: 750rpx;
} }
.showSchemaCode { .showSchemaCode {
margin-top: 10px; margin-top: 10px;
} }
</style> </style>
\ No newline at end of file
...@@ -10,6 +10,7 @@ describe('pages/user-info/add.vue', () => { ...@@ -10,6 +10,7 @@ describe('pages/user-info/add.vue', () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/user-info/add') page = await program.reLaunch('/pages/user-info/add')
await page.waitFor('view') await page.waitFor('view')
await page.setData({'isTest':true})
}) })
it('输入表单内容', async () => { it('输入表单内容', async () => {
await page.setData({ await page.setData({
...@@ -30,5 +31,6 @@ describe('pages/user-info/add.vue', () => { ...@@ -30,5 +31,6 @@ describe('pages/user-info/add.vue', () => {
"isTest": true "isTest": true
}) })
await page.callMethod('submit') await page.callMethod('submit')
await page.waitFor(1000)
}) })
}) })
\ No newline at end of file
...@@ -23,19 +23,23 @@ ...@@ -23,19 +23,23 @@
<uni-easyinput placeholder="请输入网址的地址" v-model="formData.url"></uni-easyinput> <uni-easyinput placeholder="请输入网址的地址" v-model="formData.url"></uni-easyinput>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="favorite_book_id" label="喜欢的书"> <uni-forms-item name="favorite_book_id" label="喜欢的书">
<uni-data-checkbox v-model="formData.favorite_book_id" collection="book" field="title as text, _id as value" orderby="desc"></uni-data-checkbox> <uni-data-checkbox v-model="formData.favorite_book_id" collection="book" field="title as text, _id as value"
orderby="desc"></uni-data-checkbox>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="address_code" label="地址"> <uni-forms-item name="address_code" label="地址">
<uni-data-picker self-field="code" parent-field="parent_code" v-model="formData.address_code" collection="opendb-city-china" orderby="value asc" field="code as value, name as text"></uni-data-picker> <uni-data-picker self-field="code" parent-field="parent_code" v-model="formData.address_code"
collection="opendb-city-china" orderby="value asc" field="code as value, name as text"></uni-data-picker>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="party_member" label="是否为党员"> <uni-forms-item name="party_member" label="是否为党员">
<switch @change="binddata('party_member', $event.detail.value)" :checked="formData.party_member"></switch> <switch @change="binddata('party_member', $event.detail.value)" :checked="formData.party_member"></switch>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="hobby" label="业余爱好"> <uni-forms-item name="hobby" label="业余爱好">
<uni-data-checkbox multiple="true" :multiple="true" v-model="formData.hobby" :localdata="formOptions.hobby_localdata"></uni-data-checkbox> <uni-data-checkbox multiple="true" :multiple="true" v-model="formData.hobby"
:localdata="formOptions.hobby_localdata"></uni-data-checkbox>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="comment" label="备注"> <uni-forms-item name="comment" label="备注">
<textarea placeholder="拒绝违禁词,如:test" @input="binddata('comment', $event.detail.value)" class="uni-textarea-border" v-model="formData.comment"></textarea> <textarea placeholder="拒绝违禁词,如:test" @input="binddata('comment', $event.detail.value)"
class="uni-textarea-border" v-model="formData.comment"></textarea>
</uni-forms-item> </uni-forms-item>
<view class="uni-button-group"> <view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button> <button type="primary" class="uni-button" @click="submit">提交</button>
...@@ -45,7 +49,9 @@ ...@@ -45,7 +49,9 @@
</template> </template>
<script> <script>
import { validator } from '../../js_sdk/validator/user-info.js'; import {
validator
} from '../../js_sdk/validator/user-info.js';
const db = uniCloud.database(); const db = uniCloud.database();
const dbCollectionName = 'user-info'; const dbCollectionName = 'user-info';
...@@ -77,11 +83,11 @@ ...@@ -77,11 +83,11 @@
"comment": "" "comment": ""
} }
return { return {
isTest:false, //自动化测试
isTest: false,
formData, formData,
formOptions: { formOptions: {
"gender_localdata": [ "gender_localdata": [{
{
"text": "未知", "text": "未知",
"value": 0 "value": 0
}, },
...@@ -94,8 +100,7 @@ ...@@ -94,8 +100,7 @@
"value": 2 "value": 2
} }
], ],
"hobby_localdata": [ "hobby_localdata": [{
{
"text": "唱歌", "text": "唱歌",
"value": "Sing" "value": "Sing"
}, },
...@@ -125,8 +130,8 @@ ...@@ -125,8 +130,8 @@
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
return this.$refs.form.validate().then(async(res) => { return this.$refs.form.validate().then(async (res) => {
return await this.submitForm(res) return await this.submitForm(res)
}).catch(() => { }).catch(() => {
uni.hideLoading() uni.hideLoading()
}) })
...@@ -138,17 +143,17 @@ ...@@ -138,17 +143,17 @@
icon: 'none', icon: 'none',
title: '新增成功' title: '新增成功'
}) })
if(!this.isTest){ if (!this.isTest) {
this.getOpenerEventChannel().emit('refreshData') this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500) setTimeout(() => uni.navigateBack(), 500)
} }
return res return res
}).catch((err) => { }).catch((err) => {
uni.showModal({ uni.showModal({
content: err.message || '请求服务失败', content: err.message || '请求服务失败',
showCancel: false showCancel: false
}) })
return err return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
...@@ -199,4 +204,4 @@ ...@@ -199,4 +204,4 @@
line-height: 1; line-height: 1;
margin: 0; margin: 0;
} }
</style> </style>
\ No newline at end of file
...@@ -11,7 +11,7 @@ describe('pages/user-info/detail.vue', () => { ...@@ -11,7 +11,7 @@ describe('pages/user-info/detail.vue', () => {
// page = await program.navigateTo('/pages/user-info/detail') // page = await program.navigateTo('/pages/user-info/detail')
page = await program.currentPage() page = await program.currentPage()
await page.waitFor('view') await page.waitFor('view')
const getQuery = await page.query getQuery = await page.query
console.log('getQuery: ', getQuery); console.log('getQuery: ', getQuery);
if (Object.keys(getQuery).length === 0 || getQuery === undefined) { if (Object.keys(getQuery).length === 0 || getQuery === undefined) {
console.log('err query') console.log('err query')
...@@ -25,4 +25,11 @@ describe('pages/user-info/detail.vue', () => { ...@@ -25,4 +25,11 @@ describe('pages/user-info/detail.vue', () => {
console.log('currentPage', await program.currentPage()) console.log('currentPage', await program.currentPage())
expect((await program.currentPage()).path).toBe('pages/user-info/edit') expect((await program.currentPage()).path).toBe('pages/user-info/edit')
}) })
// it('删除当前数据', async () => {
// await page.callMethod('handleDelete')
// await page.waitFor(1000)
// const testRes = await page.data('testRes')
// console.log('testRes', testRes)
// console.log('currentPage', await program.currentPage())
// })
}) })
\ No newline at end of file
<template> <template>
<view class="container"> <view class="container">
<unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="options" <unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="options"
collection="user-info,book,opendb-city-china" 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" 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"> :where="queryWhere" :getone="true" :manual="true">
<view v-if="error">{{error.message}}</view> <view v-if="error">{{error.message}}</view>
<view v-else-if="loading"> <view v-else-if="loading">
<uni-load-more :contentText="loadMore" status="loading"></uni-load-more> <uni-load-more :contentText="loadMore" status="loading"></uni-load-more>
</view> </view>
<view v-else-if="data"> <view v-else-if="data">
<view> <view>
<text>真实姓名</text> <text>真实姓名</text>
<text>{{data.username}}</text> <text>{{data.username}}</text>
</view> </view>
<view> <view>
<text>性别</text> <text>性别</text>
<text>{{options.gender_valuetotext[data.gender]}}</text> <text>{{options.gender_valuetotext[data.gender]}}</text>
</view> </view>
<view> <view>
<text>生日</text> <text>生日</text>
<uni-dateformat :threshold="[0, 0]" :date="data.birth_date"></uni-dateformat> <uni-dateformat :threshold="[0, 0]" :date="data.birth_date"></uni-dateformat>
</view> </view>
<view> <view>
<text>体重</text> <text>体重</text>
<text>{{data.weight}}</text> <text>{{data.weight}}</text>
</view> </view>
<view> <view>
<text>手机号码</text> <text>手机号码</text>
<text>{{data.mobile}}</text> <text>{{data.mobile}}</text>
</view> </view>
<view> <view>
<text>邮箱账号</text> <text>邮箱账号</text>
<uni-link :href="'mailto:'+data.email" :text="data.email"></uni-link> <uni-link :href="'mailto:'+data.email" :text="data.email"></uni-link>
</view> </view>
<view> <view>
<text>个人博客</text> <text>个人博客</text>
<uni-link :href="data.url" :download="data.url" :text="data.url"></uni-link> <uni-link :href="data.url" :download="data.url" :text="data.url"></uni-link>
</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.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.address_code && data.address_code[0] && data.address_code[0].name}}</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.party_member == true ? '' : ''}}</text> <text>{{data.party_member == true ? '' : ''}}</text>
</view> </view>
<view> <view>
<text>业余爱好</text> <text>业余爱好</text>
<uni-data-picker :localdata="options.hobby_valuetotext" :value="data.hobby" :multiple="false" <uni-data-picker :localdata="options.hobby_valuetotext" :value="data.hobby" :multiple="false" :readonly="true"
:readonly="true" :arrow="false" split=","></uni-data-picker> :arrow="false" split=","></uni-data-picker>
</view> </view>
<view> <view>
<text>备注</text> <text>备注</text>
<text>{{data.comment}}</text> <text>{{data.comment}}</text>
</view> </view>
</view> </view>
</unicloud-db> </unicloud-db>
<view class="btns"> <view class="btns">
<button type="primary" @click="handleUpdate">修改</button> <button type="primary" @click="handleUpdate">修改</button>
<button type="warn" class="btn-delete" @click="handleDelete">删除</button> <button type="warn" class="btn-delete" @click="handleDelete">删除</button>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
// 由schema2code生成,包含校验规则和enum静态数据 // 由schema2code生成,包含校验规则和enum静态数据
import { import {
enumConverter enumConverter
} from '../../js_sdk/validator/user-info.js'; } 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: '',
} //自动化测试
}, testRes:{}
onLoad(e) { }
console.log('e:-----id ', e); },
this._id = e.id onLoad(e) {
}, console.log('e:-----id ', e);
onReady() { this._id = e.id
if (this._id) { },
this.queryWhere = '_id=="' + this._id + '"' onReady() {
} if (this._id) {
}, this.queryWhere = '_id=="' + this._id + '"'
methods: { }
handleUpdate() { },
// 打开修改页面 methods: {
uni.navigateTo({ handleUpdate() {
url: './edit?id=' + this._id, // 打开修改页面
events: { uni.navigateTo({
// 监听修改页面成功修改数据后, 刷新当前页面数据 url: './edit?id=' + this._id,
refreshData: () => { events: {
this.$refs.udb.loadData({ // 监听修改页面成功修改数据后, 刷新当前页面数据
clear: true refreshData: () => {
}) this.$refs.udb.loadData({
} clear: true
} })
}) }
}, }
handleDelete() { })
console.log('handleDelete:-----'); },
this.$refs.udb.remove(this._id, { handleDelete() {
success: (res) => { this.$refs.udb.remove(this._id, {
console.log('res:-----', res); needConfirm: false, //自动化测试关闭弹框
// 删除数据成功后跳转到list页面 success: (res) => {
uni.navigateTo({ console.log('res:-----', res);
url: './list' this.testRes = res
}) // 删除数据成功后跳转到list页面
}, uni.navigateTo({
fail: (err) => { url: './list'
console.log('err:-----', err); })
uni.showToast({ },
title: '删除失败', fail: (err) => {
icon: 'none' console.log('err:-----', err);
}) this.testRes = 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
...@@ -10,7 +10,9 @@ describe('pages/user-info/detail.vue', () => { ...@@ -10,7 +10,9 @@ describe('pages/user-info/detail.vue', () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
// page = await program.navigateTo('/pages/user-info/edit?id=601d044ac9e7be0001cc00b8') // page = await program.navigateTo('/pages/user-info/edit?id=601d044ac9e7be0001cc00b8')
page = await program.currentPage() page = await program.currentPage()
await page.waitFor('view') console.log('page: ', page);
await page.waitFor('view')
await page.setData({'isTest':true})
getQuery = await page.query getQuery = await page.query
console.log('getQuery: ', getQuery); console.log('getQuery: ', getQuery);
if (Object.keys(getQuery).length === 0 || getQuery === undefined) { if (Object.keys(getQuery).length === 0 || getQuery === undefined) {
......
...@@ -23,19 +23,23 @@ ...@@ -23,19 +23,23 @@
<uni-easyinput placeholder="请输入网址的地址" v-model="formData.url"></uni-easyinput> <uni-easyinput placeholder="请输入网址的地址" v-model="formData.url"></uni-easyinput>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="favorite_book_id" label="喜欢的书"> <uni-forms-item name="favorite_book_id" label="喜欢的书">
<uni-data-checkbox v-model="formData.favorite_book_id" collection="book" field="title as text, _id as value" orderby="desc"></uni-data-checkbox> <uni-data-checkbox v-model="formData.favorite_book_id" collection="book" field="title as text, _id as value"
orderby="desc"></uni-data-checkbox>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="address_code" label="地址"> <uni-forms-item name="address_code" label="地址">
<uni-data-picker self-field="code" parent-field="parent_code" v-model="formData.address_code" collection="opendb-city-china" orderby="value asc" field="code as value, name as text"></uni-data-picker> <uni-data-picker self-field="code" parent-field="parent_code" v-model="formData.address_code"
collection="opendb-city-china" orderby="value asc" field="code as value, name as text"></uni-data-picker>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="party_member" label="是否为党员"> <uni-forms-item name="party_member" label="是否为党员">
<switch @change="binddata('party_member', $event.detail.value)" :checked="formData.party_member"></switch> <switch @change="binddata('party_member', $event.detail.value)" :checked="formData.party_member"></switch>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="hobby" label="业余爱好"> <uni-forms-item name="hobby" label="业余爱好">
<uni-data-checkbox multiple="true" :multiple="true" v-model="formData.hobby" :localdata="formOptions.hobby_localdata"></uni-data-checkbox> <uni-data-checkbox multiple="true" :multiple="true" v-model="formData.hobby"
:localdata="formOptions.hobby_localdata"></uni-data-checkbox>
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="comment" label="备注"> <uni-forms-item name="comment" label="备注">
<textarea placeholder="拒绝违禁词,如:test" @input="binddata('comment', $event.detail.value)" class="uni-textarea-border" v-model="formData.comment"></textarea> <textarea placeholder="拒绝违禁词,如:test" @input="binddata('comment', $event.detail.value)"
class="uni-textarea-border" v-model="formData.comment"></textarea>
</uni-forms-item> </uni-forms-item>
<view class="uni-button-group"> <view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button> <button type="primary" class="uni-button" @click="submit">提交</button>
...@@ -45,7 +49,9 @@ ...@@ -45,7 +49,9 @@
</template> </template>
<script> <script>
import { validator } from '../../js_sdk/validator/user-info.js'; import {
validator
} from '../../js_sdk/validator/user-info.js';
const db = uniCloud.database(); const db = uniCloud.database();
const dbCollectionName = 'user-info'; const dbCollectionName = 'user-info';
...@@ -77,11 +83,11 @@ ...@@ -77,11 +83,11 @@
"comment": "" "comment": ""
} }
return { return {
isTest:false, //自动化测试
isTest: false,
formData, formData,
formOptions: { formOptions: {
"gender_localdata": [ "gender_localdata": [{
{
"text": "未知", "text": "未知",
"value": 0 "value": 0
}, },
...@@ -94,8 +100,7 @@ ...@@ -94,8 +100,7 @@
"value": 2 "value": 2
} }
], ],
"hobby_localdata": [ "hobby_localdata": [{
{
"text": "唱歌", "text": "唱歌",
"value": "Sing" "value": "Sing"
}, },
...@@ -132,7 +137,7 @@ ...@@ -132,7 +137,7 @@
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
return this.$refs.form.validate().then(async(res) => { return this.$refs.form.validate().then(async (res) => {
return await this.submitForm(res) return await this.submitForm(res)
}).catch(() => { }).catch(() => {
uni.hideLoading() uni.hideLoading()
...@@ -146,19 +151,18 @@ ...@@ -146,19 +151,18 @@
icon: 'none', icon: 'none',
title: '修改成功' title: '修改成功'
}) })
if(!this.isTest){ if (!this.isTest) {
this.getOpenerEventChannel().emit('refreshData')
} setTimeout(() => uni.navigateBack(), 500)
this.getOpenerEventChannel().emit('refreshData') }
setTimeout(() => uni.navigateBack(), 500) console.log('res: ', res);
console.log('res: ',res); return res.result
return res.result
}).catch((err) => { }).catch((err) => {
uni.showModal({ uni.showModal({
content: err.message || '请求服务失败', content: err.message || '请求服务失败',
showCancel: false showCancel: false
}) })
return err return err
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
...@@ -172,7 +176,9 @@ ...@@ -172,7 +176,9 @@
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
db.collection(dbCollectionName).doc(id).field("username,gender,birth_date,weight,mobile,email,url,favorite_book_id,address_code,party_member,hobby,comment").get().then((res) => { db.collection(dbCollectionName).doc(id).field(
"username,gender,birth_date,weight,mobile,email,url,favorite_book_id,address_code,party_member,hobby,comment"
).get().then((res) => {
const data = res.result.data[0] const data = res.result.data[0]
if (data) { if (data) {
this.formData = data this.formData = data
...@@ -232,4 +238,4 @@ ...@@ -232,4 +238,4 @@
line-height: 1; line-height: 1;
margin: 0; margin: 0;
} }
</style> </style>
\ No newline at end of file
// jest.setTimeout(20000) // jest.setTimeout(20000)
describe('pages/user-info/list.vue', () => { describe('pages/user-info/list.vue', () => {
let page, currentPage; let page, currentPage;
console.log('uniTestPlatformInfo', process.env.uniTestPlatformInfo) console.log('uniTestPlatformInfo', process.env.uniTestPlatformInfo,process.env.UNI_PLATFORM)
if (process.env.uniTestPlatformInfo == 'ios_simulator 13.7') { if (process.env.uniTestPlatformInfo == 'ios_simulator 13.7') {
it('ios', async () => { it('ios', async () => {
expect(1).toBe(1) expect(1).toBe(1)
...@@ -12,7 +12,6 @@ describe('pages/user-info/list.vue', () => { ...@@ -12,7 +12,6 @@ describe('pages/user-info/list.vue', () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象) // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.navigateTo('/pages/user-info/list') page = await program.navigateTo('/pages/user-info/list')
await page.waitFor('view') await page.waitFor('view')
console.log('process----', process.env.UNI_PLATFORM)
}) })
async function waitTime() { async function waitTime() {
if (process.env.UNI_PLATFORM == 'mp-weixin') { if (process.env.UNI_PLATFORM == 'mp-weixin') {
...@@ -21,7 +20,7 @@ describe('pages/user-info/list.vue', () => { ...@@ -21,7 +20,7 @@ describe('pages/user-info/list.vue', () => {
await page.waitFor(1000) await page.waitFor(1000)
} }
} }
it('点击fab跳转到添加', async () => { it('点击fab跳转到add', async () => {
await page.callMethod('fabClick') await page.callMethod('fabClick')
await page.waitFor('view') await page.waitFor('view')
await waitTime() await waitTime()
...@@ -33,7 +32,7 @@ describe('pages/user-info/list.vue', () => { ...@@ -33,7 +32,7 @@ describe('pages/user-info/list.vue', () => {
await program.navigateBack() await program.navigateBack()
await page.waitFor('view') await page.waitFor('view')
}) })
it('点击第一条', async () => { it('点击第一条跳转到detail页', async () => {
await waitTime() await waitTime()
const items = await page.$$('.uni-list-item') const items = await page.$$('.uni-list-item')
if (items.length > 0) { if (items.length > 0) {
......
const Sequencer = require("@jest/test-sequencer").default; const Sequencer = require("@jest/test-sequencer").default;
const sortTestFilenames = ["add.test.js","list.test.js","detail.test.js","edit.test.js","cloudFunction.test.js"]; const sortTestFilenames = ["add.test.js","list.test.js","detail.test.js","edit.test.js"];
class CustomSequencer extends Sequencer { class CustomSequencer extends Sequencer {
sort(tests) { sort(tests) {
// 测试例排序 // 测试例排序
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册