fix: 优化脚本编写域、修复旧Mock环境数据引起的报错、修复测试计划无法关联接口和案例的问题
优化脚本编写域、修复旧Mock环境数据引起的报错、修复测试计划无法关联接口和案例的问题
This commit is contained in:
parent
d65a0a3b7b
commit
d984187f12
|
@ -88,6 +88,34 @@ public class ApiTestEnvironmentService {
|
||||||
this.add(returnModel);
|
this.add(returnModel);
|
||||||
} else {
|
} else {
|
||||||
returnModel = list.get(0);
|
returnModel = list.get(0);
|
||||||
|
returnModel = this.checkMockEvnIsRightful(returnModel, projectId, apiName, baseUrl);
|
||||||
|
}
|
||||||
|
return returnModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiTestEnvironmentWithBLOBs checkMockEvnIsRightful(ApiTestEnvironmentWithBLOBs returnModel, String projectId, String name, String url) {
|
||||||
|
boolean needUpdate = true;
|
||||||
|
if (returnModel.getConfig() != null) {
|
||||||
|
try {
|
||||||
|
JSONObject configObj = JSONObject.parseObject(returnModel.getConfig());
|
||||||
|
if (configObj.containsKey("httpConfig")) {
|
||||||
|
JSONObject httpObj = configObj.getJSONObject("httpConfig");
|
||||||
|
if (httpObj.containsKey("isMock") && httpObj.getBoolean("isMock")) {
|
||||||
|
if (httpObj.containsKey("conditions")) {
|
||||||
|
JSONArray conditions = httpObj.getJSONArray("conditions");
|
||||||
|
needUpdate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (needUpdate) {
|
||||||
|
String id = returnModel.getId();
|
||||||
|
returnModel = this.genHttpApiTestEnvironmentByUrl(projectId, name, url);
|
||||||
|
returnModel.setId(id);
|
||||||
|
apiTestEnvironmentMapper.updateByPrimaryKeyWithBLOBs(returnModel);
|
||||||
}
|
}
|
||||||
return returnModel;
|
return returnModel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<el-row style="margin:0px 10px 10px">
|
|
||||||
<el-col>
|
|
||||||
<div class="document-url">
|
|
||||||
<el-link href="https://jmeter.apache.org/usermanual/component_reference.html#BeanShell_PostProcessor"
|
|
||||||
target="componentReferenceDoc"
|
|
||||||
type="primary">{{$t('commons.reference_documentation')}}
|
|
||||||
</el-link>
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="20" class="script-content">
|
<el-col :span="20" class="script-content">
|
||||||
<ms-code-edit v-if="isCodeEditAlive" :mode="codeEditModeMap[jsr223ProcessorData.scriptLanguage]"
|
<ms-code-edit v-if="isCodeEditAlive" :mode="codeEditModeMap[jsr223ProcessorData.scriptLanguage]"
|
||||||
|
@ -18,11 +8,16 @@
|
||||||
ref="codeEdit"/>
|
ref="codeEdit"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="4" class="script-index">
|
<el-col :span="4" class="script-index">
|
||||||
<ms-dropdown :default-command="jsr223ProcessorData.scriptLanguage" :commands="languages" @command="languageChange"/>
|
<ms-dropdown :default-command="jsr223ProcessorData.scriptLanguage" :commands="languages"
|
||||||
<div class="template-title">{{$t('api_test.request.processor.code_template')}}</div>
|
@command="languageChange"/>
|
||||||
|
<div class="template-title">{{ $t('api_test.request.processor.code_template') }}</div>
|
||||||
<div v-for="(template, index) in codeTemplates" :key="index" class="code-template">
|
<div v-for="(template, index) in codeTemplates" :key="index" class="code-template">
|
||||||
<el-link :disabled="template.disabled" @click="addTemplate(template)">{{template.title}}</el-link>
|
<el-link :disabled="template.disabled" @click="addTemplate(template)">{{ template.title }}</el-link>
|
||||||
</div>
|
</div>
|
||||||
|
<el-link href="https://jmeter.apache.org/usermanual/component_reference.html#BeanShell_PostProcessor"
|
||||||
|
target="componentReferenceDoc" style="margin-top: 10px"
|
||||||
|
type="primary">{{ $t('commons.reference_documentation') }}
|
||||||
|
</el-link>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
|
@ -162,7 +157,7 @@
|
||||||
|
|
||||||
.script-content {
|
.script-content {
|
||||||
height: calc(100vh - 570px);
|
height: calc(100vh - 570px);
|
||||||
min-height: 250px;
|
min-height: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.script-index {
|
.script-index {
|
||||||
|
|
|
@ -125,26 +125,39 @@
|
||||||
|
|
||||||
saveCaseRelevance() {
|
saveCaseRelevance() {
|
||||||
|
|
||||||
let param = {};
|
|
||||||
let url = '';
|
let url = '';
|
||||||
let environmentId = undefined;
|
let environmentId = undefined;
|
||||||
let selectIds = [];
|
let selectIds = [];
|
||||||
if (this.isApiListEnable) {
|
if (this.isApiListEnable) {
|
||||||
url = '/api/definition/relevance';
|
//查找所有数据
|
||||||
environmentId = this.$refs.apiList.environmentId;
|
let params = this.$refs.apiList.getConditions();
|
||||||
selectIds = Array.from(this.$refs.apiList.selectRows).map(row => row.id);
|
this.result = this.$post("/api/definition/list/batch", params, (response) => {
|
||||||
|
let apis = response.data;
|
||||||
|
url = '/api/definition/relevance';
|
||||||
|
environmentId = this.$refs.apiList.environmentId;
|
||||||
|
selectIds = Array.from(apis).map(row => row.id);
|
||||||
|
this.postRelevance(url, environmentId, selectIds);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
url = '/api/testcase/relevance';
|
let params = this.$refs.apiCaseList.getConditions();
|
||||||
environmentId = this.$refs.apiCaseList.environmentId;
|
this.result = this.$post("/api/testcase/get/caseBLOBs/request", params, (response) => {
|
||||||
selectIds = Array.from(this.$refs.apiCaseList.selectRows).map(row => row.id);
|
let apiCases = response.data;
|
||||||
|
url = '/api/testcase/relevance';
|
||||||
|
environmentId = this.$refs.apiCaseList.environmentId;
|
||||||
|
selectIds = Array.from(apiCases).map(row => row.id);
|
||||||
|
this.postRelevance(url, environmentId, selectIds);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
postRelevance(url, environmentId, selectIds) {
|
||||||
|
let param = {};
|
||||||
if (!environmentId) {
|
if (!environmentId) {
|
||||||
this.$warning(this.$t('api_test.environment.select_environment'));
|
this.$warning(this.$t('api_test.environment.select_environment'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
param.planId = this.planId;
|
param.planId = this.planId;
|
||||||
param.selectIds = selectIds;
|
param.selectIds = selectIds;
|
||||||
param.environmentId = environmentId;
|
param.environmentId = environmentId;
|
||||||
|
|
Loading…
Reference in New Issue