refactor: 接口定义测试增加停止按钮

This commit is contained in:
shiziyuan9527 2021-08-13 15:01:16 +08:00 committed by 刘瑞斌
parent 2eed319309
commit c357870ece
4 changed files with 256 additions and 195 deletions

View File

@ -1,30 +1,30 @@
<template> <template>
<div class="card-container"> <div class="card-container">
<el-card class="card-content" v-loading="loading"> <el-card class="card-content">
<!-- 操作按钮 --> <!-- 操作按钮 -->
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand('add')" <el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand('add')"
@command="handleCommand" size="small" style="float: right;margin-right: 20px"> @command="handleCommand" size="small" style="float: right;margin-right: 20px" v-if="!runLoading">
{{$t('commons.test')}} {{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="load_case">{{$t('api_test.definition.request.load_case')}} <el-dropdown-item command="load_case">{{ $t('api_test.definition.request.load_case') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="save_as_case">{{$t('api_test.definition.request.save_as_case')}} <el-dropdown-item command="save_as_case">{{ $t('api_test.definition.request.save_as_case') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="update_api">{{$t('api_test.definition.request.update_api')}}</el-dropdown-item> <el-dropdown-item command="update_api">{{ $t('api_test.definition.request.update_api') }}</el-dropdown-item>
<el-dropdown-item command="save_as_api">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item> <el-dropdown-item command="save_as_api">{{ $t('api_test.definition.request.save_as') }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
<el-button size="small" type="primary" v-else @click.once="stop" style="float: right;margin-right: 20px">{{ $t('report.stop_btn') }}</el-button>
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
<!-- TCP 请求参数 --> <!-- TCP 请求参数 -->
<ms-basis-parameters :request="api.request" ref="requestForm"/> <ms-basis-parameters :request="api.request" ref="requestForm"/>
<!--返回结果--> <!--返回结果-->
<!-- HTTP 请求返回数据 --> <!-- HTTP 请求返回数据 -->
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p> <p class="tip">{{ $t('api_test.definition.request.res_param') }} </p>
<ms-request-result-tail :response="responseData" ref="runResult"/> <ms-request-result-tail :response="responseData" ref="runResult" v-loading="loading"/>
<ms-jmx-step :request="api.request" :response="responseData"/> <ms-jmx-step :request="api.request" :response="responseData"/>
</el-card> </el-card>
@ -38,7 +38,7 @@
<api-environment-config ref="environmentConfig" @close="environmentConfigClose"/> <api-environment-config ref="environmentConfig" @close="environmentConfigClose"/>
<!-- 执行组件 --> <!-- 执行组件 -->
<ms-run :debug="false" :environment="api.environment" :reportId="reportId" :run-data="runData" <ms-run :debug="false" :environment="api.environment" :reportId="reportId" :run-data="runData"
@runRefresh="runRefresh" ref="runTest"/> @runRefresh="runRefresh" @errorRefresh="errorRefresh" ref="runTest"/>
</div> </div>
</template> </template>
@ -67,28 +67,29 @@ export default {
MsRun, MsRun,
MsBasisParameters, MsBasisParameters,
MsJmxStep MsJmxStep
}, },
data() { data() {
return { return {
visible: false, visible: false,
api: {}, api: {},
loaded: false, loaded: false,
loading: false, loading: false,
currentRequest: {}, currentRequest: {},
createCase: "", createCase: "",
refreshSign: "", refreshSign: "",
responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []}, responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []},
reqOptions: REQ_METHOD, reqOptions: REQ_METHOD,
environments: [], environments: [],
rules: { rules: {
method: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}], method: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
url: [{required: true, message: this.$t('api_test.definition.request.path_info'), trigger: 'blur'}], url: [{required: true, message: this.$t('api_test.definition.request.path_info'), trigger: 'blur'}],
environmentId: [{required: true, message: this.$t('api_test.definition.request.run_env'), trigger: 'change'}], environmentId: [{required: true, message: this.$t('api_test.definition.request.run_env'), trigger: 'change'}],
}, },
runData: [], runData: [],
reportId: "", reportId: "",
} runLoading: false
}, }
},
props: {apiData: {}, currentProtocol: String, syncTabs: Array, projectId: String}, props: {apiData: {}, currentProtocol: String, syncTabs: Array, projectId: String},
methods: { methods: {
handleCommand(e) { handleCommand(e) {
@ -100,169 +101,184 @@ export default {
case "update_api": case "update_api":
return this.updateApi(); return this.updateApi();
case "save_as_api": case "save_as_api":
return this.saveAsApi(); return this.saveAsApi();
default: default:
return this.runTest(); return this.runTest();
} }
}, },
refresh() { refresh() {
this.$emit('refresh'); this.$emit('refresh');
}, },
runTest() { runTest() {
this.loading = true; this.runLoading = true;
this.api.request.name = this.api.id; this.loading = true;
this.api.protocol = this.currentProtocol; this.api.request.name = this.api.id;
this.runData = []; this.api.protocol = this.currentProtocol;
this.runData.push(this.api.request); this.runData = [];
/*触发执行操作*/ this.runData.push(this.api.request);
this.reportId = getUUID().substring(0, 8); /*触发执行操作*/
}, this.reportId = getUUID().substring(0, 8);
runRefresh(data) { },
this.responseData = data; runRefresh(data) {
this.loading = false; this.responseData = data;
}, this.loading = false;
saveAs() { this.runLoading = false;
this.$emit('saveAs', this.api); },
}, errorRefresh() {
loadCase() { this.loading = false;
this.refreshSign = getUUID(); this.runLoading = false;
this.$refs.caseList.open(); },
this.visible = true; saveAs() {
}, this.$emit('saveAs', this.api);
apiCaseClose() { },
this.visible = false; loadCase() {
}, this.refreshSign = getUUID();
getBodyUploadFiles() { this.$refs.caseList.open();
let bodyUploadFiles = []; this.visible = true;
this.api.bodyUploadIds = []; },
let request = this.api.request; apiCaseClose() {
if (request.body) { this.visible = false;
request.body.kvs.forEach(param => { },
if (param.files) { getBodyUploadFiles() {
param.files.forEach(item => { let bodyUploadFiles = [];
if (item.file) { this.api.bodyUploadIds = [];
let fileId = getUUID().substring(0, 8); let request = this.api.request;
item.name = item.file.name; if (request.body) {
item.id = fileId; request.body.kvs.forEach(param => {
this.api.bodyUploadIds.push(fileId); if (param.files) {
bodyUploadFiles.push(item.file); param.files.forEach(item => {
} if (item.file) {
}); let fileId = getUUID().substring(0, 8);
} item.name = item.file.name;
}); item.id = fileId;
} this.api.bodyUploadIds.push(fileId);
return bodyUploadFiles; bodyUploadFiles.push(item.file);
}, }
saveAsCase() { });
//
this.createCase = getUUID();
this.$refs.caseList.open();
this.loaded = false;
},
saveAsApi() {
let data = {};
let req = this.api.request;
req.id = getUUID();
data.request = JSON.stringify(req);
data.method = this.api.method;
data.status = this.api.status;
data.userId = this.api.userId;
data.description = this.api.description;
this.$emit('saveAsApi', data);
this.$emit('refresh');
},
updateApi() {
let url = "/api/definition/update";
let bodyFiles = this.getBodyUploadFiles();
if (Object.prototype.toString.call(this.api.response).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object') {
this.api.response = JSON.parse(this.api.response);
}
if (this.api.tags instanceof Array) {
this.api.tags = JSON.stringify(this.api.tags);
}
this.$fileUpload(url, null, bodyFiles, this.api, () => {
this.$success(this.$t('commons.save_success'));
if (this.syncTabs.indexOf(this.api.id) === -1) {
this.syncTabs.push(this.api.id);
}
this.$emit('saveApi', this.api);
});
},
selectTestCase(item) {
if (item != null) {
this.api.request = item.request;
} else {
this.api.request = this.currentRequest;
}
},
getEnvironments() {
this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data;
this.environments.forEach(environment => {
parseEnvironment(environment);
});
let hasEnvironment = false;
for (let i in this.environments) {
if (this.environments[i].id === this.api.environmentId) {
this.api.environment = this.environments[i];
hasEnvironment = true;
break;
}
}
if (!hasEnvironment) {
this.api.environmentId = '';
this.api.environment = undefined;
} }
}); });
}, }
openEnvironmentConfig() { return bodyUploadFiles;
this.$refs.environmentConfig.open(this.projectId); },
}, saveAsCase() {
environmentChange(value) { //
this.createCase = getUUID();
this.$refs.caseList.open();
this.loaded = false;
},
saveAsApi() {
let data = {};
let req = this.api.request;
req.id = getUUID();
data.request = JSON.stringify(req);
data.method = this.api.method;
data.status = this.api.status;
data.userId = this.api.userId;
data.description = this.api.description;
this.$emit('saveAsApi', data);
this.$emit('refresh');
},
updateApi() {
let url = "/api/definition/update";
let bodyFiles = this.getBodyUploadFiles();
if (Object.prototype.toString.call(this.api.response).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object') {
this.api.response = JSON.parse(this.api.response);
}
if (this.api.tags instanceof Array) {
this.api.tags = JSON.stringify(this.api.tags);
}
this.$fileUpload(url, null, bodyFiles, this.api, () => {
this.$success(this.$t('commons.save_success'));
if (this.syncTabs.indexOf(this.api.id) === -1) {
this.syncTabs.push(this.api.id);
}
this.$emit('saveApi', this.api);
});
},
selectTestCase(item) {
if (item != null) {
this.api.request = item.request;
} else {
this.api.request = this.currentRequest;
}
},
getEnvironments() {
this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data;
this.environments.forEach(environment => {
parseEnvironment(environment);
});
let hasEnvironment = false;
for (let i in this.environments) { for (let i in this.environments) {
if (this.environments[i].id === value) { if (this.environments[i].id === this.api.environmentId) {
this.api.request.useEnvironment = this.environments[i].id; this.api.environment = this.environments[i];
hasEnvironment = true;
break; break;
} }
} }
}, if (!hasEnvironment) {
environmentConfigClose() { this.api.environmentId = '';
this.getEnvironments(); this.api.environment = undefined;
}, }
getResult() { });
if (this.api.id) { },
let url = "/api/definition/report/getReport/" + this.api.id; openEnvironmentConfig() {
this.$get(url, response => { this.$refs.environmentConfig.open(this.projectId);
if (response.data) { },
let data = JSON.parse(response.data.content); environmentChange(value) {
this.responseData = data; for (let i in this.environments) {
} if (this.environments[i].id === value) {
}); this.api.request.useEnvironment = this.environments[i].id;
break;
} }
} }
}, },
created() { environmentConfigClose() {
//
this.api = JSON.parse(JSON.stringify(this.apiData));
this.api.protocol = this.currentProtocol;
this.currentRequest = this.api.request;
this.getEnvironments(); this.getEnvironments();
this.getResult(); },
} getResult() {
if (this.api.id) {
let url = "/api/definition/report/getReport/" + this.api.id;
this.$get(url, response => {
if (response.data) {
let data = JSON.parse(response.data.content);
this.responseData = data;
}
});
}
},
stop() {
let url = "/api/automation/stop/" + this.reportId;
this.$get(url, () => {
this.runLoading = false;
this.loading = false;
this.$success(this.$t('report.test_stop_success'));
});
},
},
created() {
//
this.api = JSON.parse(JSON.stringify(this.apiData));
this.api.protocol = this.currentProtocol;
this.currentRequest = this.api.request;
this.runLoading = false;
this.getEnvironments();
this.getResult();
} }
}
</script> </script>
<style scoped> <style scoped>
.ms-htt-width { .ms-htt-width {
width: 350px; width: 350px;
} }
.environment-button { .environment-button {
margin-left: 20px; margin-left: 20px;
padding: 7px; padding: 7px;
} }
/deep/ .el-drawer { /deep/ .el-drawer {
overflow: auto; overflow: auto;
} }
</style> </style>

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="card-container"> <div class="card-container">
<el-card class="card-content" v-loading="loading"> <el-card class="card-content">
<el-form :model="api" :rules="rules" ref="apiData" :inline="true" label-position="right"> <el-form :model="api" :rules="rules" ref="apiData" :inline="true" label-position="right">
@ -27,7 +27,7 @@
<!-- 操作按钮 --> <!-- 操作按钮 -->
<el-form-item> <el-form-item>
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand('add')" <el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand('add')"
@command="handleCommand" size="small"> @command="handleCommand" size="small" v-if="!runLoading">
{{ $t('commons.test') }} {{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="load_case">{{ $t('api_test.definition.request.load_case') }} <el-dropdown-item command="load_case">{{ $t('api_test.definition.request.load_case') }}
@ -39,6 +39,8 @@
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
<el-button size="small" type="primary" v-else @click.once="stop">{{ $t('report.stop_btn') }}</el-button>
</el-form-item> </el-form-item>
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p> <p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
@ -49,7 +51,7 @@
<!--返回结果--> <!--返回结果-->
<!-- HTTP 请求返回数据 --> <!-- HTTP 请求返回数据 -->
<p class="tip">{{ $t('api_test.definition.request.res_param') }} </p> <p class="tip">{{ $t('api_test.definition.request.res_param') }} </p>
<ms-request-result-tail :response="responseData" ref="runResult"/> <ms-request-result-tail v-loading="loading" :response="responseData" ref="runResult"/>
<ms-jmx-step :request="api.request" :response="responseData"/> <ms-jmx-step :request="api.request" :response="responseData"/>
@ -110,7 +112,8 @@ export default {
}, },
runData: [], runData: [],
reportId: "", reportId: "",
envMap: new Map envMap: new Map,
runLoading: false
} }
}, },
props: {apiData: {}, currentProtocol: String, syncTabs: Array, projectId: String}, props: {apiData: {}, currentProtocol: String, syncTabs: Array, projectId: String},
@ -142,6 +145,7 @@ export default {
runTest() { runTest() {
this.$refs['apiData'].validate((valid) => { this.$refs['apiData'].validate((valid) => {
if (valid) { if (valid) {
this.runLoading = true;
this.loading = true; this.loading = true;
this.api.request.name = this.api.id; this.api.request.name = this.api.id;
this.api.request.url = undefined; this.api.request.url = undefined;
@ -156,6 +160,7 @@ export default {
}, },
errorRefresh() { errorRefresh() {
this.loading = false; this.loading = false;
this.runLoading = false;
}, },
runRefresh(data) { runRefresh(data) {
this.responseData = {type: 'HTTP', responseResult: {responseCode: ""}, subRequestResults: []}; this.responseData = {type: 'HTTP', responseResult: {responseCode: ""}, subRequestResults: []};
@ -163,6 +168,7 @@ export default {
this.responseData = data; this.responseData = data;
} }
this.loading = false; this.loading = false;
this.runLoading = false;
}, },
saveAs() { saveAs() {
this.$emit('saveAs', this.api); this.$emit('saveAs', this.api);
@ -252,7 +258,15 @@ export default {
} }
}); });
} }
} },
stop() {
let url = "/api/automation/stop/" + this.reportId;
this.$get(url, () => {
this.runLoading = false;
this.loading = false;
this.$success(this.$t('report.test_stop_success'));
});
},
}, },
created() { created() {
// //
@ -262,6 +276,7 @@ export default {
if (!this.api.environmentId && this.$store.state.useEnvironment) { if (!this.api.environmentId && this.$store.state.useEnvironment) {
this.api.environmentId = this.$store.state.useEnvironment; this.api.environmentId = this.$store.state.useEnvironment;
} }
this.runLoading = false;
//this.getResult(); //this.getResult();
} }
} }

