提交 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,12 +64,10 @@ describe('pages/clientDB/unicloud-db-demo/unicloud-db-demo', () => { ...@@ -64,12 +64,10 @@ 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(isAdd){//加载更多
/* if (process.env.UNI_PLATFORM === "mp-weixin") { /* if (process.env.UNI_PLATFORM === "mp-weixin") {
const toLoadMore = await page.$('.toLoadMore') const toLoadMore = await page.$('.toLoadMore')
const loadMore = await toLoadMore.$('.loadMore') const loadMore = await toLoadMore.$('.loadMore')
...@@ -78,12 +76,11 @@ describe('pages/clientDB/unicloud-db-demo/unicloud-db-demo', () => { ...@@ -78,12 +76,11 @@ describe('pages/clientDB/unicloud-db-demo/unicloud-db-demo', () => {
} */ } */
if (process.env.UNI_PLATFORM === "h5" || process.env.UNI_PLATFORM.startsWith("app")) { if (process.env.UNI_PLATFORM === "h5" || process.env.UNI_PLATFORM.startsWith("app")) {
const loadMore = await page.$('.loadMore') const loadMore = await page.$('.loadMore')
// console.log('loadMore: ',loadMore); console.log('loadMore: ',loadMore);
// await page.waitFor(300)
await loadMore.tap() await loadMore.tap()
await page.waitFor(300) 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')
}) })
}) })
...@@ -22,15 +22,10 @@ ...@@ -22,15 +22,10 @@
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() {
setTimeout(() => {
if(!this.isTest){
this.showVideo = true; this.showVideo = true;
}
},1000)
}, },
methods: { methods: {
async showSchemaCode() { async showSchemaCode() {
......
...@@ -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,7 +130,7 @@ ...@@ -125,7 +130,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()
...@@ -138,7 +143,7 @@ ...@@ -138,7 +143,7 @@
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)
} }
......
...@@ -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
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
</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>
...@@ -86,7 +86,9 @@ ...@@ -86,7 +86,9 @@
// 将scheme enum 属性静态数据中的value转成text // 将scheme enum 属性静态数据中的value转成text
...enumConverter ...enumConverter
}, },
_id: '' _id: '',
//自动化测试
testRes:{}
} }
}, },
onLoad(e) { onLoad(e) {
...@@ -114,10 +116,11 @@ ...@@ -114,10 +116,11 @@
}) })
}, },
handleDelete() { handleDelete() {
console.log('handleDelete:-----');
this.$refs.udb.remove(this._id, { this.$refs.udb.remove(this._id, {
needConfirm: false, //自动化测试关闭弹框
success: (res) => { success: (res) => {
console.log('res:-----', res); console.log('res:-----', res);
this.testRes = res
// 删除数据成功后跳转到list页面 // 删除数据成功后跳转到list页面
uni.navigateTo({ uni.navigateTo({
url: './list' url: './list'
...@@ -125,6 +128,7 @@ ...@@ -125,6 +128,7 @@
}, },
fail: (err) => { fail: (err) => {
console.log('err:-----', err); console.log('err:-----', err);
this.testRes = err
uni.showToast({ uni.showToast({
title: '删除失败', title: '删除失败',
icon: 'none' icon: 'none'
......
...@@ -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()
console.log('page: ', page);
await page.waitFor('view') 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,12 +151,11 @@ ...@@ -146,12 +151,11 @@
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)
console.log('res: ',res); }
console.log('res: ', res);
return res.result return res.result
}).catch((err) => { }).catch((err) => {
uni.showModal({ uni.showModal({
...@@ -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
......
// 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.
先完成此消息的编辑!
想要评论请 注册