提交 1016a3ac 编写于 作者: study夏羽's avatar study夏羽

jest测试

上级 5425d365
......@@ -39,9 +39,9 @@
/*
验证码类型,用于防止不同功能的验证码混用,目前支持的类型login登录、register注册、bind绑定手机、unbind解绑手机
*/
codeType:{
codeType: {
type: String,
default(){
default () {
return 'login'
}
}
......@@ -52,14 +52,15 @@
reverseTimer: null
};
},
computed: {
computed: {
innerText() {
if (this.reverseNumber == 0) return this.$t('common').getVerifyCode;
return this.$t('smsCode.resendVerifyCode ')+ '('+this.reverseNumber+'s)';
return this.$t('smsCode.resendVerifyCode') + '(' + this.reverseNumber + 's)';
}
},
created() {
this.initClick();
// console.log(this.$t('smsCode.resendVerifyCode'));
},
methods: {
initClick() {
......@@ -68,63 +69,92 @@
this.sendMsg();
})
},
sendMsg() {
async sendMsg() {
let reg_phone = /^1\d{10}$/;
if(!reg_phone.test(this.phone))return uni.showToast({
if (!reg_phone.test(this.phone)) return uni.showToast({
title: this.$t('smsCode.phoneErrTip'),
icon: 'none'
});
uniCloud.callFunction({
name:'uni-id-cf',
data:{
action:'sendSmsCode',
params:{
return await uniCloud.callFunction({
name: 'uni-id-cf',
data: {
action: 'sendSmsCode',
params: {
"mobile": this.phone,
"type": this.codeType
},
},
success: ({result}) => {
console.log(result);
if(result.code===0){
uni.showToast({
title: this.$t('smsCode.sendSuccessTip'),
icon: 'none'
});
this.reverseNumber = Number(this.count);
this.getCode();
this.$emit('getCode');
}else{
uni.showModal({
content: result.msg,
showCancel: false
});
}
}).then(({result})=>{
console.log(result);
if (result.code === 0) {
uni.showToast({
title: this.$t('smsCode.sendSuccessTip'),
icon: 'none'
});
this.reverseNumber = Number(this.count);
this.getCode();
this.$emit('getCode');
} else {
uni.showModal({
content: result.msg,
showCancel: false
});
}
return result
})
},
getCode() {
if (this.reverseNumber == 0) {
clearTimeout(this.reverseTimer);
this.reverseTimer = null;
return;
}
this.reverseNumber--;
this.reverseTimer = setTimeout(() => {
this.getCode();
}, 1000)
// uniCloud.callFunction({
// name:'uni-id-cf',
// data:{
// action:'sendSmsCode',
// params:{
// "mobile": this.phone,
// "type": this.codeType
// },
// },
// success: ({result}) => {
// console.log(result);
// if(result.code===0){
// uni.showToast({
// title: this.$t('smsCode.sendSuccessTip'),
// icon: 'none'
// });
// this.reverseNumber = Number(this.count);
// this.getCode();
// this.$emit('getCode');
// }else{
// uni.showModal({
// content: result.msg,
// showCancel: false
// });
// }
// }
// })
},
getCode() {
if (this.reverseNumber == 0) {
clearTimeout(this.reverseTimer);
this.reverseTimer = null;
return;
}
this.reverseNumber--;
this.reverseTimer = setTimeout(() => {
this.getCode();
}, 1000)
}
}
}
</script>
<style lang="scss" scoped>
/* #ifndef APP-NVUE */
view{
display: flex;
box-sizing: border-box;
flex-direction: column;
}
/* #endif */
/* #ifndef APP-NVUE */
view {
display: flex;
box-sizing: border-box;
flex-direction: column;
}
/* #endif */
.short-code-btn {
width: 200rpx;
height: 85rpx;
......@@ -134,11 +164,13 @@ view{
justify-content: center;
align-items: center;
}
.inner-text {
font-size: 28rpx;
color: #AAAAAA;
}
.inner-text-active {
color: #007aff;
}
</style>
</style>
module.exports = {
"compile": true,
"h5": {
"options": {
"headless": false
},
"executablePath": "C:/Program Files/Google/Chrome/Application/chrome.exe"
},
"mp-weixin": {
"port": 9420,
"account": "",
"args": "",
"cwd": "",
"launch": true,
"teardown": "disconnect",
"remote": false,
"executablePath": "C:/Users/liuxi/download/微信web开发者工具/cli.bat"
},
"app-plus": {
"android": {
"id": "",
"executablePath": "D:/HX/alpha-3.1.3/HBuilderX/plugins/launcher/base/android_base.apk"
},
"version": "",
"ios": {
"id": "",
"executablePath": ""
}
}
}
const path = require('path');
module.exports = {
testTimeout: 10000,
reporters: [
'default'
],
watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
moduleFileExtensions: ['js', 'json'],
rootDir: __dirname,
testMatch: ["<rootDir>/pages/**/*test.[jt]s?(x)"],
// testMatch: ["<rootDir>/pages/ucenter/login-page/pwd-retrieve/pwd-retrieve.test.js"],
testPathIgnorePatterns: ['/node_modules/'],
testSequencer:path.join(__dirname, "testSequencer.js")
//pages/ucenter/userinfo/userinfo.test.js
//pages/ucenter/login-page/pwd-login/pwd-login.test.js
}
{
"name": "统一应用基本项目",
"appid": "请点击重新获取",
"description": "云端一体应用快速开发模版",
"versionName": "1.0.0",
"versionCode": "100",
"transformPx": false,
"app-plus": {
"locales": {
"en": {
"name" : "统一应用基本项目",
"appid" : "__UNI__D53040B",
"description" : "云端一体应用快速开发模版",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
"app-plus" : {
"locales" : {
"en" : {
// 英文
"name": "uni-starter", // 应用名称
"android": {
"strings": {
"name" : "uni-starter", // 应用名称
"android" : {
"strings" : {
//Android平台自定义字符串
"CustomKey": "CustomValue"
}
},
"ios": {
"privacyDescription": {
"CustomKey" : "CustomValue"
}
},
"ios" : {
"privacyDescription" : {
//iOS平台隐私访问描述信息
"NSPhotoLibraryUsageDescription": "access to the user’s photo library(read)"
},
"infoPlist": {
"NSPhotoLibraryUsageDescription" : "access to the user’s photo library(read)"
},
"infoPlist" : {
//iOS平台自定义InfoPlist.strings
"CustomKey": "CustomValue"
}
}
},
"zh": {
"CustomKey" : "CustomValue"
}
}
},
"zh" : {
// 中文(简体)
"name": "统一应用基本项目" // 应用名称
}
},
"privacy": {
"prompt": "template",
"template": {
"title": "服务协议和隐私政策",
"message": "  请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。<br/>  你可阅读<a href=\"https://ask.dcloud.net.cn/protocol.html\">《服务协议》</a>和<a href=\"https://ask.dcloud.net.cn/protocol.html\">《隐私政策》</a>了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。",
"buttonAccept": "同意",
"buttonRefuse": "暂不同意"
}
},
"compatible": {
"ignoreVersion": true
},
"usingComponents": true,
"nvueStyleCompiler": "uni-app",
"compilerVersion": 3,
"splashscreen": {
"alwaysShowBeforeRender": false,
"waiting": true,
"autoclose": true,
"delay": 0
},
"modules": {
"Fingerprint": {
},
"Share": {
},
"OAuth": {
},
"FaceID": {
},
"Push": {
},
"Geolocation": {
}
},
"distribute": {
"android": {
"permissions": [
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.USE_FINGERPRINT\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
],
"abiFilters": [
"armeabi-v7a",
"arm64-v8a",
"x86"
]
},
"ios": {
"capabilities": {
"entitlements": {
"com.apple.developer.associated-domains": [
"applinks:static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com"
]
}
}
},
"sdkConfigs": {
"oauth": {
"apple": {
},
"weixin": {
"appid": "",
"appsecret": "",
"UniversalLinks": ""
},
"univerify": {
}
"name" : "统一应用基本项目" // 应用名称
}
},
"ad": {
"privacy" : {
"prompt" : "template",
"template" : {
"title" : "服务协议和隐私政策",
"message" : "  请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。<br/>  你可阅读<a href=\"https://ask.dcloud.net.cn/protocol.html\">《服务协议》</a>和<a href=\"https://ask.dcloud.net.cn/protocol.html\">《隐私政策》</a>了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。",
"buttonAccept" : "同意",
"buttonRefuse" : "暂不同意"
}
},
"share": {
"weixin": {
"appid": "",
"UniversalLinks": ""
}
"compatible" : {
"ignoreVersion" : true
},
"geolocation": {
"baidu": {
"__platform__": [
"ios",
"android"
],
"appkey_ios": "请填写地图的key",
"appkey_android": "请填写地图的key"
}
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : false,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
"push": {
"unipush": {
}
"modules" : {
"Fingerprint" : {},
"OAuth" : {},
"FaceID" : {},
"Push" : {},
"Geolocation" : {}
},
"payment": {
}
},
"icons": {
"android": {
"hdpi": "",
"xhdpi": "",
"xxhdpi": "",
"xxxhdpi": ""
"distribute" : {
"android" : {
"permissions" : [
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.USE_FINGERPRINT\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
],
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ]
},
"ios" : {
"capabilities" : {
"entitlements" : {
"com.apple.developer.associated-domains" : [ "applinks:static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com" ]
}
}
},
"sdkConfigs" : {
"oauth" : {
"apple" : {},
"univerify" : {}
},
"ad" : {},
"share" : {
"weixin" : {
"appid" : "",
"UniversalLinks" : ""
}
},
"geolocation" : {
"baidu" : {
"__platform__" : [ "ios", "android" ],
"appkey_ios" : "请填写地图的key",
"appkey_android" : "请填写地图的key"
}
},
"push" : {
"unipush" : {}
},
"payment" : {}
},
"icons" : {
"android" : {
"hdpi" : "",
"xhdpi" : "",
"xxhdpi" : "",
"xxxhdpi" : ""
},
"ios" : {
"appstore" : "",
"ipad" : {
"app" : "",
"app@2x" : "",
"notification" : "",
"notification@2x" : "",
"proapp@2x" : "",
"settings" : "",
"settings@2x" : "",
"spotlight" : "",
"spotlight@2x" : ""
},
"iphone" : {
"app@2x" : "",
"app@3x" : "",
"notification@2x" : "",
"notification@3x" : "",
"settings@2x" : "",
"settings@3x" : "",
"spotlight@2x" : "",
"spotlight@3x" : ""
}
}
},
"splashscreen" : {
"iosStyle" : "common",
"androidStyle" : "common"
}
},
"nvueLaunchMode" : ""
},
"quickapp" : {},
"mp-weixin" : {
"appid" : "",
"setting" : {
"urlCheck" : false,
"es6" : false
},
"ios": {
"appstore": "",
"ipad": {
"app": "",
"app@2x": "",
"notification": "",
"notification@2x": "",
"proapp@2x": "",
"settings": "",
"settings@2x": "",
"spotlight": "",
"spotlight@2x": ""
},
"iphone": {
"app@2x": "",
"app@3x": "",
"notification@2x": "",
"notification@3x": "",
"settings@2x": "",
"settings@3x": "",
"spotlight@2x": "",
"spotlight@3x": ""
}
"usingComponents" : true,
"betterScopedSlots" : true,
"permission" : {
"scope.userLocation" : {
"desc" : "演示在onShow生命周期获取地理位置"
}
}
},
"splashscreen": {
"iosStyle": "common",
"androidStyle": "common"
}
},
"nvueLaunchMode": ""
},
"quickapp": {
},
"mp-weixin": {
"appid": "",
"setting": {
"urlCheck": false,
"es6": false
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"usingComponents": true,
"betterScopedSlots": true,
"permission": {
"scope.userLocation": {
"desc": "演示在onShow生命周期获取地理位置"
}
}
},
"mp-alipay": {
"usingComponents": true
},
"mp-baidu": {
"usingComponents": true
},
"mp-toutiao": {
"usingComponents": true
},
"uniStatistics": {
"enable": false
},
"h5": {
"template": "",
"sdkConfigs": {
"maps": {
"qqmap": {
"key": ""
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"h5" : {
"template" : "",
"sdkConfigs" : {
"maps" : {
"qqmap" : {
"key" : ""
}
}
}
}
}
},
"_spaceID": "",
"vueVersion": "2"
},
"_spaceID" : "",
"vueVersion" : "2"
}
//...
// 中文(简体)
// 应用名称
......@@ -4,12 +4,12 @@
"version": "1.1.9",
"description": "云端一体应用快速开发基本项目模版",
"keywords": [
"login",
"登录",
"搜索",
"uni-id例子",
"留言板"
],
"login",
"登录",
"搜索",
"uni-id例子",
"留言板"
],
"repository": "https://codechina.csdn.net/dcloud/uni-starter.git",
"engines": {
"HBuilderX": "^3.1.20"
......@@ -81,5 +81,7 @@
}
}
},
"dependencies": {}
"dependencies": {
"@jest/test-sequencer": "^27.0.6"
}
}
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
describe('pages/grid/grid.vue', () => {
let page
beforeAll(async () => {
page = await program.switchTab('/pages/grid/grid')
await page.waitFor(500)
})
it('检测宫格', async () => {
// expect.assertions(1);
// const perPage = await page.$('.warp')
// const getData = await perPage.data('gridList')
// console.log("getData: ",getData);
// expect(getData.length).toBe(9)
expect.assertions(1);
const getData = await page.data('gridList')
console.log("getData: ",getData);
expect(getData.length).toBe(9)
})
it('点击宫格', async () => {
// expect.assertions(1);
const perPage = await page.$('.warp')
const uGrid = await perPage.$('.uni-grid-box')
console.log("uGrid-----------: ",uGrid);
// await uGrid.callMethod('change')
// const tapRes = await uGrid.tap()
// const tapRes = await uGrid.callMethod('change')
// await page.waitFor(300)
// console.log("tapRes: ",tapRes);
})
});
\ No newline at end of file
......@@ -25,7 +25,7 @@
<!-- 宫格 -->
<uni-section :title="$t('grid.grid')" style="margin: 0;" type="line"></uni-section>
<view class="example-body">
<uni-grid :column="3" :highlight="true" @change="change">
<uni-grid class="uni-grid-box" :column="3" :highlight="true" @change="change">
<template v-for="(item,i) in gridList">
<uni-grid-item :index="i" :key="i"
v-if="i<3 || i>2&&i<6&&hasLogin || i>5&&uniIDHasRole('admin')"
......@@ -62,7 +62,8 @@
hasLogin: 'user/hasLogin'
})
},
onLoad() {
onLoad() {
console.log(uni.getStorageSync('uni_id_token'),"00000000000000000000");
let gridList = []
for (var i = 0; i < 3; i++) {
gridList.push( this.$t('grid.visibleToAll') )
......@@ -77,6 +78,7 @@
},
methods: {
change(e) {
// console.log("e: ",e);
uni.showToast({
title:this.$t('grid.clickTip') + " " + `${e.detail.index}` + " " + this.$t('grid.clickTipGrid'),
icon: 'none'
......
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
describe('pages/list/detail.vue', () => {
let page
beforeAll(async () => {
page = await program.navigateTo('/pages/list/detail?id=614343e09ee65f000158ac93&title=阿里小程序IDE官方内嵌uni-app,为开发者提供多端开发服务')
await page.waitFor(500)
})
it('检测内容', async () => {
expect.assertions(1);
const page = await program.currentPage()
await program.pageScrollTo(100)
console.log(await page.scrollTop(),"scrollTop")
expect(await page.scrollTop()).toBe(100)
})
});
......@@ -10,7 +10,8 @@
<unicloud-db ref='udb' v-slot:default="{data,pagination,hasMore, loading, error, options}" @error="onqueryerror"
:where="where" collection="opendb-news-articles,uni-id-users" :page-size="10"
field="avatar,title,last_modify_date,user_id.username">
field="avatar,title,last_modify_date,user_id.username" @load="loadData"
>
<!-- 基于 uni-list 的页面布局 -->
<uni-list class="uni-list" :border="false" :bounce="true" :alwaysScrollableVertical="true"
:style="{height:listHight}">
......@@ -68,7 +69,8 @@
where: "",
keyword: "",
refreshState: 0,
listHight: 0
listHight: 0,
dataList:[]
}
},
watch: {
......@@ -88,9 +90,10 @@
// #ifndef APP-NVUE
this.listHight = 'auto'
// #endif
cdbRef = this.$refs.udb
cdbRef = this.$refs.udb
},
async onShow() {
async onShow() {
this.keyword = getApp().globalData.searchText
getApp().globalData.searchText = ''
//这里仅演示如何,在onShow生命周期获取设备位置,并在设备或者应用没有权限时自动引导。设置完毕自动重新获取。
......@@ -99,10 +102,8 @@
// title:"获取定位中"
// });
//默认h5端不获取定位
// #ifndef H5
let location = await gps.getLocation({geocode:true})
console.log(location);
// #endif
// let location = await gps.getLocation({geocode:true})
// console.log(location);
// if(location){
// uni.showToast({
// title: JSON.stringify(location),
......@@ -112,6 +113,11 @@
// uni.hideLoading()
},
methods: {
loadData(e){
console.log("e: ----",e[0]);
this.dataList = e[0]
console.log("this.dataList: ",this.dataList);
},
searchClick(e) { //点击搜索框
uni.hideKeyboard();
uni.navigateTo({
......
describe('pages/list/list.vue', () => {
let page
beforeAll(async () => {
page = await program.switchTab('/pages/list/list')
await page.waitFor(500)
})
it('检测标题', async () => {
// expect.assertions(2);
// const perPage = await page.$('.pages')
// await page.waitFor(500)
// const getData = await perPage.data('dataList')
// console.log("getData: ",getData);
// expect(getData.title).toBe('阿里小程序IDE官方内嵌uni-app,为开发者提供多端开发服务')
// expect(getData.length).toBe(1)
const getData = await page.data('dataList')
console.log("getData: ",getData);
})
it('点击搜索跳转', async () => {
expect.assertions(2);
const searchTo = await page.callMethod('searchClick')
await page.waitFor(300)
expect((await program.currentPage()).path).toBe('pages/list/search/search')
await page.waitFor(500)
expect((await program.navigateBack()).path).toBe('pages/list/list')
})
})
\ No newline at end of file
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
describe('pages/list/search/search.vue', () => {
let page
beforeAll(async () => {
page = await program.navigateTo('/pages/list/search/search')
await page.waitFor(500)
})
it('搜索发现-显示-影藏', async () => {
expect.assertions(2);
await page.callMethod('searchHotRefresh')
await page.waitFor(300)
const getShow = await page.data('netHotListIsHide')
expect(getShow).toBeFalsy()
if(!getShow){
await page.setData({netHotListIsHide: true})
expect(await page.data('netHotListIsHide')).toBeTruthy()
}
})
it('搜索内容', async () => {
expect.assertions(1);
const setSearchTest = await page.setData({
searchText: '小程序',
})
// console.log(await page.data('searchText'));
await page.callMethod('search', '小程序')
await page.waitFor(300)
expect((await program.currentPage()).path).toBe('pages/list/list')
// 执行 navigateBack 验证是否返回
// expect((await program.navigateBack()).path).toBe('pages/list/search/search')
})
});
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
describe('pages/ucenter/about/about.vue', () => {
let page
beforeAll(async () => {
page = await program.navigateTo('/pages/ucenter/about/about')
await page.waitFor(500)
})
it('检测标题', async () => {
// expect.assertions(1);
// const perPage = await page.$('.about')
// await page.waitFor(500)
const getData = await page.data('about')
console.log("getData-----------: ", getData);
// expect(getData.appName).toBe('uni-starter')
// expect(getData.slogan).toBe('云端一体应用快速开发模版')
})
it('隐私政策协议-点击跳转', async () => {
// expect.assertions(1);
const elAgree = await page.$('.agreement')
// console.log("elAgree: ", elAgree);
await page.callMethod('navigateTo', {
url: "https://ask.dcloud.net.cn/protocol.html",
title: "用户服务条款"
})
})
});
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
describe('pages/ucenter/login-page/index/index.vue', () => {
let page
beforeAll(async () => {
page = await program.navigateTo('/pages/ucenter/login-page/index/index?type=smsCode')
await page.waitFor(500)
})
it('检查', async () => {
console.log(await program.currentPage());
const perPage = await page.$('.content')
const getTitle = await perPage.$('.title')
console.log(await getTitle.text());
// if ((await program.currentPage()).path == 'pages/ucenter/login-page/index/index') {
// expect(await getTitle.text()).toBe('登录后即可展示自己')
// }
})
it('手机号', async () => {
const setInput = await page.setData({
"phone": '17769516019',
"agree": true,
})
await page.waitFor(300)
console.log(await page.data('phone'), "phone----------");
console.log(await page.data('agree'), "agree-----------");
const agreeTrue = await page.waitFor(async () => {
return await page.data('agree')
})
console.log("agreeTrue: ", agreeTrue);
await page.callMethod('sendShortMsg')
await page.waitFor(300)
console.log(await program.currentPage());
// except((await program.currentPage()).path).toBe('pages/ucenter/login-page/phone-code/phone-code?phoneNumber=17769516019')
// if (process.env.UNI_PLATFORM === "h5") {
// const elInput = await page.$('.input-box')
// console.log("elInput: ",elInput);
// console.log(await elInput.attribute('src'));
// }
})
})
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
describe('pages/ucenter/login-page/phone-code/phone-code.vue', () => {
let page
beforeAll(async () => {
page = await program.navigateTo('/pages/ucenter/login-page/phone-code/phone-code')
await page.waitFor(500)
})
// ?phoneNumber=17769516019
it('获取短信验证码', async () => {
const initClickRes = await page.callMethod('initClick')
console.log("initClickRes: ",initClickRes);
console.log(await page.data('count'));
await page.waitFor(500)
await page.setData({
"code":"123456"
})
expect(await page.data('code').length).toBe(6)
const submitRes = await page.callMethod('submit')
console.log("submitRes: ",submitRes);
// expect(submitRes.msg).toBe('注册成功')
console.log(await program.currentPage());
// 登录成功后,/pages/ucenter/settings/settings
})
})
......@@ -42,27 +42,49 @@
// this.$refs.sendSmsCode.start();
},
methods: {
submit(){ //完成并提交
uniCloud.callFunction({
name:'uni-id-cf',
data:{
action:'loginBySms',
params:{
async submit(){ //完成并提交
return await uniCloud.callFunction({
name:'uni-id-cf',
data:{
action:'loginBySms',
params:{
"mobile":this.phone,
"code":this.code
},
},
success: ({result}) => {
if(result.code === 0){
this.loginSuccess(result)
}else{
uni.showModal({
content: result.msg,
showCancel: false
});
}
}
})
"code":this.code
},
}
}).then(({result})=>{
if(result.code === 0){
this.loginSuccess(result)
}else{
uni.showModal({
content: result.msg,
showCancel: false
});
}
return result
})
// uniCloud.callFunction({
// name:'uni-id-cf',
// data:{
// action:'loginBySms',
// params:{
// "mobile":this.phone,
// "code":this.code
// },
// },
// success: ({result}) => {
// if(result.code === 0){
// this.loginSuccess(result)
// }else{
// uni.showModal({
// content: result.msg,
// showCancel: false
// });
// }
// }
// })
}
}
}
......
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
describe('pages/ucenter/login-page/pwd-login/pwd-login.vue', () => {
let page
beforeAll(async () => {
page = await program.redirectTo('/pages/ucenter/login-page/pwd-login/pwd-login')
await page.waitFor(500)
})
it('前往注册页', async () => {
// expect.assertions(2);
const resReg = await page.callMethod('toRegister')
await page.waitFor(300)
expect((await program.currentPage()).path).toBe(
'pages/ucenter/login-page/register/register')
await page.waitFor(500)
// 执行 navigateBack 验证是否返回
expect((await program.navigateBack()).path).toBe(
'pages/ucenter/login-page/pwd-login/pwd-login')
})
it('跳转到忘记密码页', async () => {
const resPwd = await page.callMethod('toRetrievePwd')
await page.waitFor(300)
expect((await program.currentPage()).path).toBe(
'pages/ucenter/login-page/pwd-retrieve/pwd-retrieve')
await page.waitFor(500)
// 执行 navigateBack 验证是否返回
expect((await program.navigateBack()).path).toBe(
'pages/ucenter/login-page/pwd-login/pwd-login')
})
it('用户名密码登录', async () => {
// expect.assertions(1);
const setForm = await page.setData({
"password": "111111",
"username": "数字天堂",
"agree": true,
})
const resLogin = await page.callMethod('pwdLogin')
console.log("resLogin: ", resLogin.msg);
expect(resLogin.msg).toBe("登录成功");
})
})
......@@ -51,50 +51,86 @@
url: '../pwd-retrieve/pwd-retrieve?phoneNumber=' + (this.isPhone ? this.username : '') +
'&phoneArea=' + this.currenPhoneArea
})
// uni.redirectTo({
// url: '../pwd-retrieve/pwd-retrieve?phoneNumber=' + (this.isPhone ? this.username : '') +
// '&phoneArea=' + this.currenPhoneArea
// })
},
/**
* 密码登录
*/
pwdLogin() {
async pwdLogin() {
if (!this.agree) {
return uni.showToast({
title: this.$t('common').noAgree,
icon: 'none'
});
}
return await uniCloud.callFunction({
name:'uni-id-cf',
data:{
action:'login',
params:{
"username": this.username,
"password": this.password,
"captcha":this.captcha
},
},
}).then(({result}) => {
console.log(result);
if (result.code === 0) {
this.loginSuccess(result)
} else {
if (result.needCaptcha) {
uni.showToast({
title: result.msg,
icon: 'none'
});
this.createCaptcha()
}else{
uni.showModal({
title: this.$t('common').error,
content: result.msg,
showCancel: false,
confirmText: this.$t('common').gotIt
});
}
}
return result
})
// 下边是可以登录
uniCloud.callFunction({
name:'uni-id-cf',
data:{
action:'login',
params:{
"username": this.username,
"password": this.password,
"captcha":this.captcha
},
},
success: ({result}) => {
console.log(result);
if (result.code === 0) {
this.loginSuccess(result)
} else {
if (result.needCaptcha) {
uni.showToast({
title: result.msg,
icon: 'none'
});
this.createCaptcha()
}else{
uni.showModal({
title: this.$t('common').error,
content: result.msg,
showCancel: false,
confirmText: this.$t('common').gotIt
});
}
}
}
})
// uniCloud.callFunction({
// name:'uni-id-cf',
// data:{
// action:'login',
// params:{
// "username": this.username,
// "password": this.password,
// "captcha":this.captcha
// },
// },
// success: ({result}) => {
// console.log(result);
// if (result.code === 0) {
// this.loginSuccess(result)
// } else {
// if (result.needCaptcha) {
// uni.showToast({
// title: result.msg,
// icon: 'none'
// });
// this.createCaptcha()
// }else{
// uni.showModal({
// title: this.$t('common').error,
// content: result.msg,
// showCancel: false,
// confirmText: this.$t('common').gotIt
// });
// }
// }
// }
// })
},
createCaptcha(){
uniCloud.callFunction({
......@@ -123,6 +159,9 @@
uni.navigateTo({
url: '/pages/ucenter/login-page/register/register'
})
// uni.redirectTo({
// url: '/pages/ucenter/login-page/register/register'
// })
}
}
}
......
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
describe('pages/ucenter/login-page/pwd-retrieve/pwd-retrieve.vue', () => {
let page
beforeAll(async () => {
page = await program.navigateTo('/pages/ucenter/login-page/pwd-retrieve/pwd-retrieve?phoneNumber=17769516019')
await page.waitFor(500)
})
it('重置密码', async () => {
await page.setData({
formData: {
"phone": "17769516019",
'pwd': '222222',
'pwd2': '222222',
'code':'123456'
}
})
if (process.env.UNI_PLATFORM === "h5") {
const submitRes = await page.callMethod('submit')
console.log("submitRes: ",submitRes);
// expect(submitRes.msg).toBe('密码重置成功')
await page.waitFor(500)
}
console.log(await program.currentPage());
// expect((await program.currentPage()).path).toBe('/pages/ucenter/settings/settings')
})
})
......@@ -137,30 +137,52 @@
/**
* 完成并提交
*/
submit() {
submit() {
this.$refs.form.validate()
.then(res => {
uniCloud.callFunction({
name:'uni-id-cf',
data:{
action:'resetPwdBySmsCode',
params:{
"mobile": this.formData.phone,
"code": this.formData.code,
"password": this.formData.pwd
},
},
success: ({result}) => {
console.log(result);
uni.showToast({
title: result.msg,
icon: 'none'
});
if (result.code === 0) {
uni.navigateBack()
}
}
.then( async res => {
return await uniCloud.callFunction({
name:'uni-id-cf',
data:{
action:'resetPwdBySmsCode',
params:{
"mobile": this.formData.phone,
"code": this.formData.code,
"password": this.formData.pwd
},
}
}).then(({result})=>{
console.log(result);
// uni.showToast({
// title: result.msg,
// icon: 'none'
// });
if (result.code === 0) {
uni.navigateBack()
}
return result
})
// uniCloud.callFunction({
// name:'uni-id-cf',
// data:{
// action:'resetPwdBySmsCode',
// params:{
// "mobile": this.formData.phone,
// "code": this.formData.code,
// "password": this.formData.pwd
// },
// },
// success: ({result}) => {
// console.log(result);
// uni.showToast({
// title: result.msg,
// icon: 'none'
// });
// if (result.code === 0) {
// uni.navigateBack()
// }
// }
// })
})
}
}
......
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
describe('pages/ucenter/login-page/register/register.vue', () => {
let page
beforeAll(async () => {
page = await program.redirectTo('/pages/ucenter/login-page/register/register')
await page.waitFor(500)
})
it('注册账号', async () => {
let username = "数字天堂"
let nickname = "DCloud"
let password = "111111"
let pwd2 = "111111"
const setInput = await page.setData({
formData: {
"username": username,
"nickname": nickname,
'password': password,
'pwd2': pwd2
},
})
// console.log(await page.data('formData'),"0000000000000");
expect(username).toMatch(/^.{3,20}$/);
expect(password).toMatch(/^.{6,20}$/);
expect(pwd2).toMatch(/^.{6,20}$/);
expect(pwd2).toEqual(password);
await page.setData({
agree: true
})
const getUid = await page.waitFor(async () => {
const resRegister = await page.callMethod('submit')
await page.waitFor(300)
return resRegister
})
console.log("getUid:---------- ",getUid.msg);
if (getUid.uid) {
expect(getUid.msg).toBe("注册成功");
expect(getUid.userInfo.username).toBe("数字天堂");
await program.navigateTo('/pages/ucenter/settings/settings')
} else {
expect(getUid.msg).toBe("此用户名已注册");
await program.navigateTo('/pages/ucenter/login-page/pwd-login/pwd-login')
}
})
})
......@@ -58,34 +58,56 @@ import mixin from '../common/login-page.mixin.js';
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
this.submitForm(res)
return this.$refs.form.validate().then(async(res) => {
console.log("res: ",res);
let msg = await this.submitForm(res)
console.log("msg: --------------",msg);
return msg
}).catch((errors) => {
console.log(errors);
return errors
})
.finally(() => {
uni.hideLoading()
})
},
submitForm(params) {
uniCloud.callFunction({
name:'uni-id-cf',
data:{
action:'register',
params,
},
success: ({result}) => {
console.log(result);
if(result.code === 0){
this.loginSuccess(result)
}else{
uni.showModal({
content: result.msg,
showCancel: false
});
}
}
async submitForm(params) {
return await uniCloud.callFunction({
name:'uni-id-cf',
data:{
action:'register',
params,
},
}).then(({result}) => {
if(result.code === 0){
this.loginSuccess(result)
}else{
uni.showModal({
content: result.msg,
showCancel: false
});
}
console.log(result);
return result
})
// uniCloud.callFunction({
// name:'uni-id-cf',
// data:{
// action:'register',
// params,
// },
// success: ({result}) => {
// console.log(result);
// if(result.code === 0){
// this.loginSuccess(result)
// }else{
// uni.showModal({
// content: result.msg,
// showCancel: false
// });
// }
// }
// })
}
}
}
......
// uniapp自动化测试教程: https://uniapp-test.dcloud.net.cn/docs/testcase/start
// import {mapGetters} from 'vuex';
describe('pages/ucenter/settings/settings', () => {
let page
beforeAll(async () => {
page = await program.navigateTo('/pages/ucenter/settings/settings')
await page.waitFor(500)
})
it('退出登录', async () => {
const perPage = await page.$('.content')
const uList = await perPage.$('.userInfo-class')
await page.waitFor(300)
const getTokenRes = await page.waitFor(async()=>{
return await page.data('uniToken')
})
console.log("getTokenRes: ",getTokenRes);
await page.callMethod('clickLogout')
console.log((await program.currentPage()).path);
})
});
\ No newline at end of file
......@@ -2,7 +2,7 @@
<view class="content">
<!-- 功能列表 -->
<uni-list class="mt10" :border="false">
<uni-list-item :title="$t('settings.userInfo')" to="/pages/ucenter/userinfo/userinfo" link="navigateTo"></uni-list-item>
<uni-list-item class="userInfo-class" :title="$t('settings.userInfo')" to="/pages/ucenter/userinfo/userinfo" link="navigateTo"></uni-list-item>
<uni-list-item v-if="userInfo.mobile" :title="$t('settings.changePassword')" :to="'/pages/ucenter/login-page/pwd-retrieve/pwd-retrieve?phoneNumber='+ userInfo.mobile" link="navigateTo"></uni-list-item>
</uni-list>
<uni-list class="mt10" :border="false">
......@@ -42,7 +42,8 @@
pushServer:pushServer,
supportMode:[],
pushIsOn:"wait",
currentLanguage:""
currentLanguage:"",
uniToken:""
}
},
computed: {
......@@ -52,6 +53,8 @@
})
},
onLoad() {
this.uniToken = uni.getStorageSync('uni_id_token')
console.log("uniToken: ",this.uniToken);
this.currentLanguage = uni.getStorageSync('CURRENT_LANG') == "en"?'English':'简体中文'
uni.setNavigationBarTitle({
......@@ -177,21 +180,24 @@
})
},
clickLogout() {
console.log("this.hasLogin:---------------- ",this.hasLogin);
if (this.hasLogin) {
uni.showModal({
title: this.$t('settings.tips'),
content: this.$t('settings.exitLogin'),
cancelText: this.$t('settings.cancelText'),
confirmText: this.$t('settings.confirmText'),
success: res => {
if (res.confirm) {
this.logout();
uni.navigateBack();
}
},
fail: () => {},
complete: () => {}
});
this.logout();
uni.navigateBack();
// uni.showModal({
// title: this.$t('settings.tips'),
// content: this.$t('settings.exitLogin'),
// cancelText: this.$t('settings.cancelText'),
// confirmText: this.$t('settings.confirmText'),
// success: res => {
// if (res.confirm) {
// this.logout();
// uni.navigateBack();
// }
// },
// fail: () => {},
// complete: () => {}
// });
} else {
uni.navigateTo({
url: '/pages/ucenter/login-page/index/index'
......
describe('pages/ucenter/ucenter.vue', () => {
let page
beforeAll(async () => {
page = await program.switchTab('/pages/ucenter/ucenter')
await page.waitFor(300)
})
it('宫格', async () => {
const getGrid = await page.data('gridList')
// console.log("getGrid: ",getGrid);
expect(getGrid.length).toBe(4)
})
it('列表', async () => {
const getUcenterList = await page.data('ucenterList')
// console.log("getUcenterList: ",getUcenterList);
expect(getUcenterList.length).toBe(3)
})
it('我的积分', async () => {
// expect.assertions(1);
const getScoreRes = await page.callMethod('getScore')
console.log("getScoreRes: ", getScoreRes);
await page.waitFor(500)
// expect(getScoreRes.score).not.toBeUndefined();
})
})
......@@ -38,7 +38,7 @@
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-check-version';
import uniShare from '@/uni_modules/uni-share/js_sdk/uni-share.js';
// import pwdLogin from '../../common/toLogin.js';
const db = uniCloud.database();
export default {
data() {
......@@ -120,10 +120,14 @@
"style": "solid", // 边框样式
"radius": "100%" // 边框圆角,支持百分比
}
}
},
uniToken:""
}
},
onLoad() {
async onLoad() {
// const loginRes = await pwdLogin()
// console.log(loginRes,'-------------');
// this.uniToken = loginRes.token
// console.log(313,this.userInfo,this.hasLogin);
//#ifdef APP-PLUS
this.ucenterList[this.ucenterList.length - 2].unshift({
......@@ -133,7 +137,9 @@
icon: 'loop',
showBadge: this.appVersion.hasNew
})
//#endif
//#endif
this.uniToken = uni.getStorageSync('uni_id_token')
console.log("uniToken: ",this.uniToken);
},
computed: {
...mapGetters({
......@@ -218,7 +224,8 @@
/**
* 获取积分信息
*/
getScore() {
async getScore() {
console.log("this.userInfo:------------- ",this.userInfo);
if (!this.userInfo) return uni.showToast({
title: this.$t('mine.checkScore'),
icon: 'none'
......@@ -226,7 +233,7 @@
uni.showLoading({
mask: true
})
db.collection("uni-id-scores")
return await db.collection("uni-id-scores")
.where('"user_id" == $env.uid')
.field('score,balance')
.orderBy("create_date", "desc")
......@@ -240,9 +247,11 @@
uni.showToast({
title: msg,
icon: 'none'
});
}).finally(()=>{
uni.hideLoading()
});
return data
}).finally((e)=>{
uni.hideLoading()
return e
})
},
async share() {
......
// uniapp自动化测试教程: https://uniapp-test.dcloud.net.cn/docs/testcase/start
describe('pages/ucenter/userinfo/bind-mobile/bind-mobile.vue', () => {
let page
beforeAll( async ()=>{
page = await program.redirectTo('/pages/ucenter/userinfo/bind-mobile/bind-mobile')
await page.waitFor(500)
})
it('修改绑定手机号',async()=>{
let phone = "17769516019"
await page.setData({
formData: {
"phone":phone
}
})
// console.log(await page.data("formData"));
expect(phone).toMatch(/^1\d{10}$/);
if (process.env.UNI_PLATFORM === "mp-weixin") {
const codeBtnMp = await page.$('uni-send-sms-code')
const sendMsgResMp = await codeBtnMp.callMethod('sendMsg')
await page.waitFor(300)
}else{
const codebtn = await page.$('.short-code-btn')
const sendMsgRes = await codebtn.callMethod('sendMsg')
await page.waitFor(300)
}
let code = "123456"
await page.setData({formData: {code}})
expect(code).toMatch(/^\d{6}$/);
const submitRes = await page.callMethod('submit')
await page.waitFor(300)
console.log("submitRes: ",submitRes);
if(submitRes){
switch (submitRes.code){
case 0:
expect(submitRes.msg).toBe("手机号码绑定成功")
await page.waitFor(300)
console.log(await program.currentPage());
expect((await program.currentPage()).path).toBe('/pages/ucenter/userinfo/userinfo')
break;
case 403:
expect(submitRes.msg).toBe("缺少token")
await page.waitFor(300)
await program.redirectTo('/pages/ucenter/login-page/pwd-login/pwd-login')
break;
case 60101:
expect(submitRes.msg).toBe("此手机号已绑定")
break;
default:
break;
}
}
})
});
\ No newline at end of file
......@@ -3,13 +3,14 @@
<!-- 登录框 (选择手机号所属国家和地区需要另行实现) -->
<uni-easyinput clearable focus type="number" class="input-box" :inputBorder="false" v-model="formData.phone"
maxlength="11" :placeholder="$t('common.phonePlaceholder')"></uni-easyinput>
<uni-easyinput clearable type="number" class="input-box" :inputBorder="false" v-model="formData.code" maxlength="6"
:placeholder="$t('common.verifyCodePlaceholder')">
<uni-easyinput clearable type="number" class="input-box" :inputBorder="false" v-model="formData.code"
maxlength="6" :placeholder="$t('common.verifyCodePlaceholder')">
<template v-slot:right>
<uni-send-sms-code ref="shortCode" code-type="bind" :phone="formData.phone"></uni-send-sms-code>
</template>
</uni-easyinput>
<button class="send-btn-box" :disabled="!canSubmit" :type="canSubmit?'primary':'default'" @click="submit">{{$t('common.submit')}}</button>
<button class="send-btn-box" :disabled="!canSubmit" :type="canSubmit?'primary':'default'"
@click="submit">{{$t('common.submit')}}</button>
</view>
</template>
<script>
......@@ -22,26 +23,26 @@
return {
currenPhoneArea: '',
formData: {
phone:"",
code:""
phone: "",
code: ""
}
}
},
computed: {
computed: {
tipText() {
return this.$t('common.verifyCodeSend')+ `${this.currenPhoneArea} ${this.formData.phone}。` + this.$t('common.passwordDigits')
return this.$t('common.verifyCodeSend') + `${this.currenPhoneArea} ${this.formData.phone}。` + this.$t(
'common.passwordDigits')
},
canSubmit() {
return true//this.isPhone() && this.isCode();
return true //this.isPhone() && this.isCode();
}
},
onLoad(event) {
uni.setNavigationBarTitle({
title:this.$t('bindMobile.navigationBarTitle')
onLoad(event) {
uni.setNavigationBarTitle({
title: this.$t('bindMobile.navigationBarTitle')
})
},
onReady() {
},
onReady() {},
methods: {
...mapMutations({
setUserInfo: 'user/login'
......@@ -49,39 +50,60 @@
/**
* 完成并提交
*/
submit() {
async submit() {
console.log(this.formData);
uniCloud.callFunction({
return await uniCloud.callFunction({
name:'uni-id-cf',
data:{
action:'bindMobileBySms',
params:{
data: {
action: 'bindMobileBySms',
params: {
"mobile": this.formData.phone,
"code": this.formData.code
},
},
success: ({result}) => {
console.log(result);
this.setUserInfo({"mobile":result.mobile})
uni.showToast({
title: result.msg,
icon: 'none'
});
if (result.code === 0) {
uni.navigateBack()
}
}
}).then(({result})=>{
console.log(result);
this.setUserInfo({"mobile":result.mobile})
uni.showToast({
title: result.msg,
icon: 'none'
});
if (result.code === 0) {
uni.navigateBack()
}
return result
})
},
isPhone() {
let reg_phone = /^1\d{10}$/;
let isPhone = reg_phone.test(this.formData.phone);
return isPhone;
},
isCode() {
let reg_code = /^\d{6}$/;
let isCode = reg_code.test(this.formData.code);
return isCode;
// uniCloud.callFunction({
// name:'uni-id-cf',
// data:{
// action:'bindMobileBySms',
// params:{
// "mobile": this.formData.phone,
// "code": this.formData.code
// },
// },
// success: ({result}) => {
// console.log(result);
// this.setUserInfo({"mobile":result.mobile})
// uni.showToast({
// title: result.msg,
// icon: 'none'
// });
// if (result.code === 0) {
// uni.navigateBack()
// }
// }
// })
},
isPhone() {
let reg_phone = /^1\d{10}$/;
let isPhone = reg_phone.test(this.formData.phone);
return isPhone;
},
isCode() {
let reg_code = /^\d{6}$/;
let isCode = reg_code.test(this.formData.code);
return isCode;
}
}
}
......@@ -94,11 +116,13 @@
padding: 50rpx;
padding-top: 10px;
}
/* #ifndef APP-NVUE || VUE3 */
/* #ifndef APP-NVUE || VUE3 */
.box /deep/ .uni-easyinput__content {
height: 50px;
}
/* #endif */
/* #endif */
.input-box {
width: 100%;
margin-top: 16px;
......@@ -112,4 +136,4 @@
width: 650rpx;
margin-top: 15px;
}
</style>
</style>
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
describe('pages/ucenter/userinfo/userinfo.vue', () => {
let page
beforeAll(async () => {
page = await program.redirectTo('/pages/ucenter/userinfo/userinfo')
await page.waitFor(500)
})
it('设置昵称', async () => {
const getTokenRes = await page.waitFor(async()=>{
return await page.data('uniToken')
})
console.log("getTokenRes: ",getTokenRes);
// if(getTokenRes){
// const nicknameRes = await page.callMethod("setNickname","数字天堂DCloud")
// await page.waitFor(300)
// console.log("nicknameRes: ",nicknameRes);
// expect(nicknameRes.updated).toBe(1)
// }
})
it('绑定手机号', async () => {
await page.callMethod('bindMobileBySmsCode')
await page.waitFor(300)
console.log((await program.currentPage()).path);
expect((await program.currentPage()).path).toBe('pages/ucenter/userinfo/bind-mobile/bind-mobile')
await page.waitFor(300)
expect((await program.navigateBack()).path).toBe('pages/ucenter/userinfo/userinfo')
})
})
......@@ -39,10 +39,14 @@
otherLoginButton: {
"title": "其他号码绑定",
}
}
},
uniToken:''
}
},
onLoad() {
onLoad() {
this.uniToken = uni.getStorageSync('uni_id_token')
console.log("uniToken: ",this.uniToken);
this.univerifyStyle.authButton.title = this.$t('userinfo.bindPhoneNumber')
this.univerifyStyle.otherLoginButton.title = this.$t('userinfo.bindOtherLogin')
uni.setNavigationBarTitle({
......@@ -127,13 +131,13 @@
url: '/pages/ucenter/userinfo/bind-mobile/bind-mobile'
})
},
setNickname(nickname) {
async setNickname(nickname) {
console.log(nickname);
if (nickname) {
usersTable.where('_id==$env.uid').update({
return await usersTable.where('_id==$env.uid').update({
nickname
}).then(e => {
console.log(e);
console.log(e.result,"e.result---------");
if (e.result.updated) {
uni.showToast({
title:this.$t('common.updateSucceeded'),
......@@ -148,6 +152,7 @@
icon: 'none'
});
}
return e.result
})
this.$refs.dialog.close()
} else {
......
const Sequencer = require("@jest/test-sequencer").default;
const sortTestFilenames = ["register.test.js","pwd-login.test.js","userinfo.test.js"];
class CustomSequencer extends Sequencer {
sort(tests) {
// 测试例排序
const copyTests = Array.from(tests);
const sortTests = sortTestFilenames
.map((filename) => {
return copyTests.find((test) => test.path.endsWith(filename));
})
.filter(Boolean);
console.log(sortTests);
return [...new Set([...sortTests, ...copyTests])];
}
}
module.exports = CustomSequencer;
\ No newline at end of file
......@@ -28,28 +28,30 @@ export default {
2.visitor:白名单模式。枚举游客可访问的页面。
* 注意:黑名单与白名单模式二选一
*/
// "needLogin" : [
// {pattern:/^\/pages\/list.*/}, //支持正则表达式
// "/uni_modules/uni-news-favorite/pages/uni-news-favorite/list",
// "/uni_modules/uni-feedback/pages/uni-feedback/add"
// ],
"visitor" : [
"/",//注意入口页必须直接写 "/"
{"pattern":/^\/pages\/list.*/}, //支持正则表达式
{"pattern":/^\/pages\/ucenter\/login-page.*/},
"/pages/common/webview/webview",
"/pages/grid/grid",
"/pages/ucenter/ucenter",
"/pages/ucenter/guestbook/guestbook",
"/pages/ucenter/about/about",
"/pages/ucenter/settings/settings"
"needLogin" : [
// {pattern:/^\/pages\/list.*/}, //支持正则表达式
"/uni_modules/uni-news-favorite/pages/uni-news-favorite/list",
"/uni_modules/uni-feedback/pages/uni-feedback/add"
],
// "visitor" : [
// "/",//注意入口页必须直接写 "/"
// {"pattern":/^\/pages\/list.*/}, //支持正则表达式
// {"pattern":/^\/pages\/ucenter\/login-page.*/},
// "/pages/common/webview/webview",
// "/pages/grid/grid",
// "/pages/ucenter/ucenter",
// "/pages/ucenter/guestbook/guestbook",
// "/pages/ucenter/about/about",
// "/pages/ucenter/settings/settings"
// ],
/*
login:配置登陆类型与优先级
未列举到的,或设备环境不支持的选项,将被隐藏。如果你需要在不同平台有不同的配置,直接用条件编译即可
根据数组的第0项,决定登录方式的第一优先级。
*/
"login": ["username","univerify","weixin", "smsCode", "apple"]
"login": ["username","univerify","weixin", "smsCode", "apple"],
// "login": ["univerify"]
},
//关于应用
"about": {
......@@ -63,12 +65,12 @@ export default {
"slogan": "云端一体应用快速开发模版",
//政策协议
"agreements": [{
// "title": "为了多语言国际化请在 lang/en.js 和 lang/zh-Hans.js中配置",
"url": "请填写用户服务协议链接" //对应的网络链接
"title": "用户服务条款",// 为了多语言国际化请在 lang/en.js 和 lang/zh-Hans.js中配置",
"url": "https://ask.dcloud.net.cn/protocol.html" //对应的网络链接
},
{
// "title": "为了多语言国际化请在 lang/en.js 和 lang/zh-Hans.js中配置",
"url": "请填写隐私政策链接"
"title": "隐私政策",//为了多语言国际化请在 lang/en.js 和 lang/zh-Hans.js中配置
"url": "https://ask.dcloud.net.cn/protocol.html"
}
],
//应用的链接,用于分享到第三方平台和生成关于我们页的二维码
......
......@@ -44,8 +44,8 @@
"smsSecret": "短信密钥secret,开通短信服务处可以看到"
},
"univerify": {
"appid": "当前应用的appid,使用云函数URL化,此项必须配置",
"apiKey": "apiKey 和 apiSecret 在开发者中心获取,开发者中心:https://dev.dcloud.net.cn/uniLogin/index?type=0,文档:https://ask.dcloud.net.cn/article/37965",
"appid": "",
"apiKey": "",
"apiSecret": ""
}
}
......
......@@ -293,11 +293,11 @@ exports.main = async (event, context) => {
break;
case 'sendSmsCode':
/* -开始- 测试期间,为节约资源。统一虚拟短信验证码为: 123456;开启以下代码块即可 */
// return uniID.setVerifyCode({
// mobile: params.mobile,
// code: '123456',
// type: params.type
// })
return uniID.setVerifyCode({
mobile: params.mobile,
code: '123456',
type: params.type
})
/* -结束- */
// 简单限制一下客户端调用频率
......
console.log('----vue.config.js----')
process.env.UNI_CLOUD_PROVIDER = JSON.stringify([{
"provider": "aliyun", //阿里云
"clientSecret": "",
"spaceId": "",
/* "provider": "tencent",
"spaceId": "" */
}])
module.exports = {}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册