From 469802030ca634adddc63e1b31b8df5af3f0c683 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 14 Dec 2020 12:19:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):=20?= =?UTF-8?q?=E9=83=A8=E5=88=86=E7=BC=BA=E9=99=B7=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/definition/request/MsScenario.java | 3 +- .../api/service/ApiAutomationService.java | 2 +- .../api/service/ApiScenarioModuleService.java | 3 +- .../automation/scenario/AddBasisScenario.vue | 135 +++++++++--------- .../api/automation/scenario/ApiComponent.vue | 2 +- .../automation/scenario/ApiScenarioModule.vue | 1 + .../automation/scenario/EditApiScenario.vue | 9 +- .../api/automation/scenario/api/ApiList.vue | 1 + .../api/definition/components/ApiCaseList.vue | 3 + .../api/definition/components/ApiConfig.vue | 3 + .../api/definition/components/ApiList.vue | 3 + .../request/http/ApiHttpRequestForm.vue | 31 ++-- .../request/http/ApiRequestForm.vue | 6 +- frontend/src/business/components/xpack | 2 +- 14 files changed, 112 insertions(+), 92 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index 6be0d1fe99..92290a861e 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -17,6 +17,7 @@ import io.metersphere.commons.utils.CommonBeanFactory; import lombok.Data; import lombok.EqualsAndHashCode; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.jmeter.save.SaveService; import org.apache.jmeter.testelement.TestElement; import org.apache.jorphan.collections.HashTree; @@ -47,7 +48,7 @@ public class MsScenario extends MsTestElement { if (!this.isEnable()) { return; } - if (environmentId != null) { + if (StringUtils.isNotEmpty(environmentId)) { ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class); ApiTestEnvironmentWithBLOBs environment = environmentService.get(environmentId); config.setConfig(JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class)); 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 498e178e37..70145ccad2 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -124,7 +124,7 @@ public class ApiAutomationService { scenario.setDescription(request.getDescription()); apiScenarioMapper.insert(scenario); - List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); + List bodyUploadIds = request.getBodyUploadIds(); apiDefinitionService.createBodyFiles(bodyUploadIds, bodyFiles); } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java index ffbdb54759..24d2c3412b 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java @@ -21,11 +21,10 @@ import org.apache.ibatis.session.SqlSessionFactory; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.util.*; import java.util.stream.Collectors; -import javax.annotation.Resource; - @Service @Transactional(rollbackFor = Exception.class) public class ApiScenarioModuleService { diff --git a/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue b/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue index 3b826f7de1..8ef356a85e 100644 --- a/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/AddBasisScenario.vue @@ -57,74 +57,75 @@ diff --git a/frontend/src/business/components/api/automation/scenario/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/ApiComponent.vue index 6b35d98651..8056137ced 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiComponent.vue @@ -41,7 +41,7 @@

{{$t('api_test.definition.request.req_param')}}

- + diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue index 47dc95d5a4..1f728d338d 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue @@ -265,6 +265,7 @@ const children = parent.data.children || parent.data const index = children.findIndex(d => d.id !== undefined && data.id !== undefined && d.id === data.id) children.splice(index, 1); + this.getApiModuleTree(); }); }, diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 9d629a8cba..ab484774bd 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -476,7 +476,7 @@ request.enable === undefined ? request.enable = true : request.enable; request.active = false; request.resourceId = getUUID(); - if (referenced === 'REF') { + if (referenced === 'REF' || !request.hashTree) { request.hashTree = []; } if (this.selectedTreeNode != undefined) { @@ -496,7 +496,7 @@ request.enable === undefined ? request.enable = true : request.enable; request.active = false; request.resourceId = getUUID(); - if (referenced === 'REF') { + if (referenced === 'REF' || !request.hashTree) { request.hashTree = []; } if (this.selectedTreeNode != undefined) { @@ -506,6 +506,8 @@ } }) this.apiListVisible = false; + this.currentRow.cases = []; + this.currentRow.apis = []; this.sort(); this.reload(); }, @@ -861,7 +863,8 @@ /deep/ .el-step__icon.is-text { border: 1px solid; } - /deep/.el-drawer__header{ + + /deep/ .el-drawer__header { margin-bottom: 0px; } diff --git a/frontend/src/business/components/api/automation/scenario/api/ApiList.vue b/frontend/src/business/components/api/automation/scenario/api/ApiList.vue index a4102bb1df..9227f02246 100644 --- a/frontend/src/business/components/api/automation/scenario/api/ApiList.vue +++ b/frontend/src/business/components/api/automation/scenario/api/ApiList.vue @@ -193,6 +193,7 @@ this.total = response.data.itemCount; this.tableData = response.data.listObject; }); + this.selectRows = new Set(); }, handleSelect(selection, row) { row.hashTree = []; diff --git a/frontend/src/business/components/api/definition/components/ApiCaseList.vue b/frontend/src/business/components/api/definition/components/ApiCaseList.vue index 7f13288b18..7ca0bb37c6 100644 --- a/frontend/src/business/components/api/definition/components/ApiCaseList.vue +++ b/frontend/src/business/components/api/definition/components/ApiCaseList.vue @@ -335,6 +335,9 @@ for (let index in response.data) { let test = response.data[index]; test.request = JSON.parse(test.request); + if (!test.request.hashTree) { + test.request.hashTree = []; + } } this.apiCaseList = response.data; if (this.apiCaseList.length == 0) { diff --git a/frontend/src/business/components/api/definition/components/ApiConfig.vue b/frontend/src/business/components/api/definition/components/ApiConfig.vue index 1df8d46921..b886bf9d60 100644 --- a/frontend/src/business/components/api/definition/components/ApiConfig.vue +++ b/frontend/src/business/components/api/definition/components/ApiConfig.vue @@ -77,6 +77,9 @@ } else { this.reqUrl = "/api/definition/create"; } + if (!this.request.hashTree) { + this.request.hashTree = []; + } }, methods: { runTest(data) { diff --git a/frontend/src/business/components/api/definition/components/ApiList.vue b/frontend/src/business/components/api/definition/components/ApiList.vue index 91fe6f53e9..498fb5c9e9 100644 --- a/frontend/src/business/components/api/definition/components/ApiList.vue +++ b/frontend/src/business/components/api/definition/components/ApiList.vue @@ -275,6 +275,9 @@ handleTestCase(api) { this.selectApi = api; let request = JSON.parse(api.request); + if (!request.hashTree) { + request.hashTree = []; + } this.selectApi.url = request.path; this.$refs.caseList.open(this.selectApi); }, 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 d89b29472b..279badcc10 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 @@ -2,7 +2,7 @@ -
+
@@ -58,23 +58,23 @@
- -
- - - - - - - - - +
+
+ + + + + + + + +
- + +{{$t('api_test.definition.request.pre_script')}}
+{{$t('api_test.definition.request.post_script')}} @@ -116,6 +116,7 @@ return []; } }, + referenced: Boolean, isShowEnable: Boolean, jsonPathList: Array, isReadOnly: { diff --git a/frontend/src/business/components/api/definition/components/request/http/ApiRequestForm.vue b/frontend/src/business/components/api/definition/components/request/http/ApiRequestForm.vue index 3a5af1910c..de97afb499 100644 --- a/frontend/src/business/components/api/definition/components/request/http/ApiRequestForm.vue +++ b/frontend/src/business/components/api/definition/components/request/http/ApiRequestForm.vue @@ -1,6 +1,6 @@ @@ -17,6 +17,10 @@ type: Boolean, default: true }, + referenced: { + type: Boolean, + default: false + }, isReadOnly: { type: Boolean, default: false diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index a22a3005d9..29a8fc0960 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit a22a3005d9bd254793fcf634d72539cbdf31be3a +Subproject commit 29a8fc09602fde5708af06582ac972d98eb69836