fix(接口测试): 修复非http的更新用例跳转出现的模块树不是对应的请求类型以及接口中的模块查询不出来的缺陷

--bug=1016214 --user=宋天阳 【接口测试】首页-过去7天有更新的接口跳转链接页面显示模块信息为空。
https://www.tapd.cn/55049933/s/1234369
This commit is contained in:
song-tianyang 2022-08-26 11:57:47 +08:00 committed by 建国
parent af91f9efc6
commit ca1429c45e
4 changed files with 353 additions and 282 deletions

View File

@ -4,6 +4,8 @@
<ms-aside-container> <ms-aside-container>
<ms-api-module <ms-api-module
:show-operator="true" :show-operator="true"
:default-protocol="defaultProtocol"
:select-default-protocol="isSelectDefaultProtocol"
@nodeSelectEvent="nodeChange" @nodeSelectEvent="nodeChange"
@protocolChange="handleProtocolChange" @protocolChange="handleProtocolChange"
@refreshTable="refresh" @refreshTable="refresh"
@ -180,7 +182,6 @@
@changeSelectDataRangeAll="changeSelectDataRangeAll" @changeSelectDataRangeAll="changeSelectDataRangeAll"
@handleCase="handleCase" @handleCase="handleCase"
@showExecResult="showExecResult" @showExecResult="showExecResult"
v-if="moduleOptions && moduleOptions.length > 0"
ref="apiConfig" ref="apiConfig"
/> />
</div> </div>
@ -284,6 +285,34 @@ export default {
projectId() { projectId() {
return getCurrentProjectID(); return getCurrentProjectID();
}, },
isSelectDefaultProtocol() {
let selectDefaultProtocol = true;
let routeParamObj = this.$route.params.paramObj;
if (routeParamObj) {
let dataRange = routeParamObj.dataSelectRange;
let dataType = routeParamObj.dataType;
if (dataRange && typeof dataRange === 'string') {
let selectParamArr = dataRange.split("edit:");
if (selectParamArr.length === 2) {
if (dataType === 'api') {
selectDefaultProtocol = false;
}
}
}
} else {
let dataRange = this.$route.params.dataSelectRange;
let dataType = this.$route.params.dataType;
if (dataRange && typeof dataRange === 'string') {
let selectParamArr = dataRange.split("edit:");
if (selectParamArr.length === 2) {
if (dataType === 'api') {
selectDefaultProtocol = false;
}
}
}
}
return selectDefaultProtocol;
},
}, },
components: { components: {
'VersionSelect': VersionSelect.default, 'VersionSelect': VersionSelect.default,
@ -331,6 +360,7 @@ export default {
selectNodeIds: [], selectNodeIds: [],
currentApi: {}, currentApi: {},
moduleOptions: [], moduleOptions: [],
defaultProtocol: null,
trashEnable: false, trashEnable: false,
apiTabs: [{ apiTabs: [{
title: this.$t('api_test.definition.api_title'), title: this.$t('api_test.definition.api_title'),
@ -765,6 +795,7 @@ export default {
let scenarioId = selectParamArr[1]; let scenarioId = selectParamArr[1];
if (dataType === 'api') { if (dataType === 'api') {
this.$get('/api/definition/get/' + scenarioId, (response) => { this.$get('/api/definition/get/' + scenarioId, (response) => {
this.defaultProtocol = response.data.protocol;
this.editApi(response.data); this.editApi(response.data);
}); });
} }
@ -779,6 +810,7 @@ export default {
let scenarioId = selectParamArr[1]; let scenarioId = selectParamArr[1];
if (dataType === 'api') { if (dataType === 'api') {
this.$get('/api/definition/get/' + scenarioId, (response) => { this.$get('/api/definition/get/' + scenarioId, (response) => {
this.defaultProtocol = response.data.protocol;
this.editApi(response.data); this.editApi(response.data);
}); });
} }

View File

@ -1,6 +1,7 @@
<template> <template>
<div v-loading="loading"> <div v-loading="loading">
<el-form :model="basicForm" label-position="right" label-width="80px" size="small" :rules="rule" ref="basicForm" style="margin-right: 20px" :disabled="isReadOnly"> <el-form :model="basicForm" label-position="right" label-width="80px" size="small" :rules="rule" ref="basicForm"
style="margin-right: 20px" :disabled="isReadOnly">
<!-- 基础信息 --> <!-- 基础信息 -->
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
@ -10,7 +11,8 @@
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item :label="$t('test_track.module.module')" prop="moduleId"> <el-form-item :label="$t('test_track.module.module')" prop="moduleId">
<ms-select-tree size="small" :data="moduleOptions" :defaultKey="basicForm.moduleId" @getValue="setModule" :obj="moduleObj" clearable checkStrictly/> <ms-select-tree size="small" :data="moduleOptions" :defaultKey="basicForm.moduleId" @getValue="setModule"
:obj="moduleObj" clearable checkStrictly/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
@ -57,12 +59,12 @@
</template> </template>
<script> <script>
import {API_STATUS} from "../../model/JsonData"; import {API_STATUS} from "../../model/JsonData";
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag"; import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
import MsSelectTree from "../../../../common/select-tree/SelectTree"; import MsSelectTree from "../../../../common/select-tree/SelectTree";
import {getProjectMemberOption} from "@/network/user"; import {getProjectMemberOption} from "@/network/user";
export default { export default {
name: "MsBasisApi", name: "MsBasisApi",
components: {MsInputTag, MsSelectTree}, components: {MsInputTag, MsSelectTree},
props: { props: {
@ -72,7 +74,7 @@
}, },
moduleOptions: Array, moduleOptions: Array,
basisData: {}, basisData: {},
isReadOnly:{ isReadOnly: {
type: Boolean, type: Boolean,
default: false default: false
}, },
@ -121,6 +123,14 @@
} }
} }
}, },
moduleOptions: {
handler(v, v1) {
if (!this.basicForm.moduleId) {
this.basicForm.moduleId = this.basisData.moduleId;
}
},
deep: true
},
}, },
created() { created() {
this.getMaintainerOptions(); this.getMaintainerOptions();
@ -182,9 +192,13 @@
this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus); this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus);
}) })
}, },
setModule(id,data) { setModule(id, data) {
this.basicForm.moduleId = id; if (data) {
this.basisData.modulePath = data.path; this.basisData.modulePath = data.path;
}
if (id) {
this.basicForm.moduleId = id;
}
}, },
validate() { validate() {
this.$refs['basicForm'].validate((valid) => { this.$refs['basicForm'].validate((valid) => {
@ -198,7 +212,7 @@
this.$emit("createRootModelInTree"); this.$emit("createRootModelInTree");
}, },
} }
} }
</script> </script>
<style scoped> <style scoped>

