fix(接口定义): 部分缺陷修复

This commit is contained in:
fit2-zhao 2020-12-14 12:19:35 +08:00
parent 0bd4675886
commit 469802030c
14 changed files with 112 additions and 92 deletions

View File

@ -17,6 +17,7 @@ import io.metersphere.commons.utils.CommonBeanFactory;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jorphan.collections.HashTree;
@ -47,7 +48,7 @@ public class MsScenario extends MsTestElement {
if (!this.isEnable()) {
return;
}
if (environmentId != null) {
if (StringUtils.isNotEmpty(environmentId)) {
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
ApiTestEnvironmentWithBLOBs environment = environmentService.get(environmentId);
config.setConfig(JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class));

View File

@ -124,7 +124,7 @@ public class ApiAutomationService {
scenario.setDescription(request.getDescription());
apiScenarioMapper.insert(scenario);
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
List<String> bodyUploadIds = request.getBodyUploadIds();
apiDefinitionService.createBodyFiles(bodyUploadIds, bodyFiles);
}

View File

@ -21,11 +21,10 @@ import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.Resource;
@Service
@Transactional(rollbackFor = Exception.class)
public class ApiScenarioModuleService {

View File

@ -57,10 +57,11 @@
</template>
<script>
import {WORKSPACE_ID} from '@/common/js/constants';
import {getCurrentUser, getUUID,getCurrentProjectID} from "@/common/js/utils";
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
export default {
import {WORKSPACE_ID} from '@/common/js/constants';
import {getCurrentUser, getUUID, getCurrentProjectID} from "@/common/js/utils";
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
export default {
name: "MsAddBasisScenario",
components: {MsDialogFooter},
props: {},
@ -90,7 +91,7 @@ export default {
if (valid) {
let path = "/api/automation/create";
this.setParameter();
this.result = this.$post(path, this.scenarioForm, () => {
this.$fileUpload(path, null, [], this.scenarioForm, () => {
this.visible = false;
if (saveAs) {
this.scenarioForm.request = JSON.stringify(this.scenarioForm.request);
@ -108,7 +109,7 @@ export default {
this.scenarioForm.projectId = getCurrentProjectID();
this.scenarioForm.id = getUUID().substring(0, 8);
this.scenarioForm.protocol = this.currentProtocol;
if (this.currentModule != null) {
if (this.currentModule != null && this.currentModule != "newId") {
this.scenarioForm.modulePath = this.currentModule.method !== undefined ? this.currentModule.method : null;
this.scenarioForm.apiScenarioModuleId = this.currentModule.id;
}
@ -126,5 +127,5 @@ export default {
this.visible = true;
}
}
}
}
</script>

View File

@ -41,7 +41,7 @@
</el-input>
</div>
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
<ms-api-request-form :headers="request.headers " :request="request" v-if="request.protocol==='HTTP'"/>
<ms-api-request-form :referenced="true" :headers="request.headers " :request="request" v-if="request.protocol==='HTTP'"/>
<ms-tcp-basis-parameters :request="request" v-if="request.protocol==='TCP'"/>
<ms-sql-basis-parameters :request="request" v-if="request.protocol==='SQL'"/>
<ms-dubbo-basis-parameters :request="request" v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'"/>

View File

@ -265,6 +265,7 @@
const children = parent.data.children || parent.data
const index = children.findIndex(d => d.id !== undefined && data.id !== undefined && d.id === data.id)
children.splice(index, 1);
this.getApiModuleTree();
});
},

View File

@ -476,7 +476,7 @@
request.enable === undefined ? request.enable = true : request.enable;
request.active = false;
request.resourceId = getUUID();
if (referenced === 'REF') {
if (referenced === 'REF' || !request.hashTree) {
request.hashTree = [];
}
if (this.selectedTreeNode != undefined) {
@ -496,7 +496,7 @@
request.enable === undefined ? request.enable = true : request.enable;
request.active = false;
request.resourceId = getUUID();
if (referenced === 'REF') {
if (referenced === 'REF' || !request.hashTree) {
request.hashTree = [];
}
if (this.selectedTreeNode != undefined) {
@ -506,6 +506,8 @@
}
})
this.apiListVisible = false;
this.currentRow.cases = [];
this.currentRow.apis = [];
this.sort();
this.reload();
},
@ -861,7 +863,8 @@
/deep/ .el-step__icon.is-text {
border: 1px solid;
}
/deep/.el-drawer__header{
/deep/ .el-drawer__header {
margin-bottom: 0px;
}
</style>

View File

@ -193,6 +193,7 @@
this.total = response.data.itemCount;
this.tableData = response.data.listObject;
});
this.selectRows = new Set();
},
handleSelect(selection, row) {
row.hashTree = [];

View File

@ -335,6 +335,9 @@
for (let index in response.data) {
let test = response.data[index];
test.request = JSON.parse(test.request);
if (!test.request.hashTree) {
test.request.hashTree = [];
}
}
this.apiCaseList = response.data;
if (this.apiCaseList.length == 0) {

View File

@ -77,6 +77,9 @@
} else {
this.reqUrl = "/api/definition/create";
}
if (!this.request.hashTree) {
this.request.hashTree = [];
}
},
methods: {
runTest(data) {

View File

@ -275,6 +275,9 @@
handleTestCase(api) {
this.selectApi = api;
let request = JSON.parse(api.request);
if (!request.hashTree) {
request.hashTree = [];
}
this.selectApi.url = request.path;
this.$refs.caseList.open(this.selectApi);
},

View File

@ -2,7 +2,7 @@
<el-row>
<el-col :span="21">
<!-- HTTP 请求参数 -->
<div style="border:1px #DCDFE6 solid; height: 100%;border-radius: 4px ;width: 100%">
<div style="border:1px #DCDFE6 solid; height: 100%;border-radius: 4px ;width: 100%" v-loading="isReloadData">
<el-tabs v-model="activeName" class="request-tabs">
<!-- 请求头-->
<el-tab-pane :label="$t('api_test.request.headers')" name="headers">
@ -58,8 +58,8 @@
</el-tabs>
</div>
<div v-for="row in request.hashTree" :key="row.id" v-loading="isReloadData">
<div v-if="!referenced">
<div v-for="row in request.hashTree" :key="row.id">
<!-- 前置脚本 -->
<ms-jsr233-processor v-if="row.label ==='JSR223 PreProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.pre_script')" style-type="color: #B8741A;background-color: #F9F1EA"
:jsr223-processor="row"/>
@ -70,11 +70,11 @@
<ms-api-assertions v-if="row.type==='Assertions'" @copyRow="copyRow" @remove="remove" :is-read-only="isReadOnly" :assertions="row"/>
<!--提取规则-->
<ms-api-extract :is-read-only="isReadOnly" @copyRow="copyRow" @remove="remove" v-if="row.type==='Extract'" :extract="row"/>
</div>
</div>
</el-col>
<!--操作按钮-->
<el-col :span="3" class="ms-left-cell">
<el-col :span="3" class="ms-left-cell" v-if="!referenced">
<el-button class="ms-left-buttion" size="small" @click="addPre">+{{$t('api_test.definition.request.pre_script')}}</el-button>
<br/>
<el-button class="ms-left-buttion" size="small" @click="addPost">+{{$t('api_test.definition.request.post_script')}}</el-button>
@ -116,6 +116,7 @@
return [];
}
},
referenced: Boolean,
isShowEnable: Boolean,
jsonPathList: Array,
isReadOnly: {

View File

@ -1,6 +1,6 @@
<template>
<div class="request-form">
<component :is="component" :is-read-only="isReadOnly" :request="request" :headers="headers" :isShowEnable="isShowEnable"/>
<component :is="component" :is-read-only="isReadOnly" :referenced="referenced" :request="request" :headers="headers" :isShowEnable="isShowEnable"/>
</div>
</template>
@ -17,6 +17,10 @@
type: Boolean,
default: true
},
referenced: {
type: Boolean,
default: false
},
isReadOnly: {
type: Boolean,
default: false

@ -1 +1 @@
Subproject commit a22a3005d9bd254793fcf634d72539cbdf31be3a
Subproject commit 29a8fc09602fde5708af06582ac972d98eb69836