完成follow_redirects,展示子请求内容

This commit is contained in:
q4speed 2020-05-26 14:32:20 +08:00
parent d240c1a377
commit 12b4aae62c
6 changed files with 60 additions and 15 deletions

View File

@ -121,6 +121,9 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
requestResult.setTotalAssertions(result.getAssertionResults().length);
requestResult.setSuccess(result.isSuccessful());
requestResult.setError(result.getErrorCount());
for (SampleResult subResult : result.getSubResults()) {
requestResult.getSubRequestResults().add(getRequestResult(subResult));
}
ResponseResult responseResult = requestResult.getResponseResult();
responseResult.setBody(new String(result.getResponseData(), StandardCharsets.UTF_8));

View File

@ -2,6 +2,9 @@ package io.metersphere.api.jmeter;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class RequestResult {
@ -27,6 +30,8 @@ public class RequestResult {
private int passAssertions = 0;
private final List<RequestResult> subRequestResults = new ArrayList<>();
private final ResponseResult responseResult = new ResponseResult();
public void addPassAssertions() {

View File

@ -9,7 +9,9 @@
</el-col>
<el-col :span="12">
<div class="name">{{request.name}}</div>
<div class="url">{{request.url}}</div>
<el-tooltip effect="dark" :content="request.url" placement="bottom" :open-delay="800">
<div class="url">{{request.url}}</div>
</el-tooltip>
</el-col>
<el-col :span="2">
<div class="time">
@ -34,10 +36,24 @@
</div>
<el-collapse-transition>
<div v-show="isActive">
<ms-request-metric :request="request"/>
<ms-request-text :request="request"/>
<br>
<ms-response-text :response="request.responseResult"/>
<el-tabs v-model="activeName" v-show="isActive" v-if="hasSub">
<el-tab-pane :label="$t('api_report.sub_result')" name="sub">
<ms-request-result class="sub-result" v-for="(sub, index) in request.subRequestResults"
:key="index" :request="sub"/>
</el-tab-pane>
<el-tab-pane :label="$t('api_report.request_result')" name="result">
<ms-request-metric :request="request"/>
<ms-request-text :request="request"/>
<br>
<ms-response-text :response="request.responseResult"/>
</el-tab-pane>
</el-tabs>
<div v-else>
<ms-request-metric :request="request"/>
<ms-request-text :request="request"/>
<br>
<ms-response-text :response="request.responseResult"/>
</div>
</div>
</el-collapse-transition>
</div>
@ -59,9 +75,7 @@
data() {
return {
isActive: false,
activeName: "request",
activeName2: "body",
activeName3: "body",
activeName: "sub",
}
},
@ -75,6 +89,9 @@
assertion() {
return this.request.passAssertions + " / " + this.request.totalAssertions;
},
hasSub() {
return this.request.subRequestResults.length > 0;
}
}
}
</script>
@ -93,7 +110,6 @@
}
.request-result .method {
/*border-left: 5px solid #1E90FF;*/
color: #1E90FF;
font-size: 14px;
font-weight: 500;
@ -106,9 +122,10 @@
font-size: 12px;
font-weight: 400;
margin-top: 4px;
overflow: auto;
white-space: normal;
word-wrap: break-word;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
word-break: break-all;
}
.request-result .tab .el-tabs__header {
@ -119,4 +136,18 @@
height: 300px;
overflow-y: auto;
}
.sub-result .info {
background-color: #FFF;
}
.sub-result .method {
border-left: 5px solid #1E90FF;
padding-left: 20px;
}
.sub-result:last-child {
border-bottom: 1px solid #EBEEF5;
}
</style>

View File

@ -338,7 +338,9 @@ export default {
success: "Success",
fail: "Fail",
total: "Total",
test_name: "Test"
test_name: "Test",
request_result: "Result",
sub_result: "Sub Result"
},
test_track: {
test_track: "Track",

View File

@ -335,7 +335,9 @@ export default {
success: "成功",
fail: "失败",
total: "全部",
test_name: "所属测试"
test_name: "所属测试",
request_result: "请求结果",
sub_result: "子请求"
},
test_track: {
test_track: "测试跟踪",

View File

@ -326,7 +326,9 @@ export default {
success: "成功",
fail: "失敗",
total: "全部",
test_name: "所屬測試"
test_name: "所屬測試",
request_result: "請求結果",
sub_result: "子請求"
},
test_track: {
test_track: "測試跟踪",