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.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);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<header class="report-header">
|
||||
<el-row>
|
||||
<el-col>
|
||||
<!-- <span v-if="!debug"><el-input size="mini" style="width: 200px" v-model="report.name"/> </span>-->
|
||||
<!-- <span v-if="!debug"><el-input size="mini" style="width: 200px" v-model="report.name"/> </span>-->
|
||||
<span v-if="!debug">
|
||||
<el-input v-if="nameIsEdit" size="mini" @blur="nameIsEdit = false" style="width: 200px" v-model="report.name"/>
|
||||
<span v-else>
|
||||
|
@ -17,12 +17,12 @@
|
|||
</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">
|
||||
{{$t('test_track.plan_view.export_report')}}
|
||||
<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>
|
||||
|
||||
<el-button v-if="!debug" :disabled="isReadOnly" class="export-button" plain type="primary" size="mini" @click="handleSave(report.name)" style="margin-right: 10px">
|
||||
{{$t('commons.save')}}
|
||||
{{ $t('commons.save') }}
|
||||
</el-button>
|
||||
|
||||
</el-col>
|
||||
|
@ -32,28 +32,32 @@
|
|||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
export default {
|
||||
name: "MsApiReportViewHeader",
|
||||
props: {
|
||||
report: {},
|
||||
debug: Boolean,
|
||||
exportFlag: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
path() {
|
||||
return "/api/test/edit?id=" + this.report.testId;
|
||||
},
|
||||
scenarioId(){
|
||||
if(typeof this.report.scenarioId === 'string'){
|
||||
scenarioId() {
|
||||
if (typeof this.report.scenarioId === 'string') {
|
||||
return this.report.scenarioId;
|
||||
}else {
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
isSingleScenario(){
|
||||
isSingleScenario() {
|
||||
try {
|
||||
JSON.parse(this.report.scenarioId);
|
||||
return false;
|
||||
} catch(e){
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +65,7 @@
|
|||
data() {
|
||||
return {
|
||||
isReadOnly: false,
|
||||
nameIsEdit:false,
|
||||
nameIsEdit: false,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -75,13 +79,13 @@
|
|||
this.$emit('reportSave', name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.export-button {
|
||||
.export-button {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -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>
|
||||
|
@ -61,8 +61,8 @@ export default {
|
|||
failsTreeNodes: [],
|
||||
totalTime: 0,
|
||||
isRequestResult: false,
|
||||
startTime : 99991611737506593,
|
||||
endTime : 0,
|
||||
startTime: 99991611737506593,
|
||||
endTime: 0,
|
||||
request: {},
|
||||
isActive: false,
|
||||
scenarioName: null,
|
||||
|
@ -71,6 +71,7 @@ export default {
|
|||
fullTreeNodes: [],
|
||||
debugResult: new Map,
|
||||
scenarioMap: new Map,
|
||||
exportFlag:false,
|
||||
}
|
||||
},
|
||||
activated() {
|
||||
|
@ -247,7 +248,7 @@ export default {
|
|||
this.$success(this.$t('schedule.event_success'));
|
||||
});
|
||||
},
|
||||
getTransaction(transRequests,resMap) {
|
||||
getTransaction(transRequests, resMap) {
|
||||
transRequests.forEach(subItem => {
|
||||
if (subItem.method === 'Request') {
|
||||
this.getTransaction(subItem.subRequestResults, resMap);
|
||||
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue