fix(接口测试): 修复接口测试报告导出时请求信息获取不到的bug

--bug=1013171 --user=宋天阳 [接口测试]github#13566导出的自动化测试报告中请求、响应大小都为0,断言也没有显示
https://www.tapd.cn/55049933/s/1158914
This commit is contained in:
song-tianyang 2022-05-16 20:18:42 +08:00 committed by 刘瑞斌
parent 181b4a33b6
commit c3ec256a59
3 changed files with 36 additions and 9 deletions

View File

@ -34,6 +34,11 @@ public class APIScenarioReportController {
return apiReportService.get(reportId,false);
}
@GetMapping("/getAll/{reportId}")
public APIScenarioReportResult getAll(@PathVariable String reportId) {
return apiReportService.get(reportId,true);
}
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<APIScenarioReportResult>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryAPIReportRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);

View File

@ -40,7 +40,9 @@
</el-tab-pane>
<el-tab-pane name="unExecute" v-if="content.unExecute > 0">
<template slot="label">
<span class="fail" style="color: #9C9B9A">{{ $t('api_test.home_page.detail_card.unexecute') }}</span>
<span class="fail" style="color: #9C9B9A">{{
$t('api_test.home_page.detail_card.unexecute')
}}</span>
</template>
<ms-scenario-results v-on:requestResult="requestResult"
:report="report"
@ -79,7 +81,7 @@ import MsApiReportExport from "./ApiReportExport";
import MsApiReportViewHeader from "./ApiReportViewHeader";
import {RequestFactory} from "../../definition/model/ApiTestModel";
import {windowPrint, getUUID, getCurrentProjectID} from "@/common/js/utils";
import {getScenarioReport, getShareScenarioReport} from "@/network/api";
import {getScenarioReport, getScenarioReportAll, getShareScenarioReport} from "@/network/api";
import {STEP} from "@/business/components/api/automation/scenario/Setting";
import MsCodeEdit from "@/business/components/common/components/MsCodeEdit";
@ -109,6 +111,7 @@ export default {
requestType: undefined,
fullTreeNodes: [],
stepFilter: new STEP,
exportReportIsOk: false,
}
},
activated() {
@ -139,7 +142,7 @@ export default {
if (this.isTemplate) {
this.getReport();
}
}
},
},
methods: {
filter(index) {
@ -147,7 +150,7 @@ export default {
this.$refs.failsTree.filter(index);
} else if (this.activeName === "errorReport") {
this.$refs.errorReportTree.filter("errorReport");
} else if(this.activeName === "unExecute"){
} else if (this.activeName === "unExecute") {
this.$refs.unExecuteTree.filter("unexecute");
}
},
@ -339,13 +342,13 @@ export default {
}
}
},
getReport() {
getReport(getAllReport) {
this.init();
if (this.isTemplate) {
//
if(this.templateReport){
if (this.templateReport) {
this.handleGetScenarioReport(this.templateReport);
}else {
} else {
this.report = this.templateReport;
this.buildReport();
}
@ -354,6 +357,17 @@ export default {
this.checkReport(data);
this.handleGetScenarioReport(data);
});
} else if (getAllReport) {
if (this.exportReportIsOk) {
this.startExport();
} else {
getScenarioReportAll(this.reportId, (data) => {
this.checkReport(data);
this.handleGetScenarioReport(data);
this.exportReportIsOk = true;
this.startExport();
});
}
} else {
getScenarioReport(this.reportId, (data) => {
this.checkReport(data);
@ -483,7 +497,7 @@ export default {
formatExportApi(array, scenario) {
array.forEach(item => {
if (this.stepFilter && this.stepFilter.get("AllSamplerProxy").indexOf(item.type) !== -1) {
if(item.errorCode){
if (item.errorCode) {
item.value.errorCode = item.errorCode;
}
scenario.requestResults.push(item.value);
@ -493,7 +507,11 @@ export default {
}
})
},
handleExport() {
this.getReport(true);
},
startExport() {
if (this.report.reportVersion && this.report.reportVersion > 1) {
if (this.report.reportType === 'API_INTEGRATED' || this.report.reportType === 'UI_INTEGRATED') {
let scenario = {name: "", requestResults: []};
@ -550,7 +568,7 @@ export default {
this.getReport();
this.$EventBus.$on('projectChange', this.handleProjectChange);
},
destroyed () {
destroyed() {
this.$EventBus.$off('projectChange', this.handleProjectChange);
},
computed: {

View File

@ -12,6 +12,10 @@ export function getScenarioReport(reportId, callback) {
return reportId ? baseGet('/api/scenario/report/get/' + reportId, callback) : {};
}
export function getScenarioReportAll(reportId, callback) {
return reportId ? baseGet('/api/scenario/report/getAll/' + reportId, callback) : {};
}
export function getApiReport(testId, callback) {
return testId ? baseGet('/api/definition/report/getReport/' + testId, callback) : {};
}