View File

@ -1,10 +1,10 @@
<template> <template>
<div class="card-container"> <div class="card-container">
<el-card class="card-content" v-loading="loading"> <el-card class="card-content">
<!-- 操作按钮 --> <!-- 操作按钮 -->
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand('add')" <el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand('add')"
@command="handleCommand" size="small" style="float: right;margin-right: 20px"> @command="handleCommand" size="small" style="float: right;margin-right: 20px" v-if="!runLoading">
{{$t('commons.test')}} {{$t('commons.test')}}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="load_case">{{$t('api_test.definition.request.load_case')}} <el-dropdown-item command="load_case">{{$t('api_test.definition.request.load_case')}}
@ -15,7 +15,7 @@
<el-dropdown-item command="save_as_api">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item> <el-dropdown-item command="save_as_api">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
<el-button size="small" type="primary" v-else @click.once="stop" style="float: right;margin-right: 20px">{{ $t('report.stop_btn') }}</el-button>
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p> <p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
<!-- TCP 请求参数 --> <!-- TCP 请求参数 -->
<ms-basis-parameters :request="api.request" @callback="runTest" ref="requestForm"/> <ms-basis-parameters :request="api.request" @callback="runTest" ref="requestForm"/>
@ -23,7 +23,7 @@
<!--返回结果--> <!--返回结果-->
<!-- HTTP 请求返回数据 --> <!-- HTTP 请求返回数据 -->
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p> <p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
<ms-request-result-tail :response="responseData" :currentProtocol="currentProtocol" ref="runResult"/> <ms-request-result-tail :response="responseData" :currentProtocol="currentProtocol" ref="runResult" v-loading="loading"/>
<ms-jmx-step :request="api.request" :response="responseData"/> <ms-jmx-step :request="api.request" :response="responseData"/>
@ -87,6 +87,7 @@ export default {
}, },
runData: [], runData: [],
reportId: "", reportId: "",
runLoading: false
} }
}, },
props: {apiData: {}, currentProtocol: String,syncTabs: Array, projectId: String}, props: {apiData: {}, currentProtocol: String,syncTabs: Array, projectId: String},
@ -110,8 +111,10 @@ export default {
}, },
errorRefresh(){ errorRefresh(){
this.loading = false; this.loading = false;
this.runLoading = false;
}, },
runTest() { runTest() {
this.runLoading = true;
this.loading = true; this.loading = true;
this.api.request.name = this.api.id; this.api.request.name = this.api.id;
this.api.protocol = this.currentProtocol; this.api.protocol = this.currentProtocol;
@ -123,6 +126,7 @@ export default {
runRefresh(data) { runRefresh(data) {
this.responseData = data; this.responseData = data;
this.loading = false; this.loading = false;
this.runLoading = false;
}, },
saveAs() { saveAs() {
this.$emit('saveAs', this.api); this.$emit('saveAs', this.api);
@ -241,13 +245,22 @@ export default {
} }
}); });
} }
} },
stop() {
let url = "/api/automation/stop/" + this.reportId;
this.$get(url, () => {
this.runLoading = false;
this.loading = false;
this.$success(this.$t('report.test_stop_success'));
});
},
}, },
created() { created() {
// //
this.api = JSON.parse(JSON.stringify(this.apiData)); this.api = JSON.parse(JSON.stringify(this.apiData));
this.api.protocol = this.currentProtocol; this.api.protocol = this.currentProtocol;
this.currentRequest = this.api.request; this.currentRequest = this.api.request;
this.runLoading = false;
this.getEnvironments(); this.getEnvironments();
this.getResult(); this.getResult();
} }

