fix(接口自动化): 修复循环无法展开,环境 类型为无只能添加一条 控制。

This commit is contained in:
fit2-zhao 2021-04-21 18:43:03 +08:00 committed by fit2-zhao
parent 3f6e8f3323
commit bb4f482a4c
5 changed files with 42 additions and 9 deletions

View File

@ -144,6 +144,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
testResult.setTestId(testId);
testResult.setTotal(queue.size());
testResult.setReportName(this.reportName);
// 一个脚本里可能包含多个场景(ThreadGroup)所以要区分开key: 场景Id
final Map<String, ScenarioResult> scenarios = new LinkedHashMap<>();
queue.forEach(result -> {

View File

@ -280,8 +280,11 @@ public class ApiDefinitionService {
test.setResponse(JSONObject.toJSONString(request.getResponse()));
test.setEnvironmentId(request.getEnvironmentId());
test.setUserId(request.getUserId());
test.setTags(request.getTags());
this.setModule(test);
if (StringUtils.isNotEmpty(request.getTags()) && !StringUtils.equals(request.getTags(), "[]")) {
test.setTags(request.getTags());
} else {
test.setTags(null);
} this.setModule(test);
apiDefinitionMapper.updateByPrimaryKeySelective(test);
return test;
}
@ -324,7 +327,11 @@ public class ApiDefinitionService {
test.setUserId(request.getUserId());
}
test.setDescription(request.getDescription());
test.setTags(request.getTags());
if (StringUtils.isNotEmpty(request.getTags()) && !StringUtils.equals(request.getTags(), "[]")) {
test.setTags(request.getTags());
} else {
test.setTags(null);
}
apiDefinitionMapper.insert(test);
return test;
}

View File

@ -11,7 +11,7 @@
<div class="request-top">
<div>
{{request.name}}
{{ getName(request.name) }}
</div>
<div class="url">
{{request.url}}
@ -91,6 +91,18 @@
data() {
return {}
},
methods:{
getName(name) {
if (name && name.indexOf("^@~@^") !== -1) {
let arr = name.split("^@~@^");
if (arr[arr.length - 1].indexOf("UUID=")) {
return arr[arr.length - 1].split("UUID=")[0];
}
return arr[arr.length - 1];
}
return name;
}
}
}
</script>

View File

@ -4,7 +4,7 @@
<api-base-component @copy="copyRow" @active="active(controller)" @remove="remove" :data="controller" :draggable="draggable" :is-max="isMax" :show-btn="showBtn" color="#02A7F0" background-color="#F4F4F5" :title="$t('api_test.automation.loop_controller')" v-loading="loading">
<template v-slot:headerLeft>
<i class="icon el-icon-arrow-right" :class="{'is-active': controller.active}" @click="active(controller)" style="margin-right: 10px" v-if="!isMax"/>
<i class="icon el-icon-arrow-right" :class="{'is-active': controller.active}" style="margin-right: 10px" v-if="!isMax"/>
<el-radio @change="changeRadio" class="ms-radio ms-radio-margin" v-model="controller.loopType" label="LOOP_COUNT">{{$t('loop.loops_title')}}</el-radio>
<el-radio @change="changeRadio" class="ms-radio ms-radio-margin" v-model="controller.loopType" label="FOREACH">{{$t('loop.foreach')}}</el-radio>
<el-radio @change="changeRadio" class="ms-radio ms-radio-margin" v-model="controller.loopType" label="WHILE">{{$t('loop.while')}}</el-radio>

View File

@ -3,7 +3,7 @@
<el-form-item prop="socket">
<span class="ms-env-span">{{$t('api_test.environment.socket')}}</span>
<el-input v-model="condition.socket" style="width: 80%" :placeholder="$t('api_test.request.url_description')" clearable size="small" :disabled="httpConfig.isMock">
<template v-slot:prepend>
<template slot="prepend">
<el-select v-model="condition.protocol" class="request-protocol-select" size="small">
<el-option label="http://" value="http"/>
<el-option label="https://" value="https"/>
@ -13,7 +13,7 @@
</el-form-item>
<el-form-item prop="enable">
<span class="ms-env-span">{{$t('api_test.environment.condition_enable')}}</span>
<el-radio-group v-model="condition.type" @change="typeChange">
<el-radio-group v-model="condition.type" @change="typeChange" :disabled="condition.id!==undefined && condition.id!==''">
<el-radio label="NONE">{{ $t('api_test.definition.document.data_set.none') }}</el-radio>
<el-radio label="MODULE">{{$t('test_track.module.module')}}</el-radio>
<el-radio label="PATH">{{$t('api_test.definition.api_path')}}</el-radio>
@ -163,7 +163,7 @@
return value;
}
} else if (row && row.type === "PATH" && row.details.length > 0 && row.details[0].name) {
return row.details[0].value === "equals" ? this.$t("commons.adv_search.operators.equals")+ row.details[0].name : this.$t("api_test.request.assertions.contains") + row.details[0].name;
return row.details[0].value === "equals" ? this.$t("commons.adv_search.operators.equals") + row.details[0].name : this.$t("api_test.request.assertions.contains") + row.details[0].name;
} else {
return "";
}
@ -240,7 +240,20 @@
this.loading = false
});
},
checkNode() {
let index = 1;
this.httpConfig.conditions.forEach(item => {
if (item.type === "NONE") {
index++;
}
})
return index > 1;
},
add() {
if(this.checkNode()){
this.$warning("启用条件为 '无' 的域名已经存在请更新!");
return;
}
this.validateSocket();
let obj = {
id: getUUID(), type: this.condition.type, socket: this.condition.socket, protocol: this.condition.protocol, headers: this.condition.headers,
@ -311,7 +324,7 @@
}
/deep/ .el-form-item {
margin-bottom: 10px;
margin-bottom: 15px;
}
.ms-el-form-item__content >>> .el-form-item__content {