refactor(接口自动化): 优化场景步骤调试结果

This commit is contained in:
fit2-zhao 2021-01-22 10:51:43 +08:00
parent 7326f2409e
commit b01c6930cb
2 changed files with 30 additions and 16 deletions

View File

@ -11,11 +11,11 @@
:title="displayTitle"> :title="displayTitle">
<template v-slot:behindHeaderLeft> <template v-slot:behindHeaderLeft>
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag> <el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag> <el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag> <el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
<ms-run :debug="false" :reportId="reportId" :run-data="runData" <ms-run :debug="false" :reportId="reportId" :run-data="runData"
@runRefresh="runRefresh" ref="runTest"/> @runRefresh="runRefresh" ref="runTest"/>
</template> </template>
@ -42,7 +42,7 @@
<ms-dubbo-basis-parameters :request="request" v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'" :showScript="false"/> <ms-dubbo-basis-parameters :request="request" v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'" :showScript="false"/>
<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 draggable :currentProtocol="request.protocol" :response="request.requestResult" ref="runResult"/> <api-response-component :result="request.requestResult"/>
<!-- 保存操作 --> <!-- 保存操作 -->
<el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(item)" v-if="!request.referenced"> <el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(item)" v-if="!request.referenced">
@ -62,6 +62,8 @@
import MsRun from "../../../definition/components/Run"; import MsRun from "../../../definition/components/Run";
import {getUUID} from "@/common/js/utils"; import {getUUID} from "@/common/js/utils";
import ApiBaseComponent from "../common/ApiBaseComponent"; import ApiBaseComponent from "../common/ApiBaseComponent";
import ApiResponseComponent from "./ApiResponseComponent";
export default { export default {
name: "MsApiComponent", name: "MsApiComponent",
props: { props: {
@ -75,8 +77,9 @@
currentEnvironmentId: String, currentEnvironmentId: String,
}, },
components: { components: {
ApiBaseComponent, ApiBaseComponent, ApiResponseComponent,
MsSqlBasisParameters, MsTcpBasisParameters, MsDubboBasisParameters, MsApiRequestForm, MsRequestResultTail, MsRun}, MsSqlBasisParameters, MsTcpBasisParameters, MsDubboBasisParameters, MsApiRequestForm, MsRequestResultTail, MsRun
},
data() { data() {
return { return {
loading: false, loading: false,
@ -129,31 +132,31 @@
return this.$t('api_test.automation.api_list_import'); return this.$t('api_test.automation.api_list_import');
} else if (this.isExternalImport) { } else if (this.isExternalImport) {
return this.$t('api_test.automation.external_import'); return this.$t('api_test.automation.external_import');
} else if(this.isCustomizeReq) { } else if (this.isCustomizeReq) {
return this.$t('api_test.automation.customize_req'); return this.$t('api_test.automation.customize_req');
} }
return ""; return "";
}, },
isApiImport() { isApiImport() {
if (this.request.referenced!=undefined && this.request.referenced==='Deleted' || this.request.referenced=='REF' || this.request.referenced==='Copy') { if (this.request.referenced != undefined && this.request.referenced === 'Deleted' || this.request.referenced == 'REF' || this.request.referenced === 'Copy') {
return true return true
} }
return false; return false;
}, },
isExternalImport() { isExternalImport() {
if (this.request.referenced!=undefined && this.request.referenced==='OT_IMPORT') { if (this.request.referenced != undefined && this.request.referenced === 'OT_IMPORT') {
return true return true
} }
return false; return false;
}, },
isCustomizeReq() { isCustomizeReq() {
if (this.request.referenced==undefined || this.request.referenced==='Created') { if (this.request.referenced == undefined || this.request.referenced === 'Created') {
return true return true
} }
return false; return false;
}, },
isDeletedOrRef() { isDeletedOrRef() {
if (this.request.referenced!= undefined && this.request.referenced === 'Deleted' || this.request.referenced === 'REF') { if (this.request.referenced != undefined && this.request.referenced === 'Deleted' || this.request.referenced === 'REF') {
return true return true
} }
return false; return false;
@ -218,6 +221,7 @@
this.$error(this.$t('api_test.environment.select_environment')); this.$error(this.$t('api_test.environment.select_environment'));
return; return;
} }
this.request.active = true;
this.loading = true; this.loading = true;
this.runData = []; this.runData = [];
this.request.useEnvironment = this.currentEnvironmentId; this.request.useEnvironment = this.currentEnvironmentId;
@ -250,9 +254,11 @@
margin-right: 20px; margin-right: 20px;
color: #409EFF; color: #409EFF;
} }
/deep/ .el-card__body { /deep/ .el-card__body {
padding: 15px; padding: 15px;
} }
.tip { .tip {
padding: 3px 5px; padding: 3px 5px;
font-size: 16px; font-size: 16px;
@ -260,12 +266,15 @@
border-left: 4px solid #783887; border-left: 4px solid #783887;
margin: 20px 0; margin: 20px 0;
} }
.name-input { .name-input {
width: 30%; width: 30%;
} }
.el-icon-arrow-right { .el-icon-arrow-right {
margin-right: 5px; margin-right: 5px;
} }
.icon.is-active { .icon.is-active {
transform: rotate(90deg); transform: rotate(90deg);
} }

View File

@ -24,7 +24,7 @@
export default { export default {
name: "ApiResponseComponent", name: "ApiResponseComponent",
components: {ElCollapseTransition, MsRequestResultTail, ApiBaseComponent, MsRequestMetric}, components: {ElCollapseTransition, MsRequestResultTail, ApiBaseComponent, MsRequestMetric},
props: ['apiItem'], props: {apiItem: {}, result: {}},
data() { data() {
return { return {
isActive: false, isActive: false,
@ -32,8 +32,13 @@
} }
}, },
created() { created() {
this.getExecResult(); if (!this.result) {
if (this.apiItem.isActive) { this.getExecResult();
if (this.apiItem.isActive) {
this.isActive = true;
}
} else {
this.response = this.result;
this.isActive = true; this.isActive = true;
} }
}, },