From 045f0fd180f61906d5b4d7e78d132976061f60c6 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 19 Oct 2020 16:06:36 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=E7=9A=84=E6=88=AA=E6=AD=A2=E6=97=B6=E9=97=B4=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E6=97=A9=E4=BA=8E=E5=BD=93=E5=89=8D=E6=97=B6=E9=97=B4=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/review/components/TestCaseReviewEdit.vue | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue b/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue index fba2912cc2..fb6441fc5f 100644 --- a/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue +++ b/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue @@ -173,8 +173,9 @@ export default { this.$warning(this.$t('test_track.plan.input_plan_name')); return; } - if (this.operationType === 'save') { - this.compareTime(new Date().getTime(), this.form.endTime); + + if (!this.compareTime(new Date().getTime(), this.form.endTime)) { + return false; } if (this.operationType === 'edit') { @@ -254,14 +255,17 @@ export default { } }, endTimeChange(value) { - this.form.endTime = this.form.endTime.getTime(); - this.compareTime(new Date().getTime(), value.getTime()); + if (value) { + this.form.endTime = this.form.endTime.getTime(); + this.compareTime(new Date().getTime(), value.getTime()); + } }, compareTime(ts1, ts2) { if (ts1 > ts2) { - this.form.endTime = ''; this.$warning("截止时间不能早于当前时间!"); + return false; } + return true; } } } From fc6fb5eafb22e07dd0975cbd744110d0fb52d8d4 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 19 Oct 2020 16:52:25 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=85=A5=E6=A1=88=E4=BE=8B?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=92=8C=E4=BC=98=E5=85=88=E7=BA=A7=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/service/TestCaseService.java | 4 + .../io/metersphere/xmind/XmindCaseParser.java | 101 ++++++++++-------- 2 files changed, 60 insertions(+), 45 deletions(-) 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 6310cfbd97..1503384dc0 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -286,6 +286,7 @@ public class TestCaseService { testCaseNodeService.createNodes(xmindParser.getNodePaths(), projectId); } if (!xmindParser.getTestCase().isEmpty()) { + Collections.reverse(xmindParser.getTestCase()); this.saveImportData(xmindParser.getTestCase(), projectId); xmindParser.clear(); } @@ -335,6 +336,9 @@ public class TestCaseService { AtomicInteger num = new AtomicInteger(); num.set(getNextNum(projectId) + testCases.size()); testCases.forEach(testcase -> { + testcase.setId(UUID.randomUUID().toString()); + testcase.setCreateTime(System.currentTimeMillis()); + testcase.setUpdateTime(System.currentTimeMillis()); testcase.setNodeId(nodePathMap.get(testcase.getNodePath())); testcase.setSort(sort.getAndIncrement()); testcase.setNum(num.decrementAndGet()); diff --git a/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java b/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java index 465110fc92..9eaaca932f 100644 --- a/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java +++ b/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java @@ -6,7 +6,6 @@ import com.google.common.collect.ImmutableMap; import io.metersphere.base.domain.TestCaseWithBLOBs; import io.metersphere.commons.constants.TestCaseConstants; import io.metersphere.commons.utils.BeanUtils; -import io.metersphere.commons.utils.LogUtil; import io.metersphere.excel.domain.TestCaseExcelData; import io.metersphere.i18n.Translator; import io.metersphere.track.service.TestCaseService; @@ -82,6 +81,7 @@ public class XmindCaseParser { } private final Map caseTypeMap = ImmutableMap.of("功能测试", "functional", "性能测试", "performance", "接口测试", "api"); + private final List priorityList = Arrays.asList("P0", "P1", "P2", "P3"); /** * 验证模块的合规性 @@ -111,6 +111,14 @@ public class XmindCaseParser { */ private boolean validate(TestCaseWithBLOBs data) { String nodePath = data.getNodePath(); + if (!nodePath.startsWith("/")) { + nodePath = "/" + nodePath; + } + if (nodePath.endsWith("/")) { + nodePath = nodePath.substring(0, nodePath.length() - 1); + } + data.setNodePath(nodePath); + StringBuilder stringBuilder = new StringBuilder(); if (data.getName().length() > 50) { @@ -141,17 +149,33 @@ public class XmindCaseParser { if (testCaseNames.contains(data.getName())) { boolean dbExist = testCaseService.exist(data); if (dbExist) { - // db exist stringBuilder.append(Translator.get("test_case_already_exists_excel") + ":" + data.getName() + "; "); } - } else { testCaseNames.add(data.getName()); } + + // 用例等级和用例性质处理 + if (!priorityList.contains(data.getPriority())) { + stringBuilder.append(data.getName() + ":" + Translator.get("test_case_priority") + Translator.get("incorrect_format") + "; "); + } + if (data.getType() == null) { + stringBuilder.append(data.getName() + ":" + Translator.get("test_case_type") + Translator.get("incorrect_format") + "; "); + } + + + // 重复用例校验 + TestCaseExcelData compartData = new TestCaseExcelData(); + BeanUtils.copyBean(compartData, data); + if (compartDatas.contains(compartData)) { + stringBuilder.append(Translator.get("test_case_already_exists_excel") + ":" + compartData.getName() + "; "); + } if (!StringUtils.isEmpty(stringBuilder.toString())) { process.append(stringBuilder.toString()); return false; } + compartDatas.add(compartData); + return true; } @@ -162,7 +186,7 @@ public class XmindCaseParser { for (Attached item : attacheds) { if (isAvailable(item.getTitle(), TC_REGEX)) { item.setParent(parent); - this.newTestCase(item.getTitle(), parent.getPath(), item.getChildren() != null ? item.getChildren().getAttached() : null); + this.formatTestCase(item.getTitle(), parent.getPath(), item.getChildren() != null ? item.getChildren().getAttached() : null); } else { String nodePath = parent.getPath() + "/" + item.getTitle(); item.setPath(nodePath); @@ -207,27 +231,36 @@ public class XmindCaseParser { */ private String getSteps(List attacheds) { JSONArray jsonArray = new JSONArray(); - for (int i = 0; i < attacheds.size(); i++) { + if (!attacheds.isEmpty()) { + for (int i = 0; i < attacheds.size(); i++) { + // 保持插入顺序,判断用例是否有相同的steps + JSONObject step = new JSONObject(true); + step.put("num", i + 1); + step.put("desc", attacheds.get(i).getTitle()); + if (attacheds.get(i).getChildren() != null && !attacheds.get(i).getChildren().getAttached().isEmpty()) { + step.put("result", attacheds.get(i).getChildren().getAttached().get(0).getTitle()); + } + jsonArray.add(step); + } + } else { // 保持插入顺序,判断用例是否有相同的steps JSONObject step = new JSONObject(true); - step.put("num", i + 1); - step.put("desc", attacheds.get(i).getTitle()); - if (attacheds.get(i).getChildren() != null && !attacheds.get(i).getChildren().getAttached().isEmpty()) { - step.put("result", attacheds.get(i).getChildren().getAttached().get(0).getTitle()); - } + step.put("num", 1); + step.put("desc", ""); + step.put("result", ""); jsonArray.add(step); } return jsonArray.toJSONString(); } /** - * 初始化一个用例 + * 格式化一个用例 */ - private void newTestCase(String title, String nodePath, List attacheds) { + private void formatTestCase(String title, String nodePath, List attacheds) { TestCaseWithBLOBs testCase = new TestCaseWithBLOBs(); testCase.setProjectId(projectId); testCase.setMaintainer(maintainer); - testCase.setPriority("P0"); + testCase.setPriority(priorityList.get(0)); testCase.setMethod("manual"); testCase.setType("functional"); @@ -239,26 +272,21 @@ public class XmindCaseParser { } // 用例名称 testCase.setName(this.replace(tcArr[1], TC_REGEX)); - - if (!nodePath.startsWith("/")) { - nodePath = "/" + nodePath; - } - if (nodePath.endsWith("/")) { - nodePath = nodePath.substring(0, nodePath.length() - 1); - } testCase.setNodePath(nodePath); // 用例等级和用例性质处理 if (tcArr[0].indexOf("-") != -1) { - String[] otArr = tcArr[0].split("-"); - for (String item : otArr) { - if (item.toUpperCase().startsWith("P")) { + for (String item : tcArr[0].split("-")) { + if (isAvailable(item, TC_REGEX)) { + continue; + } else if (item.toUpperCase().startsWith("P")) { testCase.setPriority(item.toUpperCase()); } else { - Optional.ofNullable(caseTypeMap.get(item)).ifPresent(opt -> testCase.setType(opt)); + testCase.setType(caseTypeMap.get(item)); } } } + // 测试步骤处理 List steps = new LinkedList<>(); if (attacheds != null && !attacheds.isEmpty()) { @@ -272,29 +300,12 @@ public class XmindCaseParser { } }); } - if (!steps.isEmpty()) { - testCase.setSteps(this.getSteps(steps)); - } else { - JSONArray jsonArray = new JSONArray(); - // 保持插入顺序,判断用例是否有相同的steps - JSONObject step = new JSONObject(true); - step.put("num", 1); - step.put("desc", ""); - step.put("result", ""); - jsonArray.add(step); - testCase.setSteps(jsonArray.toJSONString()); - } - TestCaseExcelData compartData = new TestCaseExcelData(); - BeanUtils.copyBean(compartData, testCase); - if (compartDatas.contains(compartData)) { - process.append(Translator.get("test_case_already_exists_excel") + ":" + testCase.getName() + "; "); - } else if (validate(testCase)) { - testCase.setId(UUID.randomUUID().toString()); - testCase.setCreateTime(System.currentTimeMillis()); - testCase.setUpdateTime(System.currentTimeMillis()); + testCase.setSteps(this.getSteps(steps)); + + // 校验合规性 + if (validate(testCase)) { testCases.add(testCase); } - compartDatas.add(compartData); } /** From 24217c96c83b2e9df658c7215b6c52728cfe5e83 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 19 Oct 2020 17:30:15 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):?= =?UTF-8?q?=20=E7=94=A8=E4=BE=8B=E8=AF=84=E5=AE=A1=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=A0=87=E6=98=8E=E8=AF=84=E5=AE=A1=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/service/TestReviewTestCaseService.java | 6 ------ .../review/view/components/TestReviewTestCaseEdit.vue | 10 ++++++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java index 89362dca7e..ab6d852dfe 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java @@ -110,12 +110,6 @@ public class TestReviewTestCaseService { MSException.throwException("非此用例的评审人员!"); } - TestCaseReview testCaseReview = testCaseReviewMapper.selectByPrimaryKey(reviewId); - Long endTime = testCaseReview.getEndTime(); - if (System.currentTimeMillis() > endTime) { - MSException.throwException("此用例评审已到截止时间!"); - } - // 记录测试用例评审状态变更 testCaseReviewTestCase.setStatus(testCaseReviewTestCase.getStatus()); testCaseReviewTestCase.setReviewer(SessionUtils.getUser().getId()); diff --git a/frontend/src/business/components/track/review/view/components/TestReviewTestCaseEdit.vue b/frontend/src/business/components/track/review/view/components/TestReviewTestCaseEdit.vue index b03372812f..500004fbdf 100644 --- a/frontend/src/business/components/track/review/view/components/TestReviewTestCaseEdit.vue +++ b/frontend/src/business/components/track/review/view/components/TestReviewTestCaseEdit.vue @@ -38,10 +38,12 @@ @click="handleNext()"/> - + {{ $t('test_track.review.pass') }} - + {{ $t('test_track.review.un_pass') }} @@ -290,6 +292,10 @@ export default { this.$success(this.$t('commons.save_success')); this.updateTestCases(param); this.setReviewStatus(this.testCase.reviewId); + // 修改当前用例的评审状态 + this.testCase.reviewStatus = status; + // 修改当前用例在整个用例列表的状态 + this.testCases[this.index].reviewStatus = status; }); }, updateTestCases(param) { From faa9c713c2cfd631c908cec6d922ed26f1d7fc1f Mon Sep 17 00:00:00 2001 From: q4speed Date: Mon, 19 Oct 2020 17:44:34 +0800 Subject: [PATCH 4/6] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8DTCPClient=E6=B2=A1=E6=9C=89=E5=80=99?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/test/components/request/ApiTcpRequestForm.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/business/components/api/test/components/request/ApiTcpRequestForm.vue b/frontend/src/business/components/api/test/components/request/ApiTcpRequestForm.vue index ed8fa6fc91..847a93ad5d 100644 --- a/frontend/src/business/components/api/test/components/request/ApiTcpRequestForm.vue +++ b/frontend/src/business/components/api/test/components/request/ApiTcpRequestForm.vue @@ -124,7 +124,7 @@