fix(接口自动化): 循环结果放到各自请求中

This commit is contained in:
fit2-zhao 2021-02-04 19:12:36 +08:00
parent bd12a36af5
commit 039898c635
2 changed files with 48 additions and 21 deletions

View File

@ -34,7 +34,16 @@
<ms-dubbo-basis-parameters :request="request" v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'" :showScript="false"/>
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
<api-response-component :currentProtocol="request.protocol" :result="request.requestResult"/>
<div v-if="request.result">
<el-tabs v-model="request.activeName" closable class="ms-tabs">
<el-tab-pane :label="item.name" :name="item.name" v-for="(item,index) in request.result.scenarios" :key="index">
<div v-for="(result,i) in item.requestResults" :key="i" style="margin-bottom: 5px">
<api-response-component v-if="result.name===request.name" :result="result"/>
</div>
</el-tab-pane>
</el-tabs>
</div>
<api-response-component :currentProtocol="request.protocol" :result="request.requestResult" v-else/>
<!-- 保存操作 -->
<el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(item)" v-if="!request.referenced">
@ -86,6 +95,7 @@
if (!this.request.requestResult) {
this.request.requestResult = {responseResult: {}};
}
console.log(this.request)
//
this.getApiInfo();
if (this.request.protocol === 'HTTP') {
@ -155,7 +165,7 @@
return true
}
return false;
}
},
},
methods: {
remove() {
@ -247,6 +257,7 @@
},
runRefresh(data) {
this.request.requestResult = data;
this.request.result = undefined;
this.loading = false;
},
reload() {
@ -289,4 +300,9 @@
.icon.is-active {
transform: rotate(90deg);
}
.ms-tabs >>> .el-icon-close:before {
content: "";
}
</style>

View File

@ -79,17 +79,17 @@
<el-input-number size="small" v-model="controller.whileController.timeout" :placeholder="$t('commons.millisecond')" :max="1000*10000000" :min="3000" :step="1000"/>
<span class="ms-span ms-radio">ms</span>
</div>
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
<div>
<el-tabs v-model="activeName" closable class="ms-tabs">
<el-tab-pane :label="item.name" :name="item.name" v-for="(item,index) in requestResult.scenarios" :key="index">
<div v-for="(result,i) in item.requestResults" :key="i" style="margin-bottom: 5px">
<api-response-component :result="result"/>
</div>
</el-tab-pane>
</el-tabs>
<!--<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>-->
<!--<div>-->
<!--<el-tabs v-model="activeName" closable class="ms-tabs">-->
<!--<el-tab-pane :label="item.name" :name="item.name" v-for="(item,index) in requestResult.scenarios" :key="index">-->
<!--<div v-for="(result,i) in item.requestResults" :key="i" style="margin-bottom: 5px">-->
<!--<api-response-component :result="result"/>-->
<!--</div>-->
<!--</el-tab-pane>-->
<!--</el-tabs>-->
</div>
<!--</div>-->
</api-base-component>
@ -117,7 +117,7 @@
},
},
created() {
this.initResult();
// this.initResult();
},
data() {
return {
@ -202,7 +202,6 @@
this.$warning("当前循环下没有请求,不能执行")
return;
}
this.controller.active = true;
this.loading = true;
this.debugData = {
id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario",
@ -224,7 +223,7 @@
},
changeRadio() {
this.controller.active = true;
this.initResult();
//this.initResult();
this.reload();
},
change(value) {
@ -258,6 +257,20 @@
this.success = this.requestResult.scenarios && this.requestResult.scenarios != null ? this.requestResult.scenarios.length - this.error : 0;
}
},
setResult(hashTree) {
if (hashTree) {
hashTree.forEach(item => {
if (item.type === "HTTPSamplerProxy" || item.type === "DubboSampler" || item.type === "JDBCSampler" || item.type === "TCPSampler") {
item.result = this.requestResult;
item.activeName = this.activeName;
item.requestResult = undefined;
}
if (item.hashTree && item.hashTree.length > 0) {
this.setResult(item.hashTree);
}
})
}
},
getReport() {
if (this.reportId) {
let url = "/api/scenario/report/get/" + this.reportId;
@ -285,11 +298,14 @@
break;
}
this.getFails();
this.activeName = this.requestResult && this.requestResult.scenarios && this.requestResult.scenarios != null && this.requestResult.scenarios.length > 0 ? this.requestResult.scenarios[0].name : "";
//
this.setResult(this.controller.hashTree);
} catch (e) {
throw e;
}
this.loading = false;
this.activeName = this.requestResult && this.requestResult.scenarios && this.requestResult.scenarios != null && this.requestResult.scenarios.length > 0 ? this.requestResult.scenarios[0].name : "";
this.reload();
} else {
setTimeout(this.getReport, 2000)
}
@ -333,11 +349,6 @@
margin: 20px 0;
}
.ms-tabs >>> .el-icon-close:before {
content: "";
}
.icon.is-active {
transform: rotate(90deg);
}