Merge remote-tracking branch 'origin/v1.8' into v1.8

This commit is contained in:
Captain.B 2021-03-31 19:08:02 +08:00
commit c4cf9b2848
15 changed files with 87 additions and 45 deletions

View File

@ -160,14 +160,16 @@ public class MsHTTPSamplerProxy extends MsTestElement {
sampler.setProtocol(urlObject.getProtocol());
sampler.setPath(urlObject.getPath());
} else {
String configStr = config.getConfig().get(this.getProjectId()).getHttpConfig().getSocket();
sampler.setDomain(configStr);
if (config.getConfig().get(this.getProjectId()).getHttpConfig().getPort() > 0) {
sampler.setDomain(config.getConfig().get(this.getProjectId()).getHttpConfig().getDomain());
sampler.setDomain(config.getConfig().get(this.getProjectId()).getHttpConfig().getDomain());
url = config.getConfig().get(this.getProjectId()).getHttpConfig().getProtocol() + "://" + config.getConfig().get(this.getProjectId()).getHttpConfig().getSocket();
URL urlObject = new URL(url);
String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath();
if (StringUtils.isNotBlank(this.getPath())) {
envPath += this.getPath();
}
sampler.setPort(config.getConfig().get(this.getProjectId()).getHttpConfig().getPort());
sampler.setProtocol(config.getConfig().get(this.getProjectId()).getHttpConfig().getProtocol());
sampler.setPath(this.getPath());
sampler.setPath(envPath);
}
String envPath = sampler.getPath();
if (CollectionUtils.isNotEmpty(this.getRest()) && this.isRest()) {
@ -187,7 +189,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
}
} else {
String url = this.getUrl();
if (!url.startsWith("http://") && !url.startsWith("https://")) {
if (StringUtils.isNotEmpty(url) && !url.startsWith("http://") && !url.startsWith("https://")) {
url = "http://" + url;
}
if (StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) {

View File

@ -30,6 +30,7 @@ import io.metersphere.commons.utils.*;
import io.metersphere.controller.request.ScheduleRequest;
import io.metersphere.i18n.Translator;
import io.metersphere.job.sechedule.ApiScenarioTestJob;
import io.metersphere.job.sechedule.SwaggerUrlImportJob;
import io.metersphere.job.sechedule.TestPlanTestJob;
import io.metersphere.service.ScheduleService;
import io.metersphere.track.dto.TestPlanDTO;
@ -231,6 +232,7 @@ public class ApiAutomationService {
scenario.setPrincipal(request.getPrincipal());
scenario.setStepTotal(request.getStepTotal());
scenario.setUpdateTime(System.currentTimeMillis());
scenario.setDescription(request.getDescription());
scenario.setScenarioDefinition(JSON.toJSONString(request.getScenarioDefinition()));
if (StringUtils.isNotEmpty(request.getStatus())) {
scenario.setStatus(request.getStatus());
@ -816,7 +818,9 @@ public class ApiAutomationService {
if (StringUtils.equals(request.getGroup(), ScheduleGroup.TEST_PLAN_TEST.name())) {
scheduleService.addOrUpdateCronJob(
request, TestPlanTestJob.getJobKey(request.getResourceId()), TestPlanTestJob.getTriggerKey(request.getResourceId()), TestPlanTestJob.class);
} else {
}else if(StringUtils.equals(request.getGroup(), ScheduleGroup.SWAGGER_IMPORT.name())){
scheduleService.addOrUpdateCronJob(request, SwaggerUrlImportJob.getJobKey(request.getResourceId()), SwaggerUrlImportJob.getTriggerKey(request.getResourceId()), SwaggerUrlImportJob.class);
} else{
scheduleService.addOrUpdateCronJob(
request, ApiScenarioTestJob.getJobKey(request.getResourceId()), ApiScenarioTestJob.getTriggerKey(request.getResourceId()), ApiScenarioTestJob.class);
}

View File

@ -67,6 +67,16 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
break;
}
}
//增加字数校验每一层不能超过100字
for (int i = 0; i < nodes.length; i++) {
String nodeStr = nodes[i];
if(StringUtils.isNotEmpty(nodeStr)){
if(nodeStr.trim().length()>100){
stringBuilder.append(Translator.get("module") + Translator.get("test_track.length_less_than") + "100:"+nodeStr);
break;
}
}
}
}
// if (StringUtils.equals(data.getType(), TestCaseConstants.Type.Functional.getValue()) && StringUtils.equals(data.getMethod(), TestCaseConstants.Method.Auto.getValue())) {

View File

@ -91,8 +91,8 @@ public class TestPlanController {
@PostMapping("/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void editTestPlan(@RequestBody TestPlanDTO testPlanDTO) {
testPlanService.editTestPlan(testPlanDTO, true);
public String editTestPlan(@RequestBody TestPlanDTO testPlanDTO) {
return testPlanService.editTestPlan(testPlanDTO, true);
}
@PostMapping("/edit/status/{planId}")

View File

@ -176,7 +176,7 @@ public class TestPlanService {
return Optional.ofNullable(testPlanMapper.selectByPrimaryKey(testPlanId)).orElse(new TestPlan());
}
public int editTestPlan(TestPlanDTO testPlan, Boolean isSendMessage) {
public String editTestPlan(TestPlanDTO testPlan, Boolean isSendMessage) {
checkTestPlanExist(testPlan);
TestPlan res = testPlanMapper.selectByPrimaryKey(testPlan.getId()); // 先查一次库
testPlan.setUpdateTime(System.currentTimeMillis());
@ -230,7 +230,7 @@ public class TestPlanService {
.build();
noticeSendService.send(NoticeConstants.TaskType.TEST_PLAN_TASK, noticeModel);
}
return i;
return testPlan.getId();
}
//计划内容

View File

@ -392,8 +392,8 @@
}
},
runTest(data) {
this.setTabTitle(data);
this.handleTabsEdit(this.$t("commons.api"), "TEST", data);
this.setTabTitle(data);
},
saveApi(data) {
this.setTabTitle(data);

View File

@ -58,22 +58,26 @@
}
},
run() {
let testPlan = new TestPlan();
let threadGroup = new ThreadGroup();
threadGroup.hashTree = [];
testPlan.hashTree = [threadGroup];
this.runData.forEach(item => {
threadGroup.hashTree.push(item);
})
let projectId = "";
let projectId = this.$store.state.projectId;
// envMap
if (!this.envMap || this.envMap.size === 0) {
projectId = this.$store.state.projectId;
} else {
//
projectId = this.runData.projectId;
if(this.runData.projectId){
projectId = this.runData.projectId;
}
}
let testPlan = new TestPlan();
let threadGroup = new ThreadGroup();
threadGroup.hashTree = [];
testPlan.hashTree = [threadGroup];
this.runData.forEach(item => {
item.projectId = projectId;
threadGroup.hashTree.push(item);
})
let reqObj = {id: this.reportId, testElement: testPlan, type: this.type,projectId: projectId, environmentMap: strMapToObj(this.envMap)};
let bodyFiles = getBodyUploadFiles(reqObj, this.runData);
let url = "";

View File

@ -27,7 +27,7 @@
<i class="icon el-icon-arrow-right" :class="{'is-active': apiCase.active}" @click="active(apiCase)"/>
<el-input v-if="!apiCase.id || isShowInput" size="small" v-model="apiCase.name" :name="index" :key="index"
class="ms-api-header-select" style="width: 180px"
@blur="saveTestCase(apiCase)" :placeholder="$t('commons.input_name')" ref="nameEdit"/>
@blur="saveTestCase(apiCase,true)" :placeholder="$t('commons.input_name')" ref="nameEdit"/>
<span v-else>
{{ apiCase.id ? apiCase.name : '' }}
<i class="el-icon-edit" style="cursor:pointer" @click="showInput(apiCase)" v-tester/>
@ -48,7 +48,7 @@
<el-col :span="4">
<div class="tag-item" @click.stop>
<ms-input-tag :currentScenario="apiCase" ref="tag" @keyup.enter.native="saveTestCase(apiCase)"/>
<ms-input-tag :currentScenario="apiCase" ref="tag" @keyup.enter.native="saveTestCase(apiCase,true)"/>
</div>
</el-col>
@ -291,7 +291,7 @@
}
});
},
saveCase(row) {
saveCase(row,hideAlert) {
let tmp = JSON.parse(JSON.stringify(row));
this.isShowInput = false;
if (this.validate(tmp)) {
@ -328,16 +328,18 @@
row.createTime = data.createTime;
row.updateTime = data.updateTime;
if (!row.message) {
this.$success(this.$t('commons.save_success'));
this.$emit('refresh');
if(!hideAlert){
this.$success(this.$t('commons.save_success'));
this.$emit('refresh');
}
}
});
},
saveTestCase(row) {
saveTestCase(row,hideAlert) {
if (this.api.saved) {
this.addModule(row);
} else {
this.saveCase(row);
this.saveCase(row,hideAlert);
}
},
showInput(row) {

View File

@ -306,6 +306,8 @@
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
this.envMap = new Map();
this.envMap.set(this.$store.state.projectId,this.environment);
this.runData = [];
this.batchLoadingIds = [];
this.selectdCases = [];

View File

@ -248,6 +248,7 @@ import {Api_List} from "@/business/components/common/model/JsonData";
import HeaderCustom from "@/business/components/common/head/HeaderCustom";
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
import {Body} from "@/business/components/api/definition/model/ApiTestModel";
import {buildNodePath} from "@/business/components/api/definition/model/NodeTree";
export default {
@ -768,13 +769,21 @@ export default {
});
},
buildApiPath(apis) {
apis.forEach((api) => {
try {
let options = [];
this.moduleOptions.forEach(item => {
if (api.moduleId === item.id) {
api.modulePath = item.path;
}
buildNodePath(item, {path: ''}, options);
});
});
apis.forEach((api) => {
options.forEach((item) => {
if (api.moduleId === item.id) {
api.modulePath = item.path;
}
})
});
} catch (e) {
console.log(e);
}
},
sort(column) {
//

View File

@ -133,16 +133,11 @@
this.data.forEach(node => {
buildTree(node, {path: ''});
});
this.$emit('setModuleOptions', this.data);
this.$emit('setNodeTree', this.data);
if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(this.condition.filterText);
}
let moduleOptions = [];
this.data.forEach(node => {
buildNodePath(node, {path: ''}, moduleOptions);
});
this.moduleOptions = moduleOptions;
this.$emit('setModuleOptions', moduleOptions);
}
});
},

View File

@ -68,7 +68,7 @@
</el-aside>
<el-main style="padding: 0px 0px 0px 0px; line-height: 40px; text-align: center;">
<span v-if="interfaceCoverage === 'waitting...'">
{{interfaceCoverage}}
<i class="el-icon-loading lading-icon"></i>
</span>
<span v-else class="rows-count-number">
{{interfaceCoverage}}
@ -161,7 +161,11 @@ export default {
color: var(--count_number);
margin:20px auto;
}
.lading-icon{
font-size: 25px;
color: var(--count_number);
font-weight: bold;
}
.main-number-show {
width: 100px;
height: 100px;

View File

@ -379,14 +379,17 @@
.common-tree {
overflow: auto;
height: 200px;
min-height: 200px;
max-height: 400px;
}
.ms-tree-select {
width: 100%;
z-index: 111;
}
/deep/.el-tree-node__children{
overflow: inherit;
}
.ok {
float: right;
}

View File

@ -711,7 +711,7 @@ export default {
.border-hidden >>> .el-textarea__inner {
border-style: hidden;
background-color: white;
color: #606266;
color: #060505;
}
.cast_label {
@ -785,4 +785,5 @@ p {
height: 550px;
overflow: auto;
}
</style>

View File

@ -549,4 +549,10 @@ export default {
.comment-card >>> .el-card__body {
height: calc(100vh - 120px);
}
.tb-edit >>> .el-textarea__inner {
border-style: hidden;
background-color: white;
color: #060505;
}
</style>