From 974ad20206275c7d498ccac06b7a36f07be57ebb Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 9 Mar 2021 17:22:24 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E6=96=AD=E8=A8=80JSONPath=20=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE=E5=BC=8F?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/definition/request/assertions/MsAssertions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java index af6754e309..1dfbe65be0 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java @@ -96,7 +96,7 @@ public class MsAssertions extends MsTestElement { assertion.setJsonValidationBool(true); assertion.setExpectNull(false); assertion.setInvert(false); - assertion.setIsRegex(false); + assertion.setIsRegex(true); return assertion; } From 5475bb4adb31608184d0a9d40a7aa953602fdc40 Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Tue, 9 Mar 2021 17:32:49 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E6=B5=8B=E8=AF=95=E8=AF=84?= =?UTF-8?q?=E5=AE=A1=E8=AF=A6=E6=83=85=E6=94=B9=E9=80=A0=EF=BC=8C=E5=85=B3?= =?UTF-8?q?=E8=81=94=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/ext/ExtTestReviewCaseMapper.xml | 2 +- .../controller/TestCaseReviewController.java | 4 +- .../track/service/TestCaseReviewService.java | 3 +- .../components/case/ApiCaseItem.vue | 14 +- .../review/components/TestCaseReviewEdit.vue | 37 ++-- .../track/review/view/TestCaseReviewView.vue | 3 +- .../review/view/components/TestReviewApi.vue | 191 +++++++++++++----- .../review/view/components/TestReviewLoad.vue | 75 +++---- .../components/TestReviewTestCaseEdit.vue | 104 +++++++--- .../components/TestReviewTestCaseList.vue | 4 +- 10 files changed, 295 insertions(+), 142 deletions(-) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestReviewCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestReviewCaseMapper.xml index e0988937dc..00f773ad2b 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestReviewCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestReviewCaseMapper.xml @@ -100,7 +100,7 @@ select test_case_review_test_case.id as id, test_case.id as caseId, test_case.name, test_case.priority, test_case.type, test_case.node_path, test_case.method, test_case.num, test_case_review_test_case.reviewer, test_case.review_status, test_case_review_test_case.update_time, test_case_node.name as model, - project.name as projectName, test_case_review_test_case.review_id as reviewId + project.name as projectName, test_case_review_test_case.review_id as reviewId,test_case.test_id as testId from test_case_review_test_case inner join test_case on test_case_review_test_case.case_id = test_case.id left join test_case_node on test_case_node.id=test_case.node_id diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java index 6ea0f97fb8..a2e3b0daea 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java @@ -68,8 +68,8 @@ public class TestCaseReviewController { @PostMapping("/edit") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) - public void editCaseReview(@RequestBody SaveTestCaseReviewRequest testCaseReview) { - testCaseReviewService.editCaseReview(testCaseReview); + public String editCaseReview(@RequestBody SaveTestCaseReviewRequest testCaseReview) { + return testCaseReviewService.editCaseReview(testCaseReview); } @GetMapping("/delete/{reviewId}") diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java index 2857fecd68..948ae0af0f 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java @@ -203,7 +203,7 @@ public class TestCaseReviewService { return extTestCaseReviewMapper.listByWorkspaceId(currentWorkspaceId, SessionUtils.getUserId(), SessionUtils.getCurrentProjectId()); } - public void editCaseReview(SaveTestCaseReviewRequest testCaseReview) { + public String editCaseReview(SaveTestCaseReviewRequest testCaseReview) { editCaseReviewer(testCaseReview); testCaseReview.setUpdateTime(System.currentTimeMillis()); checkCaseReviewExist(testCaseReview); @@ -221,6 +221,7 @@ public class TestCaseReviewService { .event(NoticeConstants.Event.UPDATE) .build(); noticeSendService.send(NoticeConstants.TaskType.REVIEW_TASK, noticeModel); + return testCaseReview.getId(); } private void editCaseReviewer(SaveTestCaseReviewRequest testCaseReview) { diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue index bd54431588..76c6bb56f7 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue @@ -1,6 +1,6 @@ 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 2760c085f3..55604d3485 100644 --- a/frontend/src/business/components/track/review/view/components/TestReviewTestCaseEdit.vue +++ b/frontend/src/business/components/track/review/view/components/TestReviewTestCaseEdit.vue @@ -39,11 +39,14 @@ + :disabled="isReadOnly" :icon="testCase.reviewStatus === 'Pass' ? 'el-icon-check' : ''" + @click="saveCase('Pass')"> {{ $t('test_track.review.pass') }} + :disabled="isReadOnly" + :icon="testCase.reviewStatus === 'UnPass' ? 'el-icon-check' : ''" + @click="saveCase('UnPass')"> {{ $t('test_track.review.un_pass') }} @@ -66,29 +69,22 @@ {{ $t('test_track.case.case_type') }}: - {{ - $t('commons.functional') - }} + + 场景用例 + {{ $t('commons.performance') }} {{ $t('commons.api') }} + 接口用例 + - - {{ $t('test_track.case.method') }}: - {{ $t('test_track.case.manual') }} - {{ $t('test_track.case.auto') }} - - + {{ $t('test_track.case.module') }}: {{ testCase.nodePath }} - - {{ $t('test_track.plan.plan_project') }}: - {{ testCase.projectName }} - @@ -98,7 +94,7 @@ - + @@ -108,12 +104,17 @@ :is-read-only="true" :id="testCase.testId" ref="performanceTestDetail"/> + + + - +
{{ $t('test_track.case.steps') }}: @@ -229,7 +230,8 @@ - +
@@ -248,9 +250,11 @@ import PerformanceTestDetail from "../../../plan/view/comonents/test/Performance import ApiTestResult from "../../../plan/view/comonents/test/ApiTestResult"; import ApiTestDetail from "../../../plan/view/comonents/test/ApiTestDetail"; import TestPlanTestCaseStatusButton from "../../../plan/common/TestPlanTestCaseStatusButton"; -import {listenGoBack, removeGoBackListener} from "@/common/js/utils"; +import {getCurrentProjectID, listenGoBack, removeGoBackListener} from "@/common/js/utils"; import ReviewComment from "../../commom/ReviewComment"; import TestCaseAttachment from "@/business/components/track/case/components/TestCaseAttachment"; +import ApiCaseItem from "@/business/components/api/definition/components/case/ApiCaseItem"; +import MsEditApiScenario from "@/business/components/api/automation/scenario/EditApiScenario" export default { name: "TestReviewTestCaseEdit", @@ -261,7 +265,10 @@ export default { ApiTestDetail, TestPlanTestCaseStatusButton, ReviewComment, - TestCaseAttachment + TestCaseAttachment, + ApiCaseItem, + MsEditApiScenario + }, data() { return { @@ -277,7 +284,11 @@ export default { users: [], activeName: 'comment', comments: [], - tableData: [] + tableData: [], + currentScenario: {}, + mark: 'detail', + api: {}, + apiCase: {}, }; }, props: { @@ -378,16 +389,55 @@ export default { listenGoBack(this.handleClose); this.initData(testCase); this.getComments(testCase); + this.getApiTestCase(testCase); + this.getCurrentScenario(testCase) + }, + getApiTestCase(testCase) { + let param = {} + param.projectId = getCurrentProjectID(); + param.id = testCase.testId; + this.result = this.$post("/api/testcase/list", param, response => { + let apiCaseList = [] + this.apiCaseList = response.data; + this.apiCaseList.forEach(apiCase => { + if (apiCase.tags && apiCase.tags.length > 0) { + apiCase.tags = JSON.parse(apiCase.tags); + this.$set(apiCase, 'selected', false); + } + if (Object.prototype.toString.call(apiCase.request).match(/\[object (\w+)\]/)[1].toLowerCase() != 'object') { + apiCase.request = JSON.parse(apiCase.request); + } + if (!apiCase.request.hashTree) { + apiCase.request.hashTree = []; + } + this.apiCase = apiCase + this.handleTestCase(apiCase) + }) + + }); + }, + getCurrentScenario(testCase) { + this.result = this.$get("/api/automation/getApiScenario/" + testCase.testId, response => { + this.currentScenario=response.data + }); + }, + + handleTestCase(testCase) { + this.$get('/api/definition/get/' + testCase.apiDefinitionId, (response) => { + this.api = response.data; + }); }, initTest() { this.$nextTick(() => { if (this.testCase.testId && this.testCase.testId !== 'other') { - if (this.testCase.method === 'auto') { - if (this.$refs.apiTestDetail && this.testCase.type === 'api') { - this.$refs.apiTestDetail.init(); - } else if (this.testCase.type === 'performance') { - this.$refs.performanceTestDetail.init(); - } + if (this.$refs.apiTestDetail && this.testCase.type === 'api') { + this.$refs.apiTestDetail.init(); + } else if (this.testCase.type === 'performance') { + this.$refs.performanceTestDetail.init(); + } else if (this.testCase.type === 'testcase') { + this.$refs.apiCaseConfig.active(this.api); + } else if (this.testCase.type === 'automation') { + this.$refs.autoScenarioConfig.showAll(); } } }); diff --git a/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue b/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue index a3c5e0e88b..213b447120 100644 --- a/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue +++ b/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue @@ -84,7 +84,7 @@ - - + --> Date: Tue, 9 Mar 2021 17:36:53 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=E7=94=A8=E4=BE=8B=E8=AF=84?= =?UTF-8?q?=E5=AE=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/scenario/EditApiScenario.vue | 35 ++++++++++++------- .../request/http/ApiHttpRequestForm.vue | 3 +- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index b0b2fbfd21..57781e5ae7 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -1,15 +1,18 @@ @@ -222,6 +230,7 @@ props: { moduleOptions: Array, currentScenario: {}, + type: String }, components: { MsVariableList, diff --git a/frontend/src/business/components/api/definition/components/request/http/ApiHttpRequestForm.vue b/frontend/src/business/components/api/definition/components/request/http/ApiHttpRequestForm.vue index 8f048b6b23..28d1ee0a12 100644 --- a/frontend/src/business/components/api/definition/components/request/http/ApiHttpRequestForm.vue +++ b/frontend/src/business/components/api/definition/components/request/http/ApiHttpRequestForm.vue @@ -132,7 +132,8 @@ isReadOnly: { type: Boolean, default: false - } + }, + type: String, }, data() { From b80da9b9ae10060faf1799c61ab81fa6a28d533a Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 9 Mar 2021 17:41:15 +0800 Subject: [PATCH 4/4] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8C=96):=20=E6=89=A7=E8=A1=8C=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiAutomationService.java | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index c1badc7da4..2084a7eb85 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -157,17 +157,6 @@ public class ApiAutomationService { return request; } - - public List selectIdsNotExistsInPlan(String projectId, String planId) { - return extApiScenarioMapper.selectIdsNotExistsInPlan(projectId, planId); - } - - public void deleteByIds(List nodeIds) { - ApiScenarioExample example = new ApiScenarioExample(); - example.createCriteria().andApiScenarioModuleIdIn(nodeIds); - apiScenarioMapper.deleteByExample(example); - } - public void removeToGcByIds(List nodeIds) { ApiScenarioExample example = new ApiScenarioExample(); example.createCriteria().andApiScenarioModuleIdIn(nodeIds); @@ -387,7 +376,7 @@ public class ApiAutomationService { return report; } - private void pase(String scenarioDefinition, MsScenario scenario) { + private void parse(String scenarioDefinition, MsScenario scenario) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); try { @@ -424,7 +413,7 @@ public class ApiAutomationService { if (planEnvMap.size() > 0) { scenario.setEnvironmentMap(planEnvMap); } - pase(item.getScenarioDefinition(), scenario); + parse(item.getScenarioDefinition(), scenario); group.setEnableCookieShare(scenario.isEnableCookieShare()); LinkedList scenarios = new LinkedList<>(); @@ -453,7 +442,7 @@ public class ApiAutomationService { if (scenario == null) { return null; } - pase(apiScenario.getScenarioDefinition(), scenario); + parse(apiScenario.getScenarioDefinition(), scenario); // 针对导入的jmx 处理 if (CollectionUtils.isNotEmpty(scenario.getHashTree()) && (scenario.getHashTree().get(0) instanceof MsJmeterElement)) { scenario.toHashTree(jmeterHashTree, scenario.getHashTree(), config); @@ -527,12 +516,13 @@ public class ApiAutomationService { report = createScenarioReport(reportId, item.getId(), item.getName(), request.getTriggerMode(), request.getExecuteType(), item.getProjectId(), request.getReportUserID()); } - //存储报告 - batchMapper.insert(report); // 生成报告和HashTree HashTree hashTree = generateHashTree(item, reportId, planEnvMap); + //存储报告 + batchMapper.insert(report); + // 调用执行方法 jMeterService.runDefinition(report.getId(), hashTree, request.getReportId(), request.getRunMode()); // 重置报告ID