fix (接口自动化): 单条场景执行支持导出及生成测试报告

This commit is contained in:
fit2-zhao 2021-07-30 15:38:29 +08:00 committed by fit2-zhao
parent 737f75eb7b
commit 9ebb834878
4 changed files with 77 additions and 51 deletions

View File

@ -20,6 +20,7 @@ import io.metersphere.controller.request.ScheduleRequest;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
import io.metersphere.track.request.testplan.FileOperationRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@ -182,7 +183,9 @@ public class ApiAutomationController {
@PostMapping(value = "/run")
@MsAuditLog(module = "api_automation", type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
public String run(@RequestBody RunScenarioRequest request) {
if(!StringUtils.equals(request.getExecuteType(),ExecuteType.Saved.name())){
request.setExecuteType(ExecuteType.Completed.name());
}
request.setTriggerMode(TriggerMode.MANUAL.name());
request.setRunMode(ApiRunMode.SCENARIO.name());
return apiAutomationService.run(request);

View File

@ -17,7 +17,7 @@
</span>
<span class="time"> {{ report.createTime | timestampFormatDate }}</span>
<el-button v-if="!debug" v-permission="['PROJECT_API_REPORT:READ+EXPORT']" :disabled="isReadOnly" class="export-button" plain type="primary" size="mini" @click="handleExport(report.name)" style="margin-right: 10px">
<el-button v-if="!debug || exportFlag" v-permission="['PROJECT_API_REPORT:READ+EXPORT']" :disabled="isReadOnly" class="export-button" plain type="primary" size="mini" @click="handleExport(report.name)" style="margin-right: 10px">
{{ $t('test_track.plan_view.export_report') }}
</el-button>
@ -37,6 +37,10 @@
props: {
report: {},
debug: Boolean,
exportFlag: {
type: Boolean,
default: false,
}
},
computed: {
path() {

View File

@ -3,7 +3,7 @@
<ms-main-container>
<el-card>
<section class="report-container">
<ms-api-report-view-header :debug="debug" :report="report" @reportExport="handleExport"/>
<ms-api-report-view-header :debug="debug" :export-flag="exportFlag" :report="report" @reportExport="handleExport" @reportSave="handleSave"/>
<main>
<ms-metric-chart :content="content" :totalTime="totalTime" v-if="!loading"/>
<div>
@ -71,6 +71,7 @@ export default {
fullTreeNodes: [],
debugResult: new Map,
scenarioMap: new Map,
exportFlag:false,
}
},
activated() {
@ -365,6 +366,7 @@ export default {
})
this.formatTree(array, this.failsTreeNodes);
this.recursiveSorting(this.failsTreeNodes);
this.exportFlag = true;
}
},
formatTree(array, tree) {
@ -459,6 +461,22 @@ export default {
}
}
},
handleSave() {
if (!this.report.name) {
this.$warning(this.$t('api_test.automation.report_name_info'));
return;
}
this.loading = true;
this.report.projectId = this.projectId;
let url = "/api/scenario/report/update";
this.result = this.$post(url, this.report, response => {
this.$success(this.$t('commons.save_success'));
this.loading = false;
this.$emit('refresh');
}, error => {
this.loading = false;
});
},
},
computed: {
projectId() {
@ -486,7 +504,7 @@ export default {
}
/deep/ .el-card__body {
padding: 0px;
padding: 10px;
}
.report-header a {

View File

@ -836,6 +836,7 @@ export default {
run.id = getUUID();
run.projectId = this.projectId;
run.ids = scenarioIds;
run.executeType = "Saved";
this.$post(url, run, response => {
this.runVisible = true;
this.reportId = run.id;