fix (接口自动化): 单条场景执行支持导出及生成测试报告
This commit is contained in:
parent
737f75eb7b
commit
9ebb834878
|
@ -20,6 +20,7 @@ import io.metersphere.controller.request.ScheduleRequest;
|
||||||
import io.metersphere.log.annotation.MsAuditLog;
|
import io.metersphere.log.annotation.MsAuditLog;
|
||||||
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
||||||
import io.metersphere.track.request.testplan.FileOperationRequest;
|
import io.metersphere.track.request.testplan.FileOperationRequest;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
@ -182,7 +183,9 @@ public class ApiAutomationController {
|
||||||
@PostMapping(value = "/run")
|
@PostMapping(value = "/run")
|
||||||
@MsAuditLog(module = "api_automation", type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
|
@MsAuditLog(module = "api_automation", type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.ids)", msClass = ApiAutomationService.class)
|
||||||
public String run(@RequestBody RunScenarioRequest request) {
|
public String run(@RequestBody RunScenarioRequest request) {
|
||||||
|
if(!StringUtils.equals(request.getExecuteType(),ExecuteType.Saved.name())){
|
||||||
request.setExecuteType(ExecuteType.Completed.name());
|
request.setExecuteType(ExecuteType.Completed.name());
|
||||||
|
}
|
||||||
request.setTriggerMode(TriggerMode.MANUAL.name());
|
request.setTriggerMode(TriggerMode.MANUAL.name());
|
||||||
request.setRunMode(ApiRunMode.SCENARIO.name());
|
request.setRunMode(ApiRunMode.SCENARIO.name());
|
||||||
return apiAutomationService.run(request);
|
return apiAutomationService.run(request);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
</span>
|
</span>
|
||||||
<span class="time"> {{ report.createTime | timestampFormatDate }}</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') }}
|
{{ $t('test_track.plan_view.export_report') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
||||||
|
@ -37,6 +37,10 @@
|
||||||
props: {
|
props: {
|
||||||
report: {},
|
report: {},
|
||||||
debug: Boolean,
|
debug: Boolean,
|
||||||
|
exportFlag: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
path() {
|
path() {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<ms-main-container>
|
<ms-main-container>
|
||||||
<el-card>
|
<el-card>
|
||||||
<section class="report-container">
|
<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>
|
<main>
|
||||||
<ms-metric-chart :content="content" :totalTime="totalTime" v-if="!loading"/>
|
<ms-metric-chart :content="content" :totalTime="totalTime" v-if="!loading"/>
|
||||||
<div>
|
<div>
|
||||||
|
@ -71,6 +71,7 @@ export default {
|
||||||
fullTreeNodes: [],
|
fullTreeNodes: [],
|
||||||
debugResult: new Map,
|
debugResult: new Map,
|
||||||
scenarioMap: new Map,
|
scenarioMap: new Map,
|
||||||
|
exportFlag:false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
|
@ -365,6 +366,7 @@ export default {
|
||||||
})
|
})
|
||||||
this.formatTree(array, this.failsTreeNodes);
|
this.formatTree(array, this.failsTreeNodes);
|
||||||
this.recursiveSorting(this.failsTreeNodes);
|
this.recursiveSorting(this.failsTreeNodes);
|
||||||
|
this.exportFlag = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formatTree(array, tree) {
|
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: {
|
computed: {
|
||||||
projectId() {
|
projectId() {
|
||||||
|
@ -486,7 +504,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
/deep/ .el-card__body {
|
/deep/ .el-card__body {
|
||||||
padding: 0px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.report-header a {
|
.report-header a {
|
||||||
|
|
|
@ -836,6 +836,7 @@ export default {
|
||||||
run.id = getUUID();
|
run.id = getUUID();
|
||||||
run.projectId = this.projectId;
|
run.projectId = this.projectId;
|
||||||
run.ids = scenarioIds;
|
run.ids = scenarioIds;
|
||||||
|
run.executeType = "Saved";
|
||||||
this.$post(url, run, response => {
|
this.$post(url, run, response => {
|
||||||
this.runVisible = true;
|
this.runVisible = true;
|
||||||
this.reportId = run.id;
|
this.reportId = run.id;
|
||||||
|
|
Loading…
Reference in New Issue