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

test update

上级 c255655a
......@@ -3,7 +3,7 @@ import App from './App'
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
//自动化测试
uni.showModal = ()=>{};
App.mpType = 'app'
......
......@@ -2,8 +2,7 @@ describe('pages/clientDB/demo/demo.vue', () => {
let page,perPage,roles;
beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch(
'/pages/clientDB/demo/demo')
page = await program.reLaunch('/pages/clientDB/demo/demo')
await page.waitFor("view")
perPage = await page.$('.page')
//底部角色控制条
......
......@@ -64,12 +64,10 @@ describe('pages/clientDB/unicloud-db-demo/unicloud-db-demo', () => {
//改变分页策略为add
// const pageCheckbox = await page.$('.page-checkbox')
await page.setData({"pageData": "add"})
// console.log('pageData---add: ',await page.data('pageData'));
const isAdd = await page.waitFor(async()=>{
const addText = await page.data('pageData')
return addText === 'add'
})
if(isAdd){//加载更多
console.log('pageData---: ',await page.data('pageData'));
await page.waitFor(1000)
//加载更多
/* if (process.env.UNI_PLATFORM === "mp-weixin") {
const toLoadMore = await page.$('.toLoadMore')
const loadMore = await toLoadMore.$('.loadMore')
......@@ -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")) {
const loadMore = await page.$('.loadMore')
// console.log('loadMore: ',loadMore);
// await page.waitFor(300)
console.log('loadMore: ',loadMore);
await loadMore.tap()
await page.waitFor(300)
}
}
//每页数据数量减去1
const pageSizeSubBefore = await page.data('pageSize')
const numBox2 = await page.$('.num-box2')
......
......@@ -3,25 +3,12 @@ describe('pages/schema2code/schema2code.nvue', () => {
beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/schema2code/schema2code')
await page.setData({ isTest: true })
await page.waitFor('view')
})
it('schema2code-点击', async () => {
const title = await page.$('.uni-title')
const showSchemaCode = await title.$('.showSchemaCode')
await showSchemaCode.tap()
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 @@
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,
showVideo: false,
isTest: false
}
},
onReady() {
setTimeout(() => {
if(!this.isTest){
this.showVideo = true;
}
},1000)
},
methods: {
async showSchemaCode() {
......
......@@ -10,6 +10,7 @@ describe('pages/user-info/add.vue', () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/user-info/add')
await page.waitFor('view')
await page.setData({'isTest':true})
})
it('输入表单内容', async () => {
await page.setData({
......@@ -30,5 +31,6 @@ describe('pages/user-info/add.vue', () => {
"isTest": true
})
await page.callMethod('submit')
await page.waitFor(1000)
})
})
\ No newline at end of file
......@@ -23,19 +23,23 @@
<uni-easyinput placeholder="请输入网址的地址" v-model="formData.url"></uni-easyinput>
</uni-forms-item>
<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 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 name="party_member" label="是否为党员">
<switch @change="binddata('party_member', $event.detail.value)" :checked="formData.party_member"></switch>
</uni-forms-item>
<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 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>
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
......@@ -45,7 +49,9 @@
</template>
<script>
import { validator } from '../../js_sdk/validator/user-info.js';
import {
validator
} from '../../js_sdk/validator/user-info.js';
const db = uniCloud.database();
const dbCollectionName = 'user-info';
......@@ -77,11 +83,11 @@
"comment": ""
}
return {
isTest:false,
//自动化测试
isTest: false,
formData,
formOptions: {
"gender_localdata": [
{
"gender_localdata": [{
"text": "未知",
"value": 0
},
......@@ -94,8 +100,7 @@
"value": 2
}
],
"hobby_localdata": [
{
"hobby_localdata": [{
"text": "唱歌",
"value": "Sing"
},
......@@ -125,7 +130,7 @@
uni.showLoading({
mask: true
})
return this.$refs.form.validate().then(async(res) => {
return this.$refs.form.validate().then(async (res) => {
return await this.submitForm(res)
}).catch(() => {
uni.hideLoading()
......@@ -138,7 +143,7 @@
icon: 'none',
title: '新增成功'
})
if(!this.isTest){
if (!this.isTest) {
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}
......
......@@ -11,7 +11,7 @@ describe('pages/user-info/detail.vue', () => {
// page = await program.navigateTo('/pages/user-info/detail')
page = await program.currentPage()
await page.waitFor('view')
const getQuery = await page.query
getQuery = await page.query
console.log('getQuery: ', getQuery);
if (Object.keys(getQuery).length === 0 || getQuery === undefined) {
console.log('err query')
......@@ -25,4 +25,11 @@ describe('pages/user-info/detail.vue', () => {
console.log('currentPage', await program.currentPage())
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 @@
</view>
<view>
<text>业余爱好</text>
<uni-data-picker :localdata="options.hobby_valuetotext" :value="data.hobby" :multiple="false"
:readonly="true" :arrow="false" split=","></uni-data-picker>
<uni-data-picker :localdata="options.hobby_valuetotext" :value="data.hobby" :multiple="false" :readonly="true"
:arrow="false" split=","></uni-data-picker>
</view>
<view>
<text>备注</text>
......@@ -86,7 +86,9 @@
// 将scheme enum 属性静态数据中的value转成text
...enumConverter
},
_id: ''
_id: '',
//自动化测试
testRes:{}
}
},
onLoad(e) {
......@@ -114,10 +116,11 @@
})
},
handleDelete() {
console.log('handleDelete:-----');
this.$refs.udb.remove(this._id, {
needConfirm: false, //自动化测试关闭弹框
success: (res) => {
console.log('res:-----', res);
this.testRes = res
// 删除数据成功后跳转到list页面
uni.navigateTo({
url: './list'
......@@ -125,6 +128,7 @@
},
fail: (err) => {
console.log('err:-----', err);
this.testRes = err
uni.showToast({
title: '删除失败',
icon: 'none'
......
......@@ -10,7 +10,9 @@ describe('pages/user-info/detail.vue', () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
// page = await program.navigateTo('/pages/user-info/edit?id=601d044ac9e7be0001cc00b8')
page = await program.currentPage()
console.log('page: ', page);
await page.waitFor('view')
await page.setData({'isTest':true})
getQuery = await page.query
console.log('getQuery: ', getQuery);
if (Object.keys(getQuery).length === 0 || getQuery === undefined) {
......
......@@ -23,19 +23,23 @@
<uni-easyinput placeholder="请输入网址的地址" v-model="formData.url"></uni-easyinput>
</uni-forms-item>
<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 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 name="party_member" label="是否为党员">
<switch @change="binddata('party_member', $event.detail.value)" :checked="formData.party_member"></switch>
</uni-forms-item>
<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 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>
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
......@@ -45,7 +49,9 @@
</template>
<script>
import { validator } from '../../js_sdk/validator/user-info.js';
import {
validator
} from '../../js_sdk/validator/user-info.js';
const db = uniCloud.database();
const dbCollectionName = 'user-info';
......@@ -77,11 +83,11 @@
"comment": ""
}
return {
isTest:false,
//自动化测试
isTest: false,
formData,
formOptions: {
"gender_localdata": [
{
"gender_localdata": [{
"text": "未知",
"value": 0
},
......@@ -94,8 +100,7 @@
"value": 2
}
],
"hobby_localdata": [
{
"hobby_localdata": [{
"text": "唱歌",
"value": "Sing"
},
......@@ -132,7 +137,7 @@
uni.showLoading({
mask: true
})
return this.$refs.form.validate().then(async(res) => {
return this.$refs.form.validate().then(async (res) => {
return await this.submitForm(res)
}).catch(() => {
uni.hideLoading()
......@@ -146,12 +151,11 @@
icon: 'none',
title: '修改成功'
})
if(!this.isTest){
}
if (!this.isTest) {
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
console.log('res: ',res);
}
console.log('res: ', res);
return res.result
}).catch((err) => {
uni.showModal({
......@@ -172,7 +176,9 @@
uni.showLoading({
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]
if (data) {
this.formData = data
......
// jest.setTimeout(20000)
describe('pages/user-info/list.vue', () => {
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') {
it('ios', async () => {
expect(1).toBe(1)
......@@ -12,7 +12,6 @@ describe('pages/user-info/list.vue', () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.navigateTo('/pages/user-info/list')
await page.waitFor('view')
console.log('process----', process.env.UNI_PLATFORM)
})
async function waitTime() {
if (process.env.UNI_PLATFORM == 'mp-weixin') {
......@@ -21,7 +20,7 @@ describe('pages/user-info/list.vue', () => {
await page.waitFor(1000)
}
}
it('点击fab跳转到添加', async () => {
it('点击fab跳转到add', async () => {
await page.callMethod('fabClick')
await page.waitFor('view')
await waitTime()
......@@ -33,7 +32,7 @@ describe('pages/user-info/list.vue', () => {
await program.navigateBack()
await page.waitFor('view')
})
it('点击第一条', async () => {
it('点击第一条跳转到detail页', async () => {
await waitTime()
const items = await page.$$('.uni-list-item')
if (items.length > 0) {
......
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 {
sort(tests) {
// 测试例排序
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册