fix(接口定义): 修复自定义tcp没名字时无法执行的缺陷 (#18102)

--bug=1017030 --user=王孝刚 【接口测试】接口自动化自定义请求,TCP请求不填写名称创建后无法运行
https://www.tapd.cn/55049933/s/1247550

Co-authored-by: wxg0103 <727495428@qq.com>
This commit is contained in:
MeterSphere Bot 2022-09-20 19:51:45 +08:00 committed by GitHub
parent 2016d2e401
commit 6b1bcb1614
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 61 deletions

View File

@ -180,6 +180,9 @@ public class MsDubboSampler extends MsTestElement {
DubboSample sampler = new DubboSample();
sampler.setEnabled(this.isEnable());
sampler.setName(this.getName());
if (StringUtils.isEmpty(this.getName())) {
sampler.setName("DubboSamplerProxy");
}
if (config.isOperating()) {
String[] testNameArr = sampler.getName().split("<->");
if (testNameArr.length > 0) {

View File

@ -285,6 +285,9 @@ public class MsTCPSampler extends MsTestElement {
TCPSampler tcpSampler = new TCPSampler();
tcpSampler.setEnabled(this.isEnable());
tcpSampler.setName(this.getName());
if (StringUtils.isEmpty(this.getName())) {
tcpSampler.setName("TcpSamplerProxy");
}
if (config.isOperating()) {
String[] testNameArr = tcpSampler.getName().split("<->");
if (testNameArr.length > 0) {

View File

@ -1,7 +1,7 @@
<template>
<div>
<el-card>
<el-form :model="request" :rules="rules" label-width="auto" ref="request">
<el-form ref="request" :model="request" label-width="auto">
<el-form-item :label="$t('api_test.request.name')" prop="name">
<el-input v-model="request.name" maxlength="200" show-word-limit size="small"/>
</el-form-item>
@ -13,74 +13,75 @@
</el-form-item>
</el-form>
<!--不同协议请求-->
<ms-debug-http-page :scenario="true" :current-api="request" @saveAs="editApi" :currentProtocol="request.protocol" v-if="request.protocol==='HTTP'"/>
<ms-debug-jdbc-page :scenario="true" :currentProtocol="request.protocol" @saveAs="editApi" v-if="request.protocol==='SQL'"/>
<ms-debug-tcp-page :scenario="true" :currentProtocol="request.protocol" @saveAs="editApi" v-if="request.protocol==='TCP'"/>
<ms-debug-dubbo-page :scenario="true" :currentProtocol="request.protocol" @saveAs="editApi" v-if="request.protocol==='DUBBO'"/>
<ms-debug-http-page v-if="request.protocol==='HTTP'" :current-api="request" :currentProtocol="request.protocol"
:scenario="true"
@saveAs="editApi"/>
<ms-debug-jdbc-page v-if="request.protocol==='SQL'" :currentProtocol="request.protocol" :scenario="true"
@saveAs="editApi"/>
<ms-debug-tcp-page v-if="request.protocol==='TCP'" :currentProtocol="request.protocol" :scenario="true"
@saveAs="editApi"/>
<ms-debug-dubbo-page v-if="request.protocol==='DUBBO'" :currentProtocol="request.protocol" :scenario="true"
@saveAs="editApi"/>
</el-card>
</div>
</template>
<script>
import MsDebugHttpPage from "../../definition/components/debug/DebugHttpPage";
import MsDebugJdbcPage from "../../definition/components/debug/DebugJdbcPage";
import MsDebugTcpPage from "../../definition/components/debug/DebugTcpPage";
import MsDebugDubboPage from "../../definition/components/debug/DebugDubboPage";
import {getCurrentProjectID, getUUID} from "@/common/js/utils";
import MsDebugHttpPage from "../../definition/components/debug/DebugHttpPage";
import MsDebugJdbcPage from "../../definition/components/debug/DebugJdbcPage";
import MsDebugTcpPage from "../../definition/components/debug/DebugTcpPage";
import MsDebugDubboPage from "../../definition/components/debug/DebugDubboPage";
import {getCurrentProjectID, getUUID} from "@/common/js/utils";
export default {
name: "ApiCustomize",
props: {
node: {},
request: {},
},
components: {MsDebugHttpPage, MsDebugJdbcPage, MsDebugTcpPage, MsDebugDubboPage},
data() {
return {
loading: false,
rules: {
name: [{required: true, message: this.$t('commons.input_name'), trigger: 'blur'}],
protocol: [{required: true, message: this.$t('commons.please_select'), trigger: 'blur'}],
}
}
},
methods: {
remove() {
this.$emit('remove', this.request, this.node);
},
active(item) {
item.active = !item.active;
this.reload();
},
editApi(row) {
let name = this.request.name;
Object.assign(this.request, row.request);
this.request.name = name;
if (this.request.protocol === 'HTTP') {
if (row.url) {
//
this.request.url = row.url;
this.request.path = row.url;
} else {
this.request.url = row.path;
this.request.path = row.path;
}
this.request.method = row.method;
}
this.request.resourceId = getUUID();
this.request.projectId = getCurrentProjectID();
let obj = {};
Object.assign(obj, this.request);
this.$emit('addCustomizeApi', obj);
},
reload() {
this.loading = true
this.$nextTick(() => {
this.loading = false
})
},
export default {
name: "ApiCustomize",
props: {
node: {},
request: {},
},
components: {MsDebugHttpPage, MsDebugJdbcPage, MsDebugTcpPage, MsDebugDubboPage},
data() {
return {
loading: false,
}
},
methods: {
remove() {
this.$emit('remove', this.request, this.node);
},
active(item) {
item.active = !item.active;
this.reload();
},
editApi(row) {
let name = this.request.name;
Object.assign(this.request, row.request);
this.request.name = name;
if (this.request.protocol === 'HTTP') {
if (row.url) {
//
this.request.url = row.url;
this.request.path = row.url;
} else {
this.request.url = row.path;
this.request.path = row.path;
}
this.request.method = row.method;
}
this.request.resourceId = getUUID();
this.request.projectId = getCurrentProjectID();
let obj = {};
Object.assign(obj, this.request);
this.$emit('addCustomizeApi', obj);
},
reload() {
this.loading = true
this.$nextTick(() => {
this.loading = false
})
},
}
}
</script>
<style scoped>