提交 4ace9115 编写于 作者: Anne_LXM's avatar Anne_LXM

test userinfo.test.js/ucenter.test.js

上级 1d4140d0
......@@ -6,14 +6,13 @@ describe('grid', () => {
let page, hasLogin;
beforeAll(async () => {
page = await program.switchTab(PAGE_PATH)
console.log('page',page)
await page.waitFor('view')
})
it('检测宫格', async () => {
await page.waitFor(2000)
hasLogin = await page.data('hasLogin')
let gridList = await page.data('gridList')
console.log("gridList", hasLogin,gridList.length)
console.log("gridList", gridList.length,hasLogin)
expect(gridList.length).toBe(9)
})
it('点击宫格', async () => {
......
......@@ -93,7 +93,7 @@
showRefresh: false,
listHight: 0,
dataList:{},
isTest:false
isTest:true
}
},
watch: {
......
const PAGE_PATH = '/pages/list/list'
describe('list', () => {
let page,containsVite,isApp;
containsVite = process.env.UNI_CLI_PATH.includes('uniapp-cli-vite')
isApp = process.env.UNI_PLATFORM.includes('app')
if(containsVite && isApp){
it('vue3', async () => {
expect(1).toBe(1)
})
return
}
beforeAll(async () => {
page = await program.switchTab(PAGE_PATH)
console.log('page',page);
await page.waitFor('view')
await page.setData({'isTest':true})
})
it('检测标题', async () => {
expect.assertions(1);
await page.waitFor(5000)
const getTitle = await page.data('dataList')
console.log('getTitle: ',getTitle);
expect(getTitle.title).toBe('阿里小程序IDE官方内嵌uni-app,为开发者提供多端开发服务')
})
it('点击搜索跳转', async () => {
await page.callMethod('searchClick')
await page.waitFor(300)
})
const PAGE_PATH = '/pages/list/list'
describe('list', () => {
let page, containsVite, isApp;
containsVite = process.env.UNI_CLI_PATH.includes('uniapp-cli-vite')
isApp = process.env.UNI_PLATFORM.includes('app')
if (containsVite && isApp) {
it('vue3', async () => {
expect(1).toBe(1)
})
return
}
beforeAll(async () => {
page = await program.switchTab(PAGE_PATH)
await page.waitFor('view')
await page.setData({'isTest': true})
})
it('检测标题', async () => {
expect.assertions(1);
await page.waitFor(5000)
const getTitle = await page.data('dataList')
console.log('getTitle: ', getTitle);
expect(getTitle.title).toBe('阿里小程序IDE官方内嵌uni-app,为开发者提供多端开发服务')
})
it('点击搜索跳转', async () => {
await page.callMethod('searchClick')
await page.waitFor(300)
})
})
\ No newline at end of file
......@@ -5,8 +5,6 @@ describe('search', () => {
let page, containsVite, isApp;
containsVite = process.env.UNI_CLI_PATH.includes('uniapp-cli-vite')
isApp = process.env.UNI_PLATFORM.includes('app')
console.log('uniTestPlatformInfo', process.env.uniTestPlatformInfo)
console.log((containsVite && isApp) ,process.env.uniTestPlatformInfo == 'ios_simulator 13.7')
if ((containsVite && isApp) || process.env.uniTestPlatformInfo == 'ios_simulator 13.7') {
it('app--vue3', async () => {
expect(1).toBe(1)
......@@ -15,7 +13,6 @@ describe('search', () => {
}
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
console.log('page', page)
console.log('page', await program.pageStack())
await page.waitFor('view')
})
......
......@@ -35,7 +35,6 @@ describe('settings', () => {
})
it('退出登录', async () => {
const bottomEl = await page.$('.bottom-back-text')
console.log('bottom-back-text', bottomEl, await bottomEl.text())
expect(await bottomEl.text()).toBe('退出登录')
await page.callMethod('changeLoginState')
await page.waitFor(1000)
......
......@@ -3,8 +3,7 @@ const PAGE_PATH = '/pages/ucenter/ucenter'
describe('ucenter', () => {
let page, platform, hasLogin;
platform = process.env.UNI_PLATFORM
console.log('uniTestPlatformInfo', process.env.uniTestPlatformInfo, process.env.uniTestPlatformInfo ==
'ios_simulator 13.7')
console.log('uniTestPlatformInfo', process.env.uniTestPlatformInfo)
if (process.env.uniTestPlatformInfo == 'ios_simulator 13.7') {
it('ucenter-ios13.7', async () => {
expect(1).toBe(1)
......@@ -12,34 +11,28 @@ describe('ucenter', () => {
return
}
beforeAll(async () => {
try {
page = await program.switchTab(PAGE_PATH)
await page.waitFor('view')
hasLogin = await page.callMethod('hasLoginTest')
console.log("登录状态", hasLogin, platform)
} catch (err) {
console.log('err: ', err);
page = await program.switchTab(PAGE_PATH)
await page.waitFor('view')
hasLogin = await page.callMethod('hasLoginTest')
console.log("登录状态", hasLogin, platform)
if (!hasLogin) {
console.log('hasLogin--err')
return
}
})
it('宫格', async () => {
expect.assertions(1);
const getGrid = await page.data('gridList')
console.log('getGrid', getGrid.length)
expect(getGrid.length).toBe(4)
})
it('列表', async () => {
const getUcenterList = await page.data('ucenterList')
console.log('getUcenterList', getUcenterList.length)
if (platform === "mp-weixin") {
expect(getUcenterList.length).toBe(2);
} else {
expect(getUcenterList.length).toBe(3);
}
})
if (!hasLogin) {
console.log('hasLogin--err')
return
}
})
it('普通签到', async () => {
if (platform.startsWith("app")) {
await page.callMethod('signInByAd')
......
......@@ -2,7 +2,7 @@
const PAGE_PATH = '/uni_modules/uni-id-pages/pages/userinfo/userinfo'
jest.setTimeout(30000);
describe('userinfo', () => {
let page, hasLogin;
let page, userInfo;
if (process.env.uniTestPlatformInfo == 'ios_simulator 13.7') {
it('userinfo-ios', async () => {
expect(1).toBe(1)
......@@ -12,18 +12,29 @@ describe('userinfo', () => {
beforeAll(async () => {
page = await program.navigateTo(PAGE_PATH)
await page.waitFor("view")
hasLogin = await page.callMethod('hasLoginTest')
console.log("登录状态", hasLogin)
if (!hasLogin) {
userInfo = await page.callMethod('userInfoTest')
console.log("userInfo---1", userInfo)
if (!userInfo._id) {
console.log("未登录测试失败")
return
}
});
it("昵称", async () => {
const nickname = "数字天堂DCloud" + Math.round(Math.random() * 10);
console.log('nickname',nickname)
await page.waitFor(300)
await page.callMethod("setNickname", nickname)
await page.waitFor(5000)
userInfo = await page.callMethod('userInfoTest')
console.log("update--nickname---2", userInfo.nickname)
expect(userInfo.nickname).toBe(nickname)
})
// it("screenshot", async () => {
// await program.screenshot({
// path: "static/screenshot/userinfo.png" // 默认项目根目录
// })
// await page.waitFor(500)
// })
// it("头像", async () => {
// const imgs = [
// "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-52b18b34-3a3e-4861-89a0-c362c7634787/5105c383-8d83-4f40-938e-7c32c5983f8d.png",
......@@ -46,11 +57,4 @@ describe('userinfo', () => {
// await elBox.waitFor(500)
// }
// })
// it("screenshot", async () => {
// await program.screenshot({
// path: "static/screenshot/userinfo.png" // 默认项目根目录
// })
// await page.waitFor(500)
// })
});
\ No newline at end of file
......@@ -87,10 +87,10 @@ const uniIdCo = uniCloud.importObject("uni-id-co")
this.hasPwd = res.isPasswordSet
},
methods: {
// 自动化测试专用
hasLoginTest(){
return store.hasLogin
},
// 自动化测试专用
userInfoTest() {
return store.userInfo
},
login() {
uni.navigateTo({
url: '/uni_modules/uni-id-pages/pages/login/login-withoutpwd',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册