diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java index af09431f0a..7e50ea9dbd 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java @@ -175,7 +175,7 @@ public class ApiTestEnvironmentService { boolean needUpdate = false; ProjectService projectService = CommonBeanFactory.getBean(ProjectService.class); Project project = projectService.getProjectById(projectId); - if (returnModel.getConfig() != null) { + if (returnModel.getConfig() != null && project != null) { try { JSONObject configObj = JSONObject.parseObject(returnModel.getConfig()); if (configObj.containsKey("httpConfig")) { @@ -256,6 +256,9 @@ public class ApiTestEnvironmentService { } private ApiTestEnvironmentWithBLOBs genHttpApiTestEnvironmentByUrl(Project project,String projectNumber, String protocal, String name, String baseUrl) { + if(project == null){ + return null; + } String socket = ""; String url = baseUrl; if (url.startsWith("http://")) { diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 4a193e7dea..0c1b3212de 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -980,8 +980,8 @@ public class TestCaseService { list.add(model.getStepModel()); }else if(StringUtils.equalsAnyIgnoreCase(head,"Priority","用例等級","用例等级")){ list.add(model.getPriority()); - }else if(StringUtils.equalsAnyIgnoreCase(head,"Case status","用例状态","用例狀態")){ - list.add(model.getStatus()); +// }else if(StringUtils.equalsAnyIgnoreCase(head,"Case status","用例状态","用例狀態")){ +// list.add(model.getStatus()); } else if (StringUtils.equalsAnyIgnoreCase(head, "Maintainer(ID)", "责任人(ID)", "維護人(ID)")) { String value = customDataMaps.get("责任人"); value = value == null ? "" : value; @@ -1023,6 +1023,45 @@ public class TestCaseService { List list = new ArrayList<>(); StringBuilder step = new StringBuilder(""); StringBuilder result = new StringBuilder(""); + + Map> customSelectValueMap = new HashMap<>(); + TestCaseTemplateService testCaseTemplateService = CommonBeanFactory.getBean(TestCaseTemplateService.class); + TestCaseTemplateDao testCaseTemplate = testCaseTemplateService.getTemplate(request.getProjectId()); + + List customFieldList = null; + if (testCaseTemplate == null) { + customFieldList = new ArrayList<>(); + } else { + customFieldList = testCaseTemplate.getCustomFields(); + } + for (CustomFieldDao dto :customFieldList) { + Map map = new HashMap<>(); + if(StringUtils.equals("select",dto.getType())){ + try { + JSONArray optionsArr = JSONArray.parseArray(dto.getOptions()); + for (int i = 0; i < optionsArr.size();i++) { + JSONObject obj = optionsArr.getJSONObject(i); + if(obj.containsKey("text") && obj.containsKey("value")){ + String value = obj.getString("value"); + String text = obj.getString("text"); + if(StringUtils.equals(text,"test_track.case.status_finished")){ + text = Translator.get("test_case_status_finished"); + }else if(StringUtils.equals(text,"test_track.case.status_prepare")){ + text = Translator.get("test_case_status_prepare"); + }else if(StringUtils.equals(text,"test_track.case.status_running")){ + text = Translator.get("test_case_status_running"); + } + if(StringUtils.isNotEmpty(value)){ + map.put(value,text); + } + } + } + }catch (Exception e){} + } + customSelectValueMap.put(dto.getName(),map); + } + + testCaseList.forEach(t -> { TestCaseExcelData data = new TestCaseExcelData(); data.setNum(t.getNum()); @@ -1039,7 +1078,6 @@ public class TestCaseService { } else { data.setStepModel(t.getStepModel()); } -// data.setMethod(t.getMethod()); data.setPrerequisite(t.getPrerequisite()); data.setTags(t.getTags()); if (StringUtils.equals(t.getMethod(), "manual") || StringUtils.isBlank(t.getMethod())) { @@ -1106,7 +1144,15 @@ public class TestCaseService { for(int index = 0; index < customFieldsArr.size(); index ++){ JSONObject obj = customFieldsArr.getJSONObject(index); if(obj.containsKey("name") && obj.containsKey("value")){ - map.put(obj.getString("name"),obj.getString("value")); + //进行key value对换 + String name = obj.getString("name"); + String value = obj.getString("value"); + if(customSelectValueMap.containsKey(name)){ + if(customSelectValueMap.get(name).containsKey(value)){ + value = customSelectValueMap.get(name).get(value); + } + } + map.put(name,value); } } data.setCustomDatas(map); diff --git a/backend/src/main/java/io/metersphere/xmind/pojo/TestCaseXmindData.java b/backend/src/main/java/io/metersphere/xmind/pojo/TestCaseXmindData.java index 5cef603554..fc12f1f1f7 100644 --- a/backend/src/main/java/io/metersphere/xmind/pojo/TestCaseXmindData.java +++ b/backend/src/main/java/io/metersphere/xmind/pojo/TestCaseXmindData.java @@ -27,6 +27,7 @@ public class TestCaseXmindData { public TestCaseXmindData(String moduleId, String moduleName) { this.moduleId = moduleId; this.moduleName = moduleName; + this.testCaseList = new ArrayList<>(); } public void setItem(LinkedList modulePathDataList, List dataList) { diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 0af1f578d3..e7317f5044 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -265,6 +265,9 @@ personal_information_personal_settings=Personal information personal settings personal_information_apikeys=Personal information API Keys auth_title=Auth group_permission=Group +test_case_status_prepare=Rrepare +test_case_status_running=Running +test_case_status_finished=Finished # track home api_case=API performance_case=PERFORMANCE diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index ec6a0e65bb..200d783dc2 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -264,7 +264,9 @@ personal_information_personal_settings=个人信息-个人设置 personal_information_apikeys=个人信息-API Keys auth_title=系统认证 group_permission=用户组与权限 - +test_case_status_prepare=未开始 +test_case_status_running=进行中 +test_case_status_finished=已完成 # track home api_case=接口用例 performance_case=性能用例 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 4606b62d23..e07c5482c7 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -269,5 +269,8 @@ group_permission=用戶組與權限 api_case=接口用例 performance_case=性能用例 scenario_case=場景用例 +test_case_status_prepare=未開始 +test_case_status_running=進行中 +test_case_status_finished=已完成 id_not_rightful=ID 不合法 \ No newline at end of file diff --git a/frontend/src/business/components/track/case/TestCase.vue b/frontend/src/business/components/track/case/TestCase.vue index b786972d85..02a6051e71 100644 --- a/frontend/src/business/components/track/case/TestCase.vue +++ b/frontend/src/business/components/track/case/TestCase.vue @@ -34,7 +34,7 @@ @setCondition="setCondition" @decrease="decrease" :custom-num="custom_num" - ref="testCaseList"> + ref="testCaseTrashList">