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 af7d10a8bb
commit 3a7c9540d6
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,148 +59,160 @@
</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: {
currentProtocol: { currentProtocol: {
type: String, type: String,
default: "HTTP" default: "HTTP"
},
moduleOptions: Array,
basisData: {},
isReadOnly:{
type: Boolean,
default: false
},
}, },
watch: { moduleOptions: Array,
'basicForm.name': { basisData: {},
handler(v, v1) { isReadOnly: {
if (v && v1 && v !== v1) { type: Boolean,
this.apiMapStatus(); default: false
}
}
},
'basicForm.moduleId': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.status': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.follows': {
handler(v, v1) {
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1)) {
this.apiMapStatus();
}
}
},
'basicForm.description': {
handler(v, v1) {
if (v && v1 !== undefined && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.tags': {
handler(v, v1) {
this.tagCount++;
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1) && this.tagCount > 1) {
this.apiMapStatus();
}
}
},
}, },
created() { },
this.getMaintainerOptions(); watch: {
this.basicForm = this.basisData; 'basicForm.name': {
this.$get('/api/definition/follow/' + this.basisData.id, response => { handler(v, v1) {
this.basicForm.follows = response.data; if (v && v1 && v !== v1) {
}); this.apiMapStatus();
},
data() {
let validateModuleId = (rule, value, callback) => {
if (this.basicForm.moduleId.length === 0 || !this.basicForm.moduleId) {
callback(this.$t('test_track.case.input_module'));
} else {
callback();
} }
};
return {
basicForm: {},
httpVisible: false,
currentModule: {},
maintainerOptions: [],
moduleObj: {
id: 'id',
label: 'name',
},
loading: false,
rule: {
name: [
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
],
userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
moduleId: [{required: true, validator: validateModuleId, trigger: 'change'}],
status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
},
value: API_STATUS[0].id,
options: API_STATUS,
tagCount: 0
} }
}, },
methods: { 'basicForm.moduleId': {
apiMapStatus() { handler(v, v1) {
this.$store.state.apiStatus.set("fromChange", true); if (v && v1 && v !== v1) {
if (this.basicForm.id) { this.apiMapStatus();
this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus); }
}
},
'basicForm.status': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.follows': {
handler(v, v1) {
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1)) {
this.apiMapStatus();
}
}
},
'basicForm.description': {
handler(v, v1) {
if (v && v1 !== undefined && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.tags': {
handler(v, v1) {
this.tagCount++;
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1) && this.tagCount > 1) {
this.apiMapStatus();
}
}
},
moduleOptions: {
handler(v, v1) {
if (!this.basicForm.moduleId) {
this.basicForm.moduleId = this.basisData.moduleId;
} }
}, },
getMaintainerOptions() { deep: true
getProjectMemberOption(data => { },
this.maintainerOptions = data; },
}); created() {
this.getMaintainerOptions();
this.basicForm = this.basisData;
this.$get('/api/definition/follow/' + this.basisData.id, response => {
this.basicForm.follows = response.data;
});
},
data() {
let validateModuleId = (rule, value, callback) => {
if (this.basicForm.moduleId.length === 0 || !this.basicForm.moduleId) {
callback(this.$t('test_track.case.input_module'));
} else {
callback();
}
};
return {
basicForm: {},
httpVisible: false,
currentModule: {},
maintainerOptions: [],
moduleObj: {
id: 'id',
label: 'name',
}, },
reload() { loading: false,
this.loading = true rule: {
this.$nextTick(() => { name: [
this.loading = false; {required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
this.$store.state.apiStatus.set("fromChange", false); {max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus); ],
}) userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
}, moduleId: [{required: true, validator: validateModuleId, trigger: 'change'}],
setModule(id,data) { status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
this.basicForm.moduleId = id;
this.basisData.modulePath = data.path;
},
validate() {
this.$refs['basicForm'].validate((valid) => {
if (valid) {
this.$emit('callback');
}
})
this.tagCount = 0;
},
createModules() {
this.$emit("createRootModelInTree");
}, },
value: API_STATUS[0].id,
options: API_STATUS,
tagCount: 0
} }
},
methods: {
apiMapStatus() {
this.$store.state.apiStatus.set("fromChange", true);
if (this.basicForm.id) {
this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus);
}
},
getMaintainerOptions() {
getProjectMemberOption(data => {
this.maintainerOptions = data;
});
},
reload() {
this.loading = true
this.$nextTick(() => {
this.loading = false;
this.$store.state.apiStatus.set("fromChange", false);
this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus);
})
},
setModule(id, data) {
if (data) {
this.basisData.modulePath = data.path;
}
if (id) {
this.basicForm.moduleId = id;
}
},
validate() {
this.$refs['basicForm'].validate((valid) => {
if (valid) {
this.$emit('callback');
}
})
this.tagCount = 0;
},
createModules() {
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,160 +68,174 @@
</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: {
currentProtocol: { currentProtocol: {
type: String, type: String,
default: "HTTP" default: "HTTP"
},
moduleOptions: Array,
methodTypes: Array,
basisData: {},
isDiff:{
type: Boolean,
default: false
},
}, },
created() { moduleOptions: Array,
this.getMaintainerOptions(); methodTypes: Array,
this.basicForm = this.basisData; basisData: {},
if (this.basicForm.protocol == null) { isDiff: {
this.basicForm.protocol = "TCP"; type: Boolean,
default: false
},
},
created() {
this.getMaintainerOptions();
this.basicForm = this.basisData;
if (this.basicForm.protocol == null) {
this.basicForm.protocol = "TCP";
}
this.$get('/api/definition/follow/' + this.basisData.id, response => {
this.basicForm.follows = response.data;
});
},
data() {
let validateModuleId = (rule, value, callback) => {
if (this.basicForm.moduleId.length === 0 || !this.basicForm.moduleId) {
callback(this.$t('test_track.case.input_module'));
} else {
callback();
} }
this.$get('/api/definition/follow/' + this.basisData.id, response => { };
this.basicForm.follows = response.data; return {
basicForm: {},
httpVisible: false,
currentModule: {},
maintainerOptions: [],
loading: false,
rule: {
name: [
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
],
userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
moduleId: [{required: true, validator: validateModuleId, trigger: 'change'}],
status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
},
value: API_STATUS[0].id,
options: API_STATUS,
moduleObj: {
id: 'id',
label: 'name',
},
tagCount: 0
}
},
watch: {
'basicForm.name': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.userId': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.moduleId': {
handler(v, v1) {
if (this.basicForm.moduleId) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
}
},
'basicForm.status': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.follows': {
handler(v, v1) {
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1)) {
this.apiMapStatus();
}
}
},
'basicForm.description': {
handler(v, v1) {
if (v && v1 !== undefined && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.tags': {
handler(v, v1) {
this.tagCount++;
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1) && this.tagCount > 1) {
this.apiMapStatus();
}
}
},
moduleOptions: {
handler(v, v1) {
if (!this.basicForm.moduleId) {
this.basicForm.moduleId = this.basisData.moduleId;
}
},
deep: true
}
},
methods: {
apiMapStatus() {
this.$store.state.apiStatus.set("fromChange", true);
if (this.basicForm.id) {
this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus);
}
},
getMaintainerOptions() {
getProjectMemberOption(data => {
this.maintainerOptions = data;
}); });
}, },
data() { reload() {
let validateModuleId = (rule, value, callback) => { this.loading = true
if (this.basicForm.moduleId.length === 0 || !this.basicForm.moduleId) { this.$nextTick(() => {
callback(this.$t('test_track.case.input_module')); this.loading = false
} else { })
callback(); },
validate() {
this.$refs['basicForm'].validate((valid) => {
if (valid) {
this.$emit('callback');
} }
}; })
return { this.tagCount = 0;
basicForm: {}, },
httpVisible: false, createModules() {
currentModule: {}, this.$emit("createRootModelInTree");
maintainerOptions: [], },
loading: false, methodChange() {
rule: { this.$emit("changeApiProtocol", this.basicForm.method);
name: [ },
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'}, setModule(id, data) {
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'} if (data) {
], this.basisData.modulePath = data.path;
userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}], }
moduleId: [{required: true, validator: validateModuleId, trigger: 'change'}], if (id) {
status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}], this.basisData.moduleId = id;
},
value: API_STATUS[0].id,
options: API_STATUS,
moduleObj: {
id: 'id',
label: 'name',
},
tagCount: 0
} }
}, },
watch: {
'basicForm.name': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.userId': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.moduleId': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.status': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.follows': {
handler(v, v1) {
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1)) {
this.apiMapStatus();
}
}
},
'basicForm.description': {
handler(v, v1) {
if (v && v1 !== undefined && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.tags': {
handler(v, v1) {
this.tagCount++;
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1) && this.tagCount > 1) {
this.apiMapStatus();
}
}
},
},
methods: {
apiMapStatus() {
this.$store.state.apiStatus.set("fromChange", true);
if (this.basicForm.id) {
this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus);
}
},
getMaintainerOptions() {
getProjectMemberOption(data => {
this.maintainerOptions = data;
});
},
reload() {
this.loading = true
this.$nextTick(() => {
this.loading = false
})
},
validate() {
this.$refs['basicForm'].validate((valid) => {
if (valid) {
this.$emit('callback');
}
})
this.tagCount = 0;
},
createModules() {
this.$emit("createRootModelInTree");
},
methodChange() {
this.$emit("changeApiProtocol", this.basicForm.method);
},
setModule(id,data) {
this.basisData.modulePath = data.path;
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;