View File

@ -1,13 +1,15 @@
<template> <template>
<div v-loading="loading"> <div v-loading="loading">
<el-form :model="basicForm" label-position="right" label-width="80px" size="small" :rules="rule" ref="basicForm" style="margin-right: 20px" :disabled="isDiff"> <el-form :model="basicForm" label-position="right" label-width="80px" size="small" :rules="rule" ref="basicForm"
style="margin-right: 20px" :disabled="isDiff">
<!-- 基础信息 --> <!-- 基础信息 -->
<el-row> <el-row>
<el-col :span="isDiff?16:8"> <el-col :span="isDiff?16:8">
<el-form-item :label="$t('commons.name')" prop="name"> <el-form-item :label="$t('commons.name')" prop="name">
<!-- <el-input class="ms-http-input" size="small" v-model="basicForm.name"/>--> <!-- <el-input class="ms-http-input" size="small" v-model="basicForm.name"/>-->
<el-input v-model="basicForm.name" class="ms-http-input" size="small"> <el-input v-model="basicForm.name" class="ms-http-input" size="small">
<el-select v-model="basicForm.method" slot="prepend" style="width: 100px" size="small" @change="methodChange"> <el-select v-model="basicForm.method" slot="prepend" style="width: 100px" size="small"
@change="methodChange">
<el-option v-for="item in methodTypes" :key="item.key" :label="item.value" :value="item.key"/> <el-option v-for="item in methodTypes" :key="item.key" :label="item.value" :value="item.key"/>
</el-select> </el-select>
</el-input> </el-input>
@ -16,7 +18,9 @@
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item :label="$t('test_track.module.module')" prop="moduleId"> <el-form-item :label="$t('test_track.module.module')" prop="moduleId">
<ms-select-tree size="small" :data="moduleOptions" :defaultKey="basicForm.moduleId" @getValue="setModule" :obj="moduleObj" clearable checkStrictly/> <ms-select-tree size="small" :data="moduleOptions"
:defaultKey="basicForm.moduleId" @getValue="setModule"
:obj="moduleObj" clearable checkStrictly/>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -64,12 +68,12 @@
</template> </template>
<script> <script>
import {API_STATUS} from "../../model/JsonData"; import {API_STATUS} from "../../model/JsonData";
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag"; import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
import MsSelectTree from "../../../../common/select-tree/SelectTree"; import MsSelectTree from "../../../../common/select-tree/SelectTree";
import {getProjectMemberOption} from "@/network/user"; import {getProjectMemberOption} from "@/network/user";
export default { export default {
name: "MsTcpBasicApi", name: "MsTcpBasicApi",
components: {MsInputTag, MsSelectTree}, components: {MsInputTag, MsSelectTree},
props: { props: {
@ -80,7 +84,7 @@
moduleOptions: Array, moduleOptions: Array,
methodTypes: Array, methodTypes: Array,
basisData: {}, basisData: {},
isDiff:{ isDiff: {
type: Boolean, type: Boolean,
default: false default: false
}, },
@ -145,10 +149,12 @@
}, },
'basicForm.moduleId': { 'basicForm.moduleId': {
handler(v, v1) { handler(v, v1) {
if (this.basicForm.moduleId) {
if (v && v1 && v !== v1) { if (v && v1 && v !== v1) {
this.apiMapStatus(); this.apiMapStatus();
} }
} }
}
}, },
'basicForm.status': { 'basicForm.status': {
handler(v, v1) { handler(v, v1) {
@ -179,6 +185,14 @@
} }
} }
}, },
moduleOptions: {
handler(v, v1) {
if (!this.basicForm.moduleId) {
this.basicForm.moduleId = this.basisData.moduleId;
}
},
deep: true
}
}, },
methods: { methods: {
apiMapStatus() { apiMapStatus() {
@ -212,12 +226,16 @@
methodChange() { methodChange() {
this.$emit("changeApiProtocol", this.basicForm.method); this.$emit("changeApiProtocol", this.basicForm.method);
}, },
setModule(id,data) { setModule(id, data) {
if (data) {
this.basisData.modulePath = data.path; this.basisData.modulePath = data.path;
}
if (id) {
this.basisData.moduleId = id; this.basisData.moduleId = id;
}
}, },
} }
} }
</script> </script>
<style scoped> <style scoped>

View File

@ -88,6 +88,7 @@ export default {
return false; return false;
} }
}, },
defaultProtocol: String,
showCaseNum: { showCaseNum: {
type: Boolean, type: Boolean,
default() { default() {
@ -106,6 +107,7 @@ export default {
relevanceProjectId: String, relevanceProjectId: String,
reviewId: String, reviewId: String,
pageSource: String, pageSource: String,
selectDefaultProtocol: Boolean,
total: Number, total: Number,
isRelevance: Boolean, isRelevance: Boolean,
options: { options: {
@ -156,6 +158,11 @@ export default {
isTrashData() { isTrashData() {
this.condition.trashEnable = this.isTrashData; this.condition.trashEnable = this.isTrashData;
this.list(); this.list();
},
defaultProtocol() {
if (this.condition.protocol !== this.defaultProtocol) {
this.condition.protocol = this.defaultProtocol;
}
} }
}, },
methods: { methods: {
@ -166,7 +173,7 @@ export default {
this.condition.protocol = this.$route.params.type; this.condition.protocol = this.$route.params.type;
this.$emit('protocolChange', this.condition.protocol); this.$emit('protocolChange', this.condition.protocol);
this.list(); this.list();
} else if (!this.isRelevance && !isRedirectPage) { } else if (!this.isRelevance && !isRedirectPage && this.selectDefaultProtocol) {
// //
this.$get('/api/module/getUserDefaultApiType/', response => { this.$get('/api/module/getUserDefaultApiType/', response => {
this.condition.protocol = response.data; this.condition.protocol = response.data;