This commit is contained in:
chenjianxing 2021-01-13 16:04:27 +08:00
commit 2dee505e53
2 changed files with 245 additions and 209 deletions

View File

@ -13,4 +13,5 @@ public class ApiTestCaseResult extends ApiTestCaseWithBLOBs {
private String execResult; private String execResult;
private Long execTime; private Long execTime;
private boolean active = false; private boolean active = false;
private boolean responseActive = false;
} }

View File

@ -71,6 +71,17 @@
<ms-tcp-basis-parameters :request="apiCase.request" v-if="api.protocol==='TCP'"/> <ms-tcp-basis-parameters :request="apiCase.request" v-if="api.protocol==='TCP'"/>
<ms-sql-basis-parameters :request="apiCase.request" v-if="api.protocol==='SQL'"/> <ms-sql-basis-parameters :request="apiCase.request" v-if="api.protocol==='SQL'"/>
<ms-dubbo-basis-parameters :request="apiCase.request" v-if="api.protocol==='DUBBO'"/> <ms-dubbo-basis-parameters :request="apiCase.request" v-if="api.protocol==='DUBBO'"/>
<!-- HTTP 请求返回数据 -->
<p class="tip">
{{$t('api_test.definition.request.res_param')}}
<i class="icon el-icon-arrow-right" :class="{'is-responseActive': apiCase.responseActive}" @click="responseActive(apiCase)"/>
</p>
<el-collapse-transition>
<div v-if="apiCase.responseActive">
<ms-request-result-tail :response="responseData"/>
</div>
</el-collapse-transition>
<!-- 保存操作 --> <!-- 保存操作 -->
<el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(apiCase)" v-tester> <el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(apiCase)" v-tester>
{{ $t('commons.save') }} {{ $t('commons.save') }}
@ -81,20 +92,21 @@
</template> </template>
<script> <script>
import {getCurrentProjectID, getUUID} from "../../../../../../common/js/utils"; import {getCurrentProjectID, getUUID} from "../../../../../../common/js/utils";
import {PRIORITY, RESULT_MAP} from "../../model/JsonData"; import {PRIORITY, RESULT_MAP} from "../../model/JsonData";
import MsTag from "../../../../common/components/MsTag"; import MsTag from "../../../../common/components/MsTag";
import MsTipButton from "../../../../common/components/MsTipButton"; import MsTipButton from "../../../../common/components/MsTipButton";
import MsApiRequestForm from "../request/http/ApiRequestForm"; import MsApiRequestForm from "../request/http/ApiRequestForm";
import ApiEnvironmentConfig from "../environment/ApiEnvironmentConfig"; import ApiEnvironmentConfig from "../environment/ApiEnvironmentConfig";
import MsApiAssertions from "../assertion/ApiAssertions"; import MsApiAssertions from "../assertion/ApiAssertions";
import MsSqlBasisParameters from "../request/database/BasisParameters"; import MsSqlBasisParameters from "../request/database/BasisParameters";
import MsTcpBasisParameters from "../request/tcp/TcpBasisParameters"; import MsTcpBasisParameters from "../request/tcp/TcpBasisParameters";
import MsDubboBasisParameters from "../request/dubbo/BasisParameters"; import MsDubboBasisParameters from "../request/dubbo/BasisParameters";
import MsApiExtendBtns from "../reference/ApiExtendBtns"; import MsApiExtendBtns from "../reference/ApiExtendBtns";
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag"; import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
import MsRequestResultTail from "../response/RequestResultTail";
export default { export default {
name: "ApiCaseItem", name: "ApiCaseItem",
components: { components: {
MsInputTag, MsInputTag,
@ -106,7 +118,8 @@ export default {
MsSqlBasisParameters, MsSqlBasisParameters,
MsTcpBasisParameters, MsTcpBasisParameters,
MsDubboBasisParameters, MsDubboBasisParameters,
MsApiExtendBtns MsApiExtendBtns,
MsRequestResultTail
}, },
data() { data() {
return { return {
@ -120,6 +133,7 @@ export default {
checkedCases: new Set(), checkedCases: new Set(),
visible: false, visible: false,
condition: {}, condition: {},
responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []},
isShowInput: false, isShowInput: false,
} }
}, },
@ -128,7 +142,7 @@ export default {
type: Object, type: Object,
default() { default() {
return {} return {}
} },
}, },
environment: {}, environment: {},
index: { index: {
@ -147,7 +161,6 @@ export default {
}, },
watch: {}, watch: {},
methods: { methods: {
deleteCase(index, row) { deleteCase(index, row) {
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + row.name + " ", '', { this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + row.name + " ", '', {
confirmButtonText: this.$t('commons.confirm'), confirmButtonText: this.$t('commons.confirm'),
@ -162,6 +175,18 @@ export default {
}); });
}, },
getExecResult() {
//
if (this.apiCase) {
let url = "/api/definition/report/getReport/" + this.apiCase.id;
this.$get(url, response => {
if (response.data) {
let data = JSON.parse(response.data.content);
this.responseData = data;
}
});
}
},
singleRun(data) { singleRun(data) {
this.$emit('singleRun', data); this.$emit('singleRun', data);
}, },
@ -228,6 +253,12 @@ export default {
active(item) { active(item) {
item.active = !item.active; item.active = !item.active;
}, },
responseActive(item) {
item.responseActive = !item.responseActive;
if (item.responseActive) {
this.getExecResult();
}
},
getResult(data) { getResult(data) {
if (RESULT_MAP.get(data)) { if (RESULT_MAP.get(data)) {
return RESULT_MAP.get(data); return RESULT_MAP.get(data);
@ -281,44 +312,48 @@ export default {
return bodyUploadFiles; return bodyUploadFiles;
}, },
} }
} }
</script> </script>
<style scoped> <style scoped>
.ms-api-select { .ms-api-select {
margin-left: 20px; margin-left: 20px;
width: 80px; width: 80px;
} }
.ms-api-header-select { .ms-api-header-select {
margin-left: 20px; margin-left: 20px;
min-width: 100px; min-width: 100px;
} }
.ms-api-label { .ms-api-label {
color: #CCCCCC; color: #CCCCCC;
} }
.ms-api-col { .ms-api-col {
background-color: #7C3985; background-color: #7C3985;
border-color: #7C3985; border-color: #7C3985;
margin-right: 10px; margin-right: 10px;
color: white; color: white;
} }
.icon.is-active { .icon.is-active {
transform: rotate(90deg); transform: rotate(90deg);
} }
.tip { .icon.is-responseActive {
transform: rotate(90deg);
}
.tip {
padding: 3px 5px; padding: 3px 5px;
font-size: 16px; font-size: 16px;
border-radius: 4px; border-radius: 4px;
border-left: 4px solid #783887; border-left: 4px solid #783887;
margin: 20px 0; margin: 20px 0;
} }
.is-selected { .is-selected {
background: #EFF7FF; background: #EFF7FF;
} }
</style> </style>