View File

@ -1,13 +1,13 @@
<template> <template>
<div class="card-container"> <div class="card-container">
<el-card class="card-content" v-loading="loading"> <el-card class="card-content">
<el-form :model="api" :rules="rules" ref="apiData" :inline="true" label-position="right"> <el-form :model="api" :rules="rules" ref="apiData" :inline="true" label-position="right">
<!-- 操作按钮 --> <!-- 操作按钮 -->
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand('add')" <el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand('add')"
@command="handleCommand" size="small" style="float: right;margin-right: 20px"> @command="handleCommand" size="small" style="float: right;margin-right: 20px" v-if="!runLoading">
{{$t('commons.test')}} {{$t('commons.test')}}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="load_case">{{$t('api_test.definition.request.load_case')}} <el-dropdown-item command="load_case">{{$t('api_test.definition.request.load_case')}}
@ -18,6 +18,7 @@
<el-dropdown-item command="save_as_api">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item> <el-dropdown-item command="save_as_api">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
<el-button size="small" type="primary" v-else @click.once="stop" style="float: right;margin-right: 20px">{{ $t('report.stop_btn') }}</el-button>
<p class="tip">{{$t('test_track.plan_view.base_info')}} </p> <p class="tip">{{$t('test_track.plan_view.base_info')}} </p>
<!-- 执行环境 --> <!-- 执行环境 -->
@ -38,7 +39,7 @@
<!--返回结果--> <!--返回结果-->
<!-- HTTP 请求返回数据 --> <!-- HTTP 请求返回数据 -->
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p> <p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
<ms-request-result-tail :response="responseData" ref="runResult"/> <ms-request-result-tail :response="responseData" ref="runResult" v-loading="loading"/>
</div> </div>
<div v-else-if="api.method=='ESB'"> <div v-else-if="api.method=='ESB'">
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p> <p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
@ -62,7 +63,7 @@
<!-- 执行组件 --> <!-- 执行组件 -->
<ms-run :debug="false" :environment="api.environment" :reportId="reportId" :run-data="runData" <ms-run :debug="false" :environment="api.environment" :reportId="reportId" :run-data="runData"
@runRefresh="runRefresh" ref="runTest"/> @runRefresh="runRefresh" @errorRefresh="errorRefresh" ref="runTest"/>
</div> </div>
</template> </template>
@ -115,6 +116,7 @@ export default {
runData: [], runData: [],
reportId: "", reportId: "",
showXpackCompnent:false, showXpackCompnent:false,
runLoading: false
} }
}, },
props: {apiData: {}, currentProtocol: String,syncTabs: Array, projectId: String}, props: {apiData: {}, currentProtocol: String,syncTabs: Array, projectId: String},
@ -139,6 +141,7 @@ export default {
runTest() { runTest() {
this.$refs['apiData'].validate((valid) => { this.$refs['apiData'].validate((valid) => {
if (valid) { if (valid) {
this.runLoading = true;
this.loading = true; this.loading = true;
this.api.request.name = this.api.id; this.api.request.name = this.api.id;
this.api.protocol = this.currentProtocol; this.api.protocol = this.currentProtocol;
@ -152,6 +155,11 @@ export default {
runRefresh(data) { runRefresh(data) {
this.responseData = data; this.responseData = data;
this.loading = false; this.loading = false;
this.runLoading = false;
},
errorRefresh() {
this.loading = false;
this.runLoading = false;
}, },
saveAs() { saveAs() {
this.$emit('saveAs', this.api); this.$emit('saveAs', this.api);
@ -238,13 +246,22 @@ export default {
this.responseData = data; this.responseData = data;
} }
}); });
} },
stop() {
let url = "/api/automation/stop/" + this.reportId;
this.$get(url, () => {
this.runLoading = false;
this.loading = false;
this.$success(this.$t('report.test_stop_success'));
});
},
}, },
created() { created() {
// //
this.api = JSON.parse(JSON.stringify(this.apiData)); this.api = JSON.parse(JSON.stringify(this.apiData));
this.api.protocol = this.currentProtocol; this.api.protocol = this.currentProtocol;
this.currentRequest = this.api.request; this.currentRequest = this.api.request;
this.runLoading = false;
this.getResult(); this.getResult();
if (requireComponent != null && JSON.stringify(esbDefinition) !== '{}') { if (requireComponent != null && JSON.stringify(esbDefinition) !== '{}') {
this.showXpackCompnent = true; this.showXpackCompnent = true;