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

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

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