refactor(接口测试): 批量展开步骤优化
--bug=1011643 --user=赵勇 【通用功能】页面性能优化 https://www.tapd.cn/55049933/s/1127679
This commit is contained in:
parent
be96d32354
commit
7fba70d76e
|
@ -21,10 +21,8 @@ import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
|||
import io.metersphere.api.dto.ssl.KeyStoreConfig;
|
||||
import io.metersphere.api.dto.ssl.KeyStoreFile;
|
||||
import io.metersphere.api.dto.ssl.MsKeyStore;
|
||||
import io.metersphere.api.service.ApiDefinitionService;
|
||||
import io.metersphere.api.service.ApiTestCaseService;
|
||||
import io.metersphere.api.service.CommandService;
|
||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
|
@ -284,13 +282,11 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
|
||||
private boolean setRefElement() {
|
||||
try {
|
||||
ApiDefinitionService apiDefinitionService = CommonBeanFactory.getBean(ApiDefinitionService.class);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
MsHTTPSamplerProxy proxy = null;
|
||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
||||
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
||||
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
||||
ApiTestCaseWithBLOBs bloBs = CommonBeanFactory.getBean(ApiTestCaseService.class).get(this.getId());
|
||||
if (bloBs != null) {
|
||||
this.setProjectId(bloBs.getProjectId());
|
||||
JSONObject element = JSON.parseObject(bloBs.getRequest());
|
||||
|
@ -299,14 +295,6 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
});
|
||||
this.setName(bloBs.getName());
|
||||
}
|
||||
} else {
|
||||
ApiDefinitionWithBLOBs apiDefinition = apiDefinitionService.getBLOBs(this.getId());
|
||||
if (apiDefinition != null) {
|
||||
this.setName(apiDefinition.getName());
|
||||
this.setProjectId(apiDefinition.getProjectId());
|
||||
proxy = mapper.readValue(apiDefinition.getRequest(), new TypeReference<MsHTTPSamplerProxy>() {
|
||||
});
|
||||
}
|
||||
}
|
||||
if (proxy != null) {
|
||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
||||
|
|
|
@ -1810,21 +1810,32 @@ export default {
|
|||
if (resourceIds.indexOf(nodes[i].resourceId) !== -1) {
|
||||
nodes[i].active = this.expandedStatus;
|
||||
}
|
||||
if (nodes[i].hashTree && nodes[i].hashTree.length > 0 && resourceIds.length < 60) {
|
||||
if (nodes[i].hashTree && nodes[i].hashTree.length > 0 && !this.expandedStatus) {
|
||||
this.changeNodeStatus(resourceIds, nodes[i].hashTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
getAllResourceIds() {
|
||||
let selectValueArr = [];
|
||||
if (this.$refs.stepTree) {
|
||||
let checkNodes = this.$refs.stepTree.getCheckedNodes();
|
||||
for (let node of checkNodes) {
|
||||
selectValueArr.push(node.resourceId);
|
||||
return this.$refs.stepTree.getCheckedKeys();
|
||||
}
|
||||
return [];
|
||||
},
|
||||
checkALevelChecked() {
|
||||
if (this.$refs.stepTree) {
|
||||
let resourceIds = [];
|
||||
this.$refs.stepTree.root.childNodes.forEach(item => {
|
||||
if (item.checked) {
|
||||
resourceIds.push(item.data.resourceId);
|
||||
}
|
||||
})
|
||||
if (resourceIds.length > 20) {
|
||||
this.$warning(this.$t('api_test.automation.open_check_message'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return selectValueArr;
|
||||
return true;
|
||||
},
|
||||
recursionExpansion(resourceIds, array) {
|
||||
if (array) {
|
||||
|
@ -1844,9 +1855,11 @@ export default {
|
|||
},
|
||||
openExpansion() {
|
||||
this.expandedStatus = true;
|
||||
let resourceIds = this.getAllResourceIds();
|
||||
this.changeNodeStatus(resourceIds, this.scenarioDefinition);
|
||||
this.recursionExpansion(resourceIds, this.$refs.stepTree.root.childNodes);
|
||||
if (this.checkALevelChecked()) {
|
||||
let resourceIds = this.getAllResourceIds();
|
||||
this.changeNodeStatus(resourceIds, this.scenarioDefinition);
|
||||
this.recursionExpansion(resourceIds, this.$refs.stepTree.root.childNodes);
|
||||
}
|
||||
},
|
||||
closeExpansion() {
|
||||
this.expandedStatus = false;
|
||||
|
|
|
@ -1323,6 +1323,7 @@ export default {
|
|||
case_reduction_error_text: "Please restore first"
|
||||
},
|
||||
automation: {
|
||||
open_check_message: "There are too many steps to check, and a maximum of 20 first-level steps can be supported.",
|
||||
open_expansion: "Batch Folding Steps",
|
||||
close_expansion: "Bulk Expand Steps",
|
||||
bulk_activation_steps: "Bulk activation steps",
|
||||
|
|
|
@ -1328,6 +1328,7 @@ export default {
|
|||
case_reduction_error_text: "请先恢复"
|
||||
},
|
||||
automation: {
|
||||
open_check_message: "勾选步骤太多,最大可支持展开20个一级步骤",
|
||||
open_expansion: "批量展开步骤",
|
||||
close_expansion: "批量折叠步骤",
|
||||
bulk_activation_steps: "批量启用步骤",
|
||||
|
|
|
@ -1328,6 +1328,7 @@ export default {
|
|||
case_reduction_error_text: "請先恢復"
|
||||
},
|
||||
automation: {
|
||||
open_check_message: "勾選步驟太多,最大可支持展開20個一級步驟",
|
||||
open_expansion: "批量展開步驟",
|
||||
close_expansion: "批量折疊步驟",
|
||||
bulk_activation_steps: "批量啟用步驟",
|
||||
|
|
Loading…
Reference in New Issue