Browse Source

优化

master
陈裕财 3 years ago
parent
commit
1a5b526e9a
  1. 2
      src/views/xm/core/xmIteration/index.vue
  2. 2
      src/views/xm/core/xmProduct/index.vue
  3. 2
      src/views/xm/core/xmProject/index.vue
  4. 10
      src/views/xm/core/xmTestCasedb/index.vue
  5. 117
      src/views/xm/core/xmTestPlanCase/XmTestPlanCaseMng.vue

2
src/views/xm/core/xmIteration/index.vue

@ -34,7 +34,7 @@ export default {
if(!this.$route.query.iterationId){ if(!this.$route.query.iterationId){
this.$message.error("地址不合规") this.$message.error("地址不合规")
this.$route.back(-1)
this.$router.back(-1)
} }
if(!this.xmIteration||this.xmIteration.id!=this.$route.query.iterationId){ if(!this.xmIteration||this.xmIteration.id!=this.$route.query.iterationId){
listXmIterationWithState({id:this.$route.query.iterationId}).then(res=>{ listXmIterationWithState({id:this.$route.query.iterationId}).then(res=>{

2
src/views/xm/core/xmProduct/index.vue

@ -34,7 +34,7 @@ export default {
if(!this.$route.query.productId){ if(!this.$route.query.productId){
this.$message.error("地址不合规") this.$message.error("地址不合规")
this.$route.back(-1)
this.$router.back(-1)
} }
if(!this.xmProduct||this.xmProduct.id!=this.$route.query.productId){ if(!this.xmProduct||this.xmProduct.id!=this.$route.query.productId){
listXmProductWithState({id:this.$route.query.productId}).then(res=>{ listXmProductWithState({id:this.$route.query.productId}).then(res=>{

2
src/views/xm/core/xmProject/index.vue

@ -33,7 +33,7 @@ export default {
mounted() { mounted() {
if(!this.$route.query.projectId){ if(!this.$route.query.projectId){
this.$message.error("地址不合规") this.$message.error("地址不合规")
this.$route.back(-1)
this.$router.back(-1)
} }
if(!this.projectInfo||this.projectInfo.id!=this.$route.query.projectId){ if(!this.projectInfo||this.projectInfo.id!=this.$route.query.projectId){
listXmProject({id:this.$route.query.projectId}).then(res=>{ listXmProject({id:this.$route.query.projectId}).then(res=>{

10
src/views/xm/core/xmTestCasedb/index.vue

@ -34,7 +34,7 @@ export default {
if(!this.$route.query.casedbId){ if(!this.$route.query.casedbId){
this.$message.error("地址不合规") this.$message.error("地址不合规")
this.$route.back(-1)
this.$router.back(-1)
} }
if(!this.testCasedb||this.testCasedb.id!=this.$route.query.casedbId){ if(!this.testCasedb||this.testCasedb.id!=this.$route.query.casedbId){
listXmTestCasedb({id:this.$route.query.casedbId}).then(res=>{ listXmTestCasedb({id:this.$route.query.casedbId}).then(res=>{
@ -44,16 +44,12 @@ export default {
store.dispatch('setTestCasedb',res.data.data[0]) store.dispatch('setTestCasedb',res.data.data[0])
}else{ }else{
this.$message.error("测试用例库不存在,请确保测试用例库编号正确") this.$message.error("测试用例库不存在,请确保测试用例库编号正确")
this.$router.push({
path:'/xm/core/casedb/mng'
})
this.$router.back(-1)
} }
}else{ }else{
this.$message.error(tips.msg) this.$message.error(tips.msg)
this.$router.push({
path:'/xm/core/casedb/mng'
})
this.$router.back(-1)
} }
}) })
} }

117
src/views/xm/core/xmTestPlanCase/XmTestPlanCaseMng.vue

@ -94,6 +94,18 @@
<el-dialog title="选择测试用例" :visible.sync="addFormVisible" width="80%" top="20px" append-to-body :close-on-click-modal="false"> <el-dialog title="选择测试用例" :visible.sync="addFormVisible" width="80%" top="20px" append-to-body :close-on-click-modal="false">
<xm-test-case-select :xm-test-plan="xmTestPlan" :xm-test-casedb="xmTestCasedb" :visible="addFormVisible" @cancel="addFormVisible=false" @select="onXmTestCaseSelect"></xm-test-case-select> <xm-test-case-select :xm-test-plan="xmTestPlan" :xm-test-casedb="xmTestCasedb" :visible="addFormVisible" @cancel="addFormVisible=false" @select="onXmTestCaseSelect"></xm-test-case-select>
</el-dialog> </el-dialog>
<el-dialog title="批量执行自动化测试用例" :visible.sync="doBatchExecVisible" width="600" top="20px" append-to-body :close-on-click-modal="false">
<el-result v-if="load.doBatch" icon="warning" title="警告提示" :subTitle="'正在批量执行测试用例,请勿关闭窗口,当前进度【'+batchProgress+'%】'">
</el-result>
<el-result v-if="!load.doBatch" icon="success" title="执行完毕" :subTitle="'成功用例【'+okCasesNum+'】,失败【'+errCasesNum+'】,忽略【'+igCasesNum+'】'">
<template slot="extra">
<el-button type="primary" size="medium" @click="doBatchBack">返回</el-button>
</template>
</el-result>
</el-dialog>
</el-row> </el-row>
</section> </section>
</template> </template>
@ -110,7 +122,8 @@ import MdpSelectUserXm from '@/views/xm/core/components/MdpSelectUserXm';//修
import {autoStepToAxios,initEnvVars} from '@/api/xm/core/XmTestAutoStep.js';// import {autoStepToAxios,initEnvVars} from '@/api/xm/core/XmTestAutoStep.js';//
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import axios from 'axios'//访
import axios from 'axios'//访
export default { export default {
name:'xmTestPlanCaseMng', name:'xmTestPlanCaseMng',
components: { components: {
@ -152,6 +165,11 @@ export default {
caseStatus:'', caseStatus:'',
execStatus:'' execStatus:''
}, },
batchProgress:0,
okCasesNum:0,
errCasesNum:0,
igCasesNum:0,
xmTestPlanCases: [],// xmTestPlanCases: [],//
pageInfo:{// pageInfo:{//
total:0,//0>0 total:0,//0>0
@ -161,7 +179,7 @@ export default {
orderFields:[],// ['sex','student_id'] orderFields:[],// ['sex','student_id']
orderDirs:[]// asc,desc ['asc','desc'] orderDirs:[]// asc,desc ['asc','desc']
}, },
load:{ list: false, edit: false, del: false, add: false },//...
load:{ list: false, edit: false, del: false, add: false,doBatch:false },//...
sels: [],// sels: [],//
dicts:{ dicts:{
testCaseStatus:[], testCaseStatus:[],
@ -177,6 +195,7 @@ export default {
bugs:'',execUserid:'',caseId:'',ltime:'',ctime:'',execStatus:'',execUsername:'',planId:'',caseName:'',priority:'',remark:'',testStep:'' bugs:'',execUserid:'',caseId:'',ltime:'',ctime:'',execStatus:'',execUsername:'',planId:'',caseName:'',priority:'',remark:'',testStep:''
}, },
maxTableHeight:300, maxTableHeight:300,
doBatchExecVisible:false,
} }
},//end data },//end data
methods: { methods: {
@ -365,7 +384,10 @@ export default {
} }
}).catch((e)=>Object.assign(this.editForm,this.editFormBak)) }).catch((e)=>Object.assign(this.editForm,this.editFormBak))
}, },
doBatchBack(){
this.doBatchExecVisible=false;
this.searchXmTestPlanCases();
},
editSomeFieldsForExec(sels,fieldName,$event){ editSomeFieldsForExec(sels,fieldName,$event){
let params={}; let params={};
params['pkList']=sels.map(i=>{ return { caseId:i.caseId, planId:i.planId}}) params['pkList']=sels.map(i=>{ return { caseId:i.caseId, planId:i.planId}})
@ -416,60 +438,71 @@ export default {
} }
this.doBatchExec(this.sels) this.doBatchExec(this.sels)
}, },
doBatchExec(planCases){
async doBatchExec(planCases){
this.doBatchExecVisible=true; this.doBatchExecVisible=true;
this.load.doBatch=true;
var igCases=planCases.filter(k=> !k.autoStep || k.testType!='1') var igCases=planCases.filter(k=> !k.autoStep || k.testType!='1')
if(igCases.length>0){
this.editSomeFieldsForExec(igCases,"execStatus",'1')
}
this.igCasesNum=igCases.length;
this.batchProgress=Math.round(igCases.length/planCases.length)
var cases=planCases.filter(k=>k.autoStep && k.testType=='1') var cases=planCases.filter(k=>k.autoStep && k.testType=='1')
var execAll=[] var execAll=[]
var env=initEnvVars(this.xmTestCasedb?this.xmTestCasedb.envJson:null,this.xmTestPlan ?this.xmTestPlan.envJson:null); var env=initEnvVars(this.xmTestCasedb?this.xmTestCasedb.envJson:null,this.xmTestPlan ?this.xmTestPlan.envJson:null);
cases.forEach(k=>{
this.sendMsgForTestSetting(k,env,execAll)
})
for( let k of cases ){
var data= await this.sendMsgForTestSetting(k,env)
execAll.push(data)
this.batchProgress=Math.round((igCases.length+execAll.length)/planCases.length)
}
var okCases=execAll.filter(k=>k.execStatus=='2') var okCases=execAll.filter(k=>k.execStatus=='2')
this.okCasesNum=okCases.length
if(okCases.length>0){ if(okCases.length>0){
this.editSomeFieldsForExec(okCases,"execStatus",'2')
this.editSomeFieldsForExec(okCases,"execStatus",'2')
} }
var errCases=execAll.filter(k=>k.execStatus=='4') var errCases=execAll.filter(k=>k.execStatus=='4')
this.errCasesNum=errCases.length;
if(errCases.length>0){ if(errCases.length>0){
this.editSomeFieldsForExec(errCases,"execStatus",'4') this.editSomeFieldsForExec(errCases,"execStatus",'4')
} }
this.load.doBatch=false;
}, },
sendMsgForTestSetting(planCase,env,execAll){
var autoStepObj=JSON.parse(planCase.autoStep)
if(!autoStepObj.url){
planCase.execStatus='1'
execAll.push(planCase)
}else{
var axiosObj=autoStepToAxios(autoStepObj,env)
//axiosObj.headers['Access-Control-Allow-Origin']='*'
//axios.defaults.withCredentials = true // cookie
//axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
axios(axiosObj).then(res=>{
if(autoStepObj.expectResult){
var func=new Function('res','env',autoStepObj.expectResult)
var result=func(res,env)
planCase.execStatus=result==true?"2":"4"
}else{
planCase.execStatus=res.status==200?"2":"4"
sendMsgForTestSetting:function(planCase,env){
return new Promise((resolve,reject)=>{
var autoStepObj=JSON.parse(planCase.autoStep)
if(!autoStepObj.url){
planCase.execStatus='1'
resolve(planCase)
}else{
var axiosObj=autoStepToAxios(autoStepObj,env)
//axiosObj.headers['Access-Control-Allow-Origin']='*'
//axios.defaults.withCredentials = true // cookie
//axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
axios(axiosObj).then(res=>{
if(autoStepObj.expectResult){
var func=new Function('res','env',autoStepObj.expectResult)
var result=func(res,env)
planCase.execStatus=result==true?"2":"4"
}else{
planCase.execStatus=res.status==200?"2":"4"
}
execAll.push(planCase)
}).catch(res=>{
var func=new Function('res','env',autoStepObj.expectResult)
var result=func(res,env)
if(result==true){
planCase.execStatus="2"
}else{
planCase.execStatus="4"
}
execAll.push(planCase)
})
}
}
resolve(planCase)
}).catch(res=>{
var func=new Function('res','env',autoStepObj.expectResult)
var result=func(res,env)
if(result==true){
planCase.execStatus="2"
}else{
planCase.execStatus="4"
}
resolve(planCase)
})
}
})
}, },
onXmFuncRowClick(row){ onXmFuncRowClick(row){

Loading…
Cancel
Save