From 131b0724bb0bc4b4b1151bdc7c4bc14cab30dfd4 Mon Sep 17 00:00:00 2001 From: Anne_LXM Date: Wed, 8 May 2024 16:17:33 +0800 Subject: [PATCH] test update --- main.js | 2 +- pages/clientDB/demo/demo.test.js | 3 +- .../unicloud-db-demo/unicloud-db-demo.test.js | 35 +- pages/schema2code/schema2code.test.js | 13 - pages/schema2code/schema2code.vue | 175 +++++----- pages/user-info/add.test.js | 2 + pages/user-info/add.vue | 43 +-- pages/user-info/detail.test.js | 9 +- pages/user-info/detail.vue | 298 +++++++++--------- pages/user-info/edit.test.js | 4 +- pages/user-info/edit.vue | 48 +-- pages/user-info/list.test.js | 7 +- testSequencer.js | 2 +- 13 files changed, 322 insertions(+), 319 deletions(-) diff --git a/main.js b/main.js index 6019751..d1ed13d 100644 --- a/main.js +++ b/main.js @@ -3,7 +3,7 @@ import App from './App' // #ifndef VUE3 import Vue from 'vue' Vue.config.productionTip = false - +//自动化测试 uni.showModal = ()=>{}; App.mpType = 'app' diff --git a/pages/clientDB/demo/demo.test.js b/pages/clientDB/demo/demo.test.js index 6fc685c..cb8ac15 100644 --- a/pages/clientDB/demo/demo.test.js +++ b/pages/clientDB/demo/demo.test.js @@ -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') //底部角色控制条 diff --git a/pages/clientDB/unicloud-db-demo/unicloud-db-demo.test.js b/pages/clientDB/unicloud-db-demo/unicloud-db-demo.test.js index a832d5f..4f9c389 100644 --- a/pages/clientDB/unicloud-db-demo/unicloud-db-demo.test.js +++ b/pages/clientDB/unicloud-db-demo/unicloud-db-demo.test.js @@ -64,26 +64,23 @@ 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){//加载更多 - /* if (process.env.UNI_PLATFORM === "mp-weixin") { - const toLoadMore = await page.$('.toLoadMore') - const loadMore = await toLoadMore.$('.loadMore') - await loadMore.tap() - await page.waitFor(300) - } */ - 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) - await loadMore.tap() - await page.waitFor(300) - } + 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') + await loadMore.tap() + await page.waitFor(300) + } */ + if (process.env.UNI_PLATFORM === "h5" || process.env.UNI_PLATFORM.startsWith("app")) { + const loadMore = await page.$('.loadMore') + console.log('loadMore: ',loadMore); + await loadMore.tap() + await page.waitFor(300) } + //每页数据数量减去1 const pageSizeSubBefore = await page.data('pageSize') const numBox2 = await page.$('.num-box2') diff --git a/pages/schema2code/schema2code.test.js b/pages/schema2code/schema2code.test.js index 982a73d..17776e0 100644 --- a/pages/schema2code/schema2code.test.js +++ b/pages/schema2code/schema2code.test.js @@ -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') }) }) diff --git a/pages/schema2code/schema2code.vue b/pages/schema2code/schema2code.vue index 715b90c..a83593b 100644 --- a/pages/schema2code/schema2code.vue +++ b/pages/schema2code/schema2code.vue @@ -1,107 +1,102 @@ \ No newline at end of file diff --git a/pages/user-info/add.test.js b/pages/user-info/add.test.js index 4af2646..3d36b08 100644 --- a/pages/user-info/add.test.js +++ b/pages/user-info/add.test.js @@ -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 diff --git a/pages/user-info/add.vue b/pages/user-info/add.vue index bad592d..83449a7 100644 --- a/pages/user-info/add.vue +++ b/pages/user-info/add.vue @@ -23,19 +23,23 @@ - + - + - + - + @@ -45,7 +49,9 @@ \ No newline at end of file diff --git a/pages/user-info/edit.test.js b/pages/user-info/edit.test.js index fba5ec2..5a9cdab 100644 --- a/pages/user-info/edit.test.js +++ b/pages/user-info/edit.test.js @@ -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() - await page.waitFor('view') + 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) { diff --git a/pages/user-info/edit.vue b/pages/user-info/edit.vue index 8f34a51..5987471 100644 --- a/pages/user-info/edit.vue +++ b/pages/user-info/edit.vue @@ -23,19 +23,23 @@ - + - + - + - + @@ -45,7 +49,9 @@