fix(接口测试): 修复复制场景步骤不显示版本信息问题

--bug=1009898 --user=赵勇 【接口测试】场景引用其他项目的接口用例,会变成自定义用例 https://www.tapd.cn/55049933/s/1098592
This commit is contained in:
fit2-zhao 2022-01-26 10:05:23 +08:00 committed by 刘瑞斌
parent 5ea5610ac3
commit 643030fa33
3 changed files with 8 additions and 34 deletions

View File

@ -509,6 +509,7 @@ public class ElementUtil {
if (CollectionUtils.isNotEmpty(targetHashTree)) {
for (int i = 0; i < targetHashTree.size(); i++) {
JSONObject item = targetHashTree.getJSONObject(i);
item.put("disabled", true);
if (StringUtils.isNotEmpty(item.getString("id"))) {
updateMap.put(item.getString("id"), item);
}

View File

@ -719,16 +719,17 @@ public class ApiAutomationService {
if (StringUtils.equalsIgnoreCase(element.getString("refType"), "CASE")) {
ApiTestCaseInfo apiTestCase = apiTestCaseService.get(element.getString("id"));
if (apiTestCase != null) {
JSONObject refElement = JSON.parseObject(apiTestCase.getRequest());
ElementUtil.dataFormatting(refElement);
if (StringUtils.equalsIgnoreCase(element.getString("referenced"), "REF")) {
if (refElement.get("hashTree") != null) {
JSONObject refElement = JSON.parseObject(apiTestCase.getRequest());
ElementUtil.dataFormatting(refElement);
JSONArray array = refElement.getJSONArray("hashTree");
BeanUtils.copyBean(element, refElement);
if (array != null) {
ElementUtil.mergeHashTree(element, refElement.getJSONArray("hashTree"));
}
element.put("referenced", "REF");
element.put("disabled", true);
element.put("name", apiTestCase.getName());
} else {
element = refElement;
}
element.put("id", apiTestCase.getId());
isExist = true;
@ -1144,10 +1145,8 @@ public class ApiAutomationService {
public JmxInfoDTO genPerformanceTestJmx(GenScenarioRequest request) {
List<String> ids = request.getIds();
List<ApiScenarioDTO> apiScenarios = extApiScenarioMapper.selectIds(ids);
String testName = "";
String id = "";
if (!apiScenarios.isEmpty()) {
testName = apiScenarios.get(0).getName();
id = apiScenarios.get(0).getId();
}
if (CollectionUtils.isEmpty(apiScenarios)) {
@ -1765,33 +1764,6 @@ public class ApiAutomationService {
return returnList;
}
private void addUrlAndIdToList(String scenarioDefiniton, List<String> urlList, List<String> idList) {
try {
JSONObject scenarioObj = JSONObject.parseObject(scenarioDefiniton);
if (scenarioObj.containsKey("hashTree")) {
JSONArray hashArr = scenarioObj.getJSONArray("hashTree");
for (int i = 0; i < hashArr.size(); i++) {
JSONObject elementObj = hashArr.getJSONObject(i);
if (elementObj.containsKey("id")) {
String id = elementObj.getString("id");
idList.add(id);
}
if (elementObj.containsKey("url")) {
String url = elementObj.getString("url");
urlList.add(url);
}
if (elementObj.containsKey("path")) {
String path = elementObj.getString("path");
urlList.add(path);
}
}
}
} catch (Exception e) {
}
}
public ScenarioEnv getApiScenarioProjectId(String id) {
ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(id);
ScenarioEnv scenarioEnv = new ScenarioEnv();

View File

@ -250,6 +250,7 @@ export default {
if (this.request.num) {
this.isShowNum = true;
this.request.root = true;
this.getWorkspaceId(this.request.projectId);
} else {
this.isShowNum = false;