fix(接口测试): 修复测试报告导出时没有统计信息的问题

修复测试报告导出时没有统计信息的问题
This commit is contained in:
song-tianyang 2022-05-20 13:42:17 +08:00 committed by f2c-ci-robot[bot]
parent 94eadaa43c
commit ceba6c714d
2 changed files with 35 additions and 16 deletions

View File

@ -60,6 +60,7 @@
</el-tabs>
</div>
<ms-api-report-export v-if="reportExportVisible" id="apiTestReport" :title="report.name"
:report="report"
:content="content" :total-time="totalTime"/>
</main>
</section>
@ -159,7 +160,6 @@ export default {
this.report = {};
this.content = {};
this.fails = [];
this.report = {};
this.fullTreeNodes = [];
this.failsTreeNodes = [];
this.isRequestResult = false;
@ -342,7 +342,31 @@ export default {
}
}
},
getReport(getAllReport) {
getReportByExport() {
if (this.exportReportIsOk) {
this.startExport();
} else {
getScenarioReportAll(this.reportId, (data) => {
if (data && data.content) {
let report = JSON.parse(data.content);
this.content = report;
this.fullTreeNodes = report.steps;
this.content.console = report.console;
this.content.error = report.error;
let successCount = (report.total - report.error - report.errorCode - report.unExecute);
if (successCount >= report.unExecute) {
//
successCount = successCount - report.unExecute;
}
this.content.success = successCount;
this.totalTime = report.totalTime;
}
this.exportReportIsOk = true;
setTimeout(this.startExport, 500)
});
}
},
getReport() {
this.init();
if (this.isTemplate) {
//
@ -357,17 +381,6 @@ 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);
@ -394,7 +407,12 @@ export default {
this.fullTreeNodes = report.steps;
this.content.console = report.console;
this.content.error = report.error;
this.content.success = (report.total - report.error - report.errorCode);
let successCount = (report.total - report.error - report.errorCode - report.unExecute);
if (successCount >= report.unExecute) {
//
successCount = successCount - report.unExecute;
}
this.content.success = successCount;
this.totalTime = report.totalTime;
}
this.loading = false;
@ -509,7 +527,7 @@ export default {
},
handleExport() {
this.getReport(true);
this.getReportByExport();
},
startExport() {
if (this.report.reportVersion && this.report.reportVersion > 1) {

View File

@ -1,6 +1,6 @@
<template>
<ms-report-export-template :title="title" :type="$t('report.api_test_report')">
<ms-metric-chart :content="content" :is-export="true" :totalTime="totalTime"/>
<ms-metric-chart :content="content" :is-export="true" :totalTime="totalTime" :report="report"/>
<div class="scenario-result" v-for="(scenario, index) in content.scenarios" :key="index" :scenario="scenario">
<div>
<el-card>
@ -95,6 +95,7 @@
MsReportTitle, MsMetricChart, ApiReportReqestHeaderItem, MsRequestResultTail, MsScenarioResult ,MsAssertionResults
},
props: {
report:Object,
content: Object,
totalTime: Number,
title: String