From a7f7a83031507ab723326530cf4f9aee2692df8b Mon Sep 17 00:00:00 2001 From: BugKing Date: Thu, 1 Apr 2021 09:29:58 +0800 Subject: [PATCH 01/64] =?UTF-8?q?build:=20=E5=A2=9E=E5=8A=A0=E8=87=AA?= =?UTF-8?q?=E5=8A=A8PR=E7=9A=84action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/auto-pr.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/auto-pr.yml diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml new file mode 100644 index 0000000000..289f74d0bc --- /dev/null +++ b/.github/workflows/auto-pr.yml @@ -0,0 +1,13 @@ +on: [push, pull_request, release] + +name: MeterSphere pull request handler + +jobs: + generic_handler: + name: Generic handler for MeterSphere Repos + runs-on: ubuntu-latest + steps: + - name: Add labels + uses: jumpserver/action-generic-handler@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }} \ No newline at end of file From 010b8185c8a8a9d02bcbc1e3251ab9d68713a4dd Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 1 Apr 2021 11:08:52 +0800 Subject: [PATCH 02/64] =?UTF-8?q?refactor(=E6=80=A7=E8=83=BD=E6=B5=8B?= =?UTF-8?q?=E8=AF=95):=20=E6=B5=8B=E8=AF=95=E6=8A=A5=E5=91=8A=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=B1=95=E7=A4=BAmedian=EF=BC=8C=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=90=8D=E5=AD=97=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../performance/report/components/RequestStatistics.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/business/components/performance/report/components/RequestStatistics.vue b/frontend/src/business/components/performance/report/components/RequestStatistics.vue index 06e59e8851..294c1fac27 100644 --- a/frontend/src/business/components/performance/report/components/RequestStatistics.vue +++ b/frontend/src/business/components/performance/report/components/RequestStatistics.vue @@ -61,6 +61,10 @@ prop="max" label="Max" /> + Date: Thu, 1 Apr 2021 11:04:05 +0800 Subject: [PATCH 03/64] =?UTF-8?q?refactor(=E6=80=A7=E8=83=BD=E6=B5=8B?= =?UTF-8?q?=E8=AF=95):=20=E6=B5=8B=E8=AF=95=E6=8A=A5=E5=91=8A=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=B1=95=E7=A4=BAmedian=EF=BC=8C=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=90=8D=E5=AD=97=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/metersphere/performance/base/Statistics.java | 4 +++- .../performance/report/components/RequestStatistics.vue | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/metersphere/performance/base/Statistics.java b/backend/src/main/java/io/metersphere/performance/base/Statistics.java index 119e5100c7..c53648fa44 100644 --- a/backend/src/main/java/io/metersphere/performance/base/Statistics.java +++ b/backend/src/main/java/io/metersphere/performance/base/Statistics.java @@ -9,7 +9,7 @@ public class Statistics { private String samples; - private String ko; + private String fail; private String error; @@ -19,6 +19,8 @@ public class Statistics { private String max; + private String median; + private String tp90; private String tp95; diff --git a/frontend/src/business/components/performance/report/components/RequestStatistics.vue b/frontend/src/business/components/performance/report/components/RequestStatistics.vue index 294c1fac27..4013aab85c 100644 --- a/frontend/src/business/components/performance/report/components/RequestStatistics.vue +++ b/frontend/src/business/components/performance/report/components/RequestStatistics.vue @@ -36,7 +36,7 @@ /> From ca7130a42011c489f6cf54f4e5077922df589dfb Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 1 Apr 2021 10:53:56 +0800 Subject: [PATCH 04/64] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E6=89=A7=E8=A1=8C=E6=97=B6=E7=BB=99=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E5=9C=BA=E6=99=AF=E6=AD=A5=E9=AA=A4=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=A1=B9=E7=9B=AEID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/api/dto/definition/request/MsScenario.java | 5 +++-- .../api/dto/definition/request/MsTestElement.java | 1 + .../commons/constants/MsTestElementConstants.java | 2 +- 3 files changed, 5 insertions(+), 3 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 02fc8979bd..384a5cd190 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 @@ -14,6 +14,7 @@ import io.metersphere.api.service.ApiAutomationService; import io.metersphere.api.service.ApiTestEnvironmentService; import io.metersphere.base.domain.ApiScenarioWithBLOBs; import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs; +import io.metersphere.commons.constants.MsTestElementConstants; import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.FileUtils; import io.metersphere.commons.utils.SessionUtils; @@ -77,9 +78,9 @@ public class MsScenario extends MsTestElement { if (!config.isOperating() && !this.isEnable()) { return; } - if (this.getReferenced() != null && this.getReferenced().equals("Deleted")) { + if (this.getReferenced() != null && this.getReferenced().equals(MsTestElementConstants.Deleted.name())) { return; - } else if (this.getReferenced() != null && this.getReferenced().equals("REF")) { + } else if (this.getReferenced() != null && MsTestElementConstants.REF.name().equals(this.getReferenced())) { try { ApiAutomationService apiAutomationService = CommonBeanFactory.getBean(ApiAutomationService.class); ObjectMapper mapper = new ObjectMapper(); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java index 03f2ca46a6..6ca67bba17 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java @@ -160,6 +160,7 @@ public abstract class MsTestElement { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); ApiDefinitionWithBLOBs apiDefinition = apiDefinitionService.getBLOBs(element.getId()); if (apiDefinition != null) { + element.setProjectId(apiDefinition.getProjectId()); element = mapper.readValue(apiDefinition.getRequest(), new TypeReference() { }); hashTree.add(element); diff --git a/backend/src/main/java/io/metersphere/commons/constants/MsTestElementConstants.java b/backend/src/main/java/io/metersphere/commons/constants/MsTestElementConstants.java index e3e2dbf232..81f0415d05 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/MsTestElementConstants.java +++ b/backend/src/main/java/io/metersphere/commons/constants/MsTestElementConstants.java @@ -1,5 +1,5 @@ package io.metersphere.commons.constants; public enum MsTestElementConstants { - LoopController,SCENARIO,REF + LoopController,SCENARIO,REF,Deleted } From 113cb8e93f30a4e93570427f797e0aee8e04eaf7 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 1 Apr 2021 10:59:34 +0800 Subject: [PATCH 05/64] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E9=99=90=E5=88=B6=E5=8F=AA=E6=9C=89=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E8=AF=B7=E6=B1=82=E5=8F=AF=E4=BB=A5=E5=8F=A6?= =?UTF-8?q?=E5=AD=98=E6=96=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/automation/scenario/component/StepExtendBtns.vue | 9 ++++----- frontend/src/i18n/en-US.js | 5 +++++ frontend/src/i18n/zh-CN.js | 5 +++++ frontend/src/i18n/zh-TW.js | 5 +++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/component/StepExtendBtns.vue b/frontend/src/business/components/api/automation/scenario/component/StepExtendBtns.vue index 273121e660..b7d9970906 100644 --- a/frontend/src/business/components/api/automation/scenario/component/StepExtendBtns.vue +++ b/frontend/src/business/components/api/automation/scenario/component/StepExtendBtns.vue @@ -5,11 +5,10 @@ - - 删除步骤 - 查看场景变量 - 打开场景 - 另存为接口定义 + {{this.$t('api_test.automation.delete_step')}} + {{this.$t("api_test.automation.view_scene_variables")}} + {{this.$t("api_test.automation.open_scene")}} + {{this.$t("api_test.automation.save_as_api")}} diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 3ffb614514..d98cec7e9a 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -705,6 +705,11 @@ export default { } }, automation: { + view_scene_variables: "View scene variables", + open_scene: "Open scene", + save_as_api: "Save as api", + delete_step: "Delete step", + reference_deleted_info: "Reference scene has been deleted", follow_people: "Follow people", create_tag: "Create tag", scenario_step: "Ccenario step", diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 5039195966..060b0161fe 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -706,6 +706,11 @@ export default { } }, automation: { + view_scene_variables: "查看场景变量", + open_scene: "打开场景", + save_as_api: "另存为接口定义", + delete_step: "删除步骤", + reference_deleted_info: "引用场景已经被删除", follow_people: "关注人", create_tag: "创建Tag", scenario_step: "场景步骤", diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 2a6ca86ab7..21df6e7b38 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -705,6 +705,11 @@ export default { } }, automation: { + view_scene_variables: "查看場景變量", + open_scene: "打開場景", + save_as_api: "另存為接口定義", + delete_step: "删除步骤", + reference_deleted_info: "引用場景已經被刪除", follow_people: "關註人", create_tag: "創建Tag", scenario_step: "場景步驟", From b659206b0e8b6f3f42ae867b3392872cd4709a1f Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 1 Apr 2021 13:33:11 +0800 Subject: [PATCH 06/64] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0):=20=E4=BF=AE=E5=A4=8D=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=9B=B4=E6=96=B0=E6=97=B6=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=90=8C=E5=90=8D=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProjectController.java | 6 +++--- .../io/metersphere/service/FileService.java | 7 +++++++ .../metersphere/service/ProjectService.java | 20 ++++++++++++------- .../test/components/ResourceFiles.vue | 2 +- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/io/metersphere/controller/ProjectController.java b/backend/src/main/java/io/metersphere/controller/ProjectController.java index f9feec4b15..9f4321d986 100644 --- a/backend/src/main/java/io/metersphere/controller/ProjectController.java +++ b/backend/src/main/java/io/metersphere/controller/ProjectController.java @@ -91,9 +91,9 @@ public class ProjectController { return projectService.uploadFiles(projectId, files); } - @PostMapping(value = "/update/file/{projectId}/{fileId}", consumes = {"multipart/form-data"}) - public FileMetadata updateFile(@PathVariable String projectId, @PathVariable String fileId, @RequestPart(value = "file") MultipartFile file) { - return projectService.updateFile(projectId, fileId, file); + @PostMapping(value = "/update/file/{fileId}", consumes = {"multipart/form-data"}) + public FileMetadata updateFile(@PathVariable String fileId, @RequestPart(value = "file") MultipartFile file) { + return projectService.updateFile(fileId, file); } @GetMapping(value = "delete/file/{fileId}") diff --git a/backend/src/main/java/io/metersphere/service/FileService.java b/backend/src/main/java/io/metersphere/service/FileService.java index 817ca5826d..74c095bc0f 100644 --- a/backend/src/main/java/io/metersphere/service/FileService.java +++ b/backend/src/main/java/io/metersphere/service/FileService.java @@ -43,6 +43,13 @@ public class FileService { return fileContentMapper.selectByPrimaryKey(fileId); } + public void setFileContent(String fileId, byte[] content) { + FileContent record = new FileContent(); + record .setFile(content); + record.setFileId(fileId); + fileContentMapper.updateByPrimaryKeySelective(record); + } + public void deleteFileByIds(List ids) { if (CollectionUtils.isEmpty(ids)) { return; diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index 7fea391b86..d44beaa170 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -28,6 +28,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -186,16 +187,21 @@ public class ProjectService { return result; } - public FileMetadata updateFile(String projectId, String fileId, MultipartFile file) { + public FileMetadata updateFile( String fileId, MultipartFile file) { QueryProjectFileRequest request = new QueryProjectFileRequest(); request.setName(file.getOriginalFilename()); - if (CollectionUtils.isEmpty(fileService.getProjectFiles(projectId, request))) { - fileService.deleteFileById(fileId); - return fileService.saveFile(file, projectId); - } else { - MSException.throwException(Translator.get("project_file_already_exists")); + FileMetadata fileMetadata = fileService.getFileMetadataById(fileId); + if (fileMetadata != null) { + fileMetadata.setSize(file.getSize()); + fileMetadata.setUpdateTime(System.currentTimeMillis()); + fileService.updateFileMetadata(fileMetadata); + try { + fileService.setFileContent(fileId, file.getBytes()); + } catch (IOException e) { + MSException.throwException(e); + } } - return null; + return fileMetadata; } public void deleteFile(String fileId) { diff --git a/frontend/src/business/components/performance/test/components/ResourceFiles.vue b/frontend/src/business/components/performance/test/components/ResourceFiles.vue index b05920888b..880323d75c 100644 --- a/frontend/src/business/components/performance/test/components/ResourceFiles.vue +++ b/frontend/src/business/components/performance/test/components/ResourceFiles.vue @@ -167,7 +167,7 @@ export default { } let formData = new FormData(); - let url = '/project/update/file/' + this.projectId + '/' + this.currentRow.id + let url = '/project/update/file/' + '/' + this.currentRow.id formData.append("file", file); let options = { method: 'POST', From 01bde26454f30c62626a0c04d4c522fe0f4fed55 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Thu, 1 Apr 2021 14:41:37 +0800 Subject: [PATCH 07/64] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E7=8E=87=E7=9A=84=E7=BB=9F=E8=AE=A1=E5=85=AC?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/APITestController.java | 12 ------------ .../base/mapper/ext/ExtApiDefinitionMapper.xml | 2 +- .../components/api/homepage/ApiTestHomePage.vue | 2 +- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/APITestController.java b/backend/src/main/java/io/metersphere/api/controller/APITestController.java index 185abbd176..9a0b8f1f41 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APITestController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APITestController.java @@ -288,23 +288,11 @@ public class APITestController { * 接口覆盖率 * 复制的接口定义/复制或引用的单接口用例/ 添加的自定义请求 url 路径与现有的接口定义一致的请求 */ - long startTime1 = System.currentTimeMillis(); List allScenarioInfoList = apiAutomationService.selectIdAndScenarioByProjectId(projectId); - long startTime2 = System.currentTimeMillis(); - System.out.println("Search data time : " + (startTime2 - startTime1)); - startTime1 = System.currentTimeMillis(); List allEffectiveApiIdList = apiDefinitionService.selectEffectiveIdByProjectId(projectId); - startTime2 = System.currentTimeMillis(); - System.out.println("Search data time (api info) : " + (startTime2 - startTime1)); List allEffectiveApiCaseList = apiTestCaseService.selectEffectiveTestCaseByProjectId(projectId); - long startTime3 = System.currentTimeMillis(); - System.out.println("Search data time (case info): " + (startTime3 - startTime2)); - try { - startTime1 = System.currentTimeMillis(); float intetfaceCoverageRageNumber = apiAutomationService.countInterfaceCoverage(allScenarioInfoList, allEffectiveApiIdList, allEffectiveApiCaseList); - startTime2 = System.currentTimeMillis(); - System.out.println("Count data time : " + (startTime2 - startTime1)); DecimalFormat df = new DecimalFormat("0.0"); returnStr = df.format(intetfaceCoverageRageNumber) + "%"; }catch (Exception e){ diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml index 7067ce9a49..a136fbd0af 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml @@ -468,7 +468,7 @@ diff --git a/frontend/src/business/components/api/homepage/ApiTestHomePage.vue b/frontend/src/business/components/api/homepage/ApiTestHomePage.vue index 1bd4373d58..e3610ad9b6 100644 --- a/frontend/src/business/components/api/homepage/ApiTestHomePage.vue +++ b/frontend/src/business/components/api/homepage/ApiTestHomePage.vue @@ -109,7 +109,7 @@ export default { this.$get("/api/testSceneInfoCount/" + selectProjectId, response => { this.sceneCountData = response.data; }); - + this.interfaceCoverage = "waitting..."; this.$get("/api/countInterfaceCoverage/" + selectProjectId, response => { this.interfaceCoverage = response.data; }); From c61563d3447cdea21c36c7c18eaf7bc97b0fd61a Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Wed, 31 Mar 2021 18:10:53 +0800 Subject: [PATCH 08/64] =?UTF-8?q?fix:=E5=8A=A0=E5=A4=A7case=20review?= =?UTF-8?q?=E4=B8=ADcomment=E7=9A=84=E9=95=BF=E5=BA=A6=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/components/track/review/commom/ReviewComment.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/business/components/track/review/commom/ReviewComment.vue b/frontend/src/business/components/track/review/commom/ReviewComment.vue index c849f11adc..728a19d88d 100644 --- a/frontend/src/business/components/track/review/commom/ReviewComment.vue +++ b/frontend/src/business/components/track/review/commom/ReviewComment.vue @@ -18,8 +18,8 @@ type="textarea" :placeholder="$t('test_track.comment.send_comment')" v-model="textarea" - maxlength="60" - show-word-limit + maxlength="180" + show-word-limt resize="none" :autosize="{ minRows: 4, maxRows: 4}" @keyup.ctrl.enter.native="sendComment" From a04e13cb8b9b14d361dff98f258c7d950df3eb8a Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Thu, 1 Apr 2021 15:43:27 +0800 Subject: [PATCH 09/64] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AF=84=E5=AE=A1t?= =?UTF-8?q?ags=E3=80=81=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92tags):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=AF=84=E5=AE=A1=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E8=AE=A1=E5=88=92=E6=A0=87=E7=AD=BE=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/plan/components/TestPlanEdit.vue | 12 ++++++++++-- .../track/review/components/TestCaseReviewEdit.vue | 11 ++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/frontend/src/business/components/track/plan/components/TestPlanEdit.vue b/frontend/src/business/components/track/plan/components/TestPlanEdit.vue index 1773b19e59..995d24e258 100644 --- a/frontend/src/business/components/track/plan/components/TestPlanEdit.vue +++ b/frontend/src/business/components/track/plan/components/TestPlanEdit.vue @@ -8,7 +8,7 @@ @close="close" width="65%"> - + @@ -31,7 +31,7 @@ @@ -134,6 +134,7 @@ export default { components: {TestPlanStatusButton, MsInputTag}, data() { return { + isStepTableAlive: true, dialogFormVisible: false, form: { name: '', @@ -159,6 +160,10 @@ export default { }; }, methods: { + reload() { + this.isStepTableAlive = false; + this.$nextTick(() => (this.isStepTableAlive = true)); + }, openTestPlanEditDialog(testPlan) { this.resetForm(); this.setPrincipalOptions(); @@ -169,9 +174,12 @@ export default { let tmp = {}; Object.assign(tmp, testPlan); Object.assign(this.form, tmp); + } else { + this.form.tags = [] } listenGoBack(this.close); this.dialogFormVisible = true; + this.reload() }, testPlanInfo() { this.$refs['planFrom'].validate((valid) => { diff --git a/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue b/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue index bd18176244..9649021f33 100644 --- a/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue +++ b/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue @@ -7,7 +7,8 @@ :visible.sync="dialogFormVisible" @close="close" v-loading="result.loading" - width="65%"> + width="65%" + v-if="isStepTableAlive"> @@ -109,6 +110,7 @@ export default { components: {MsInputTag, TestPlanStatusButton}, data() { return { + isStepTableAlive: true, dialogFormVisible: false, result: {}, form: { @@ -137,6 +139,10 @@ export default { }; }, methods: { + reload() { + this.isStepTableAlive = false; + this.$nextTick(() => (this.isStepTableAlive = true)); + }, openCaseReviewEditDialog(caseReview) { this.resetForm(); this.setReviewerOptions(); @@ -148,9 +154,12 @@ export default { Object.assign(tmp, caseReview); Object.assign(this.form, tmp); this.dbProjectIds = JSON.parse(JSON.stringify(this.form.projectIds)); + } else { + this.form.tags = [] } listenGoBack(this.close); this.dialogFormVisible = true; + this.reload() }, reviewInfo() { From b503122a8a7ad2352aa631c10b2d6ed28bc58400 Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Thu, 1 Apr 2021 15:54:10 +0800 Subject: [PATCH 10/64] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AF=84=E5=AE=A1t?= =?UTF-8?q?ags=E3=80=81=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92tags):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=AF=84=E5=AE=A1=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E8=AE=A1=E5=88=92=E6=A0=87=E7=AD=BE=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/track/plan/components/TestPlanEdit.vue | 4 ++-- .../components/track/review/components/TestCaseReviewEdit.vue | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/business/components/track/plan/components/TestPlanEdit.vue b/frontend/src/business/components/track/plan/components/TestPlanEdit.vue index 995d24e258..1c4d6557e9 100644 --- a/frontend/src/business/components/track/plan/components/TestPlanEdit.vue +++ b/frontend/src/business/components/track/plan/components/TestPlanEdit.vue @@ -175,11 +175,11 @@ export default { Object.assign(tmp, testPlan); Object.assign(this.form, tmp); } else { - this.form.tags = [] + this.form.tags = []; } listenGoBack(this.close); this.dialogFormVisible = true; - this.reload() + this.reload(); }, testPlanInfo() { this.$refs['planFrom'].validate((valid) => { diff --git a/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue b/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue index 9649021f33..283d4b2263 100644 --- a/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue +++ b/frontend/src/business/components/track/review/components/TestCaseReviewEdit.vue @@ -155,11 +155,11 @@ export default { Object.assign(this.form, tmp); this.dbProjectIds = JSON.parse(JSON.stringify(this.form.projectIds)); } else { - this.form.tags = [] + this.form.tags = []; } listenGoBack(this.close); this.dialogFormVisible = true; - this.reload() + this.reload(); }, reviewInfo() { From 5750f3061f90e39be66e035a51d3725154446b7c Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 1 Apr 2021 14:35:45 +0800 Subject: [PATCH 11/64] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E5=9C=BA=E6=99=AF=E5=90=8D=E7=A7=B0=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=EF=BC=8C=E6=89=A7=E8=A1=8C=E6=8A=A5=E5=91=8A=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=8F=98=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/dto/definition/request/MsScenario.java | 1 + .../metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) 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 384a5cd190..6267b7ee35 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 @@ -88,6 +88,7 @@ public class MsScenario extends MsTestElement { ApiScenarioWithBLOBs scenario = apiAutomationService.getApiScenario(this.getId()); if (scenario != null && StringUtils.isNotEmpty(scenario.getScenarioDefinition())) { JSONObject element = JSON.parseObject(scenario.getScenarioDefinition()); + this.setName(scenario.getName()); hashTree = mapper.readValue(element.getString("hashTree"), new TypeReference>() { }); // 场景变量 diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml index 93463a6929..c07f7d4c0f 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml @@ -100,9 +100,10 @@ SELECT * FROM api_test_case WHERE api_test_case.api_definition_id = #{definitionId} ORDER BY num DESC LIMIT 1; - - \ No newline at end of file + diff --git a/frontend/package.json b/frontend/package.json index d67ac0605e..2ab2e30b6e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -49,7 +49,7 @@ "vue-float-action-button": "^0.6.6", "vue-i18n": "^8.15.3", "vue-jsonpath-picker": "^1.1.5", - "vue-minder-editor-plus": "^1.0.19", + "vue-minder-editor-plus": "^1.0.21", "vue-papa-parse": "^2.0.0", "vue-pdf": "^4.2.0", "vue-router": "^3.1.3", diff --git a/frontend/src/business/components/common/components/MsModuleMinder.vue b/frontend/src/business/components/common/components/MsModuleMinder.vue index 51178116a6..2d1451b384 100644 --- a/frontend/src/business/components/common/components/MsModuleMinder.vue +++ b/frontend/src/business/components/common/components/MsModuleMinder.vue @@ -9,6 +9,7 @@ :tags="tags" :height="height" :distinct-tags="distinctTags" + @afterMount="$emit('afterMount')" @save="save" /> @@ -17,6 +18,7 @@ From c3e636c95333a0bf5361b05400625d16798419e5 Mon Sep 17 00:00:00 2001 From: wenyann Date: Thu, 8 Apr 2021 11:43:14 +0800 Subject: [PATCH 53/64] =?UTF-8?q?fix:=20=E6=B5=8B=E8=AF=95=E8=AE=A1?= =?UTF-8?q?=E5=88=92=EF=BC=8C=E5=85=B3=E8=81=94=E6=B5=8B=E8=AF=95=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E9=97=AE=E9=A2=98,=E6=96=B0=E5=BB=BA=E7=94=A8?= =?UTF-8?q?=E4=BE=8B-=E7=BC=96=E8=BE=91=EF=BC=8C=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E7=BB=99=E7=94=A8=E4=BE=8B=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=AD=A5=E9=AA=A4,=E6=89=A7=E8=A1=8C=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E5=BA=94=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=A4=87=E6=B3=A8=E5=92=8C=E9=99=84=E4=BB=B6?= =?UTF-8?q?,=E4=BB=A5=E5=8F=8A=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/controller/TestCaseController.java | 6 +++ .../track/service/TestCaseService.java | 40 ++++++++++++++++++- .../track/case/components/TestCaseEdit.vue | 6 ++- .../functional/FunctionalTestCaseEdit.vue | 2 +- 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java index e504263ec8..19456e0fa6 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java @@ -128,6 +128,12 @@ public class TestCaseController { return testCaseService.edit(request, files); } + @PostMapping(value = "/edit/testPlan", consumes = {"multipart/form-data"}) + @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + public String editTestCaseByTestPlan(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file") List files) { + return testCaseService.editTestCase(request, files); + } + @PostMapping("/delete/{testCaseId}") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) public int deleteTestCase(@PathVariable String testCaseId) { 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 fba30e63e6..11c9135293 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -91,7 +91,6 @@ public class TestCaseService { TestCaseFileMapper testCaseFileMapper; @Resource TestCaseTestMapper testCaseTestMapper; - private void setNode(TestCaseWithBLOBs testCase){ if (StringUtils.isEmpty(testCase.getNodeId()) || "default-module".equals(testCase.getNodeId())) { TestCaseNodeExample example = new TestCaseNodeExample(); @@ -131,7 +130,6 @@ public class TestCaseService { public int editTestCase(TestCaseWithBLOBs testCase) { testCase.setUpdateTime(System.currentTimeMillis()); - checkTestCaseExist(testCase); return testCaseMapper.updateByPrimaryKeySelective(testCase); } @@ -842,6 +840,44 @@ public class TestCaseService { return request.getId(); } + public String editTestCase(EditTestCaseRequest request, List files) { + String testCaseId = testPlanTestCaseMapper.selectByPrimaryKey(request.getId()).getCaseId(); + request.setId(testCaseId); + TestCaseWithBLOBs testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(testCaseId); + if (testCaseWithBLOBs == null) { + MSException.throwException(Translator.get("edit_load_test_not_found") + request.getId()); + } + testCaseWithBLOBs.setRemark(request.getRemark()); + // 新选择了一个文件,删除原来的文件 + List updatedFiles = request.getUpdatedFileList(); + List originFiles = fileService.getFileMetadataByCaseId(testCaseId); + List updatedFileIds = updatedFiles.stream().map(FileMetadata::getId).collect(Collectors.toList()); + List originFileIds = originFiles.stream().map(FileMetadata::getId).collect(Collectors.toList()); + // 相减 + List deleteFileIds = ListUtils.subtract(originFileIds, updatedFileIds); + fileService.deleteFileRelatedByIds(deleteFileIds); + + if (!CollectionUtils.isEmpty(deleteFileIds)) { + TestCaseFileExample testCaseFileExample = new TestCaseFileExample(); + testCaseFileExample.createCriteria().andFileIdIn(deleteFileIds); + testCaseFileMapper.deleteByExample(testCaseFileExample); + } + + + if (files != null) { + files.forEach(file -> { + final FileMetadata fileMetadata = fileService.saveFile(file, testCaseWithBLOBs.getProjectId()); + TestCaseFile testCaseFile = new TestCaseFile(); + testCaseFile.setFileId(fileMetadata.getId()); + testCaseFile.setCaseId(testCaseId); + testCaseFileMapper.insert(testCaseFile); + }); + } + this.setNode(request); + editTestCase(request); + return request.getId(); + } + public List listTestCaseIds(QueryTestCaseRequest request) { List orderList = ServiceUtils.getDefaultOrder(request.getOrders()); OrderRequest order = new OrderRequest(); diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index 9d0d1d0dce..bfc578213b 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -661,7 +661,11 @@ export default { Object.assign(tmp, testCase); tmp.steps = JSON.parse(testCase.steps); if (tmp.steps == null) { - tmp.steps = [] + tmp.steps = [{ + num: 1, + desc: '', + result: '' + }]; } tmp.tags = JSON.parse(tmp.tags); Object.assign(this.form, tmp); diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseEdit.vue b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseEdit.vue index 62861f34c4..fbee3392c1 100644 --- a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseEdit.vue +++ b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseEdit.vue @@ -509,7 +509,7 @@ export default { }); formData.append('request', new Blob([requestJson], { - type: "application/json "; + type: "application/json " })); return { From be6883095594fd1b444a730ac1f7920368ea5346 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Tue, 6 Apr 2021 23:00:57 +0800 Subject: [PATCH 54/64] =?UTF-8?q?fix(=E5=9C=BA=E6=99=AF=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E7=A6=81=E7=94=A8=E5=9C=BA=E6=99=AF=E6=AD=A5?= =?UTF-8?q?=E9=AA=A4=E4=BB=8D=E8=A6=81=E6=B1=82=E9=80=89=E6=8B=A9=E7=8E=AF?= =?UTF-8?q?=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiAutomationService.java | 46 +- .../automation/scenario/EditApiScenario.vue | 59 ++- .../api/automation/scenario/EnvPopover.vue | 8 +- .../api/automation/scenario/EnvSelect.vue | 432 +++++++++--------- .../scenario/maximize/ScenarioHeader.vue | 29 +- .../scenario/testplan/TestPlanList.vue | 4 +- .../track/case/components/BatchEdit.vue | 3 +- .../components/track/common/EnvPopover.vue | 57 +++ .../components/track/common/EnvSelect.vue | 285 ++++++++++++ .../comonents/api/RelevanceScenarioList.vue | 2 +- .../ReviewRelevanceScenarioList.vue | 2 +- 11 files changed, 666 insertions(+), 261 deletions(-) create mode 100644 frontend/src/business/components/track/common/EnvPopover.vue create mode 100644 frontend/src/business/components/track/common/EnvSelect.vue 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 d2e475ea11..f3d2dd1433 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -392,9 +392,11 @@ public class ApiAutomationService { ApiDefinition apiDefinition = apiDefinitionService.get(tr.getId()); http.setUrl(apiDefinition.getPath()); } - if (StringUtils.isBlank(http.getUrl()) || !isURL(http.getUrl())) { - env.getProjectIds().add(http.getProjectId()); - env.setFullUrl(false); + if (http.isEnable()) { + if (StringUtils.isBlank(http.getUrl()) || !isURL(http.getUrl())) { + env.getProjectIds().add(http.getProjectId()); + env.setFullUrl(false); + } } } else if (StringUtils.equals(tr.getType(), "TCPSampler")) { if (StringUtils.equals(tr.getRefType(), "CASE")) { @@ -405,11 +407,13 @@ public class ApiAutomationService { env.getProjectIds().add(apiDefinition.getProjectId()); } } else if (StringUtils.equals(tr.getType(), "scenario")) { - ApiScenarioDTO apiScenario = getApiScenario(tr.getId()); - String scenarioDefinition = apiScenario.getScenarioDefinition(); - JSONObject element1 = JSON.parseObject(scenarioDefinition); - LinkedList hashTree1 = mapper.readValue(element1.getString("hashTree"), new TypeReference>(){}); - tr.setHashTree(hashTree1); + if (tr.isEnable()) { + ApiScenarioDTO apiScenario = getApiScenario(tr.getId()); + String scenarioDefinition = apiScenario.getScenarioDefinition(); + JSONObject element1 = JSON.parseObject(scenarioDefinition); + LinkedList hashTree1 = mapper.readValue(element1.getString("hashTree"), new TypeReference>(){}); + tr.setHashTree(hashTree1); + } } } else { if (StringUtils.equals(tr.getType(), "HTTPSamplerProxy")) { @@ -425,6 +429,9 @@ public class ApiAutomationService { env.getProjectIds().add(tr.getProjectId()); } } + if (!tr.isEnable()) { + continue; + } if (CollectionUtils.isNotEmpty(tr.getHashTree())) { getHashTree(tr.getHashTree(), env); } @@ -452,9 +459,11 @@ public class ApiAutomationService { ApiDefinition apiDefinition = apiDefinitionService.get(tr.getId()); http.setUrl(apiDefinition.getPath()); } - if (StringUtils.isBlank(http.getUrl()) || !this.isURL(http.getUrl())) { - env.setFullUrl(false); - env.getProjectIds().add(http.getProjectId()); + if (http.isEnable()) { + if (StringUtils.isBlank(http.getUrl()) || !this.isURL(http.getUrl())) { + env.setFullUrl(false); + env.getProjectIds().add(http.getProjectId()); + } } } else if (StringUtils.equals(tr.getType(), "TCPSampler")) { if (StringUtils.equals(tr.getRefType(), "CASE")) { @@ -465,11 +474,13 @@ public class ApiAutomationService { env.getProjectIds().add(apiDefinition.getProjectId()); } } else if (StringUtils.equals(tr.getType(), "scenario")) { - ApiScenarioDTO apiScenario = getApiScenario(tr.getId()); - String scenarioDefinition = apiScenario.getScenarioDefinition(); - JSONObject element1 = JSON.parseObject(scenarioDefinition); - LinkedList hashTree1 = mapper.readValue(element1.getString("hashTree"), new TypeReference>(){}); - tr.setHashTree(hashTree1); + if (tr.isEnable()) { + ApiScenarioDTO apiScenario = getApiScenario(tr.getId()); + String scenarioDefinition = apiScenario.getScenarioDefinition(); + JSONObject element1 = JSON.parseObject(scenarioDefinition); + LinkedList hashTree1 = mapper.readValue(element1.getString("hashTree"), new TypeReference>(){}); + tr.setHashTree(hashTree1); + } } } else { if (StringUtils.equals(tr.getType(), "HTTPSamplerProxy")) { @@ -485,6 +496,9 @@ public class ApiAutomationService { env.getProjectIds().add(tr.getProjectId()); } } + if (!tr.isEnable()) { + continue; + } if (CollectionUtils.isNotEmpty(tr.getHashTree())) { getHashTree(tr.getHashTree(), env); } diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 24e5687ee8..0b4a5b977c 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -121,7 +121,7 @@ + @showPopover="showPopover" :project-list="projectList" ref="envPopover"/> {{$t('api_test.request.debug')}} @@ -205,8 +205,8 @@ { this.loading = false }); - let definition = JSON.parse(JSON.stringify(this.currentScenario)); - definition.hashTree = this.scenarioDefinition; - this.getEnv(JSON.stringify(definition)); + // let definition = JSON.parse(JSON.stringify(this.currentScenario)); + // definition.hashTree = this.scenarioDefinition; + // this.getEnv(JSON.stringify(definition)); }, runDebug() { /*触发执行操作*/ @@ -789,24 +789,28 @@ let definition = JSON.parse(JSON.stringify(this.currentScenario)); definition.hashTree = this.scenarioDefinition; this.getEnv(JSON.stringify(definition)).then(() => { - let sign = this.$refs.envPopover.checkEnv(this.isFullUrl); - if (!sign) { - return; - } - this.editScenario().then(() => { - this.debugData = { - id: this.currentScenario.id, - name: this.currentScenario.name, - type: "scenario", - variables: this.currentScenario.variables, - referenced: 'Created', - enableCookieShare: this.enableCookieShare, - headers: this.currentScenario.headers, - environmentMap: this.projectEnvMap, - hashTree: this.scenarioDefinition - }; - this.reportId = getUUID().substring(0, 8); + let promise = this.$refs.envPopover.initEnv(); + promise.then(() => { + let sign = this.$refs.envPopover.checkEnv(this.isFullUrl); + if (!sign) { + return; + } + this.editScenario().then(() => { + this.debugData = { + id: this.currentScenario.id, + name: this.currentScenario.name, + type: "scenario", + variables: this.currentScenario.variables, + referenced: 'Created', + enableCookieShare: this.enableCookieShare, + headers: this.currentScenario.headers, + environmentMap: this.projectEnvMap, + hashTree: this.scenarioDefinition + }; + this.reportId = getUUID().substring(0, 8); + }) }) + }) } }) @@ -1002,7 +1006,7 @@ if (response.data) { this.path = "/api/automation/update"; if (response.data.scenarioDefinition != null) { - this.getEnv(response.data.scenarioDefinition); + // this.getEnv(response.data.scenarioDefinition); let obj = JSON.parse(response.data.scenarioDefinition); if (obj) { this.currentEnvironmentId = obj.environmentId; @@ -1138,6 +1142,13 @@ close(name) { this.drawer = false; this.$emit('closePage', name); + }, + showPopover() { + let definition = JSON.parse(JSON.stringify(this.currentScenario)); + definition.hashTree = this.scenarioDefinition; + this.getEnv(JSON.stringify(definition)).then(() => { + this.$refs.envPopover.openEnvSelect(); + }) } } } diff --git a/frontend/src/business/components/api/automation/scenario/EnvPopover.vue b/frontend/src/business/components/api/automation/scenario/EnvPopover.vue index 32580f3be9..83072dd7cc 100644 --- a/frontend/src/business/components/api/automation/scenario/EnvPopover.vue +++ b/frontend/src/business/components/api/automation/scenario/EnvPopover.vue @@ -39,11 +39,17 @@ export default { }, methods: { showPopover() { - this.$refs.envSelect.open(); + this.$emit("showPopover"); + }, + openEnvSelect() { + return this.$refs.envSelect.open(); }, setProjectEnvMap(map) { this.$emit("setProjectEnvMap", map); }, + initEnv() { + return this.$refs.envSelect.initEnv(); + }, checkEnv(data) { return this.$refs.envSelect.checkEnv(data); } diff --git a/frontend/src/business/components/api/automation/scenario/EnvSelect.vue b/frontend/src/business/components/api/automation/scenario/EnvSelect.vue index 1ea30c2a20..23b8e387cf 100644 --- a/frontend/src/business/components/api/automation/scenario/EnvSelect.vue +++ b/frontend/src/business/components/api/automation/scenario/EnvSelect.vue @@ -5,12 +5,14 @@ - + {{ $t('api_test.environment.environment_config') }} diff --git a/frontend/src/business/components/api/automation/scenario/maximize/ScenarioHeader.vue b/frontend/src/business/components/api/automation/scenario/maximize/ScenarioHeader.vue index 2588a23bb2..e22f8f7711 100644 --- a/frontend/src/business/components/api/automation/scenario/maximize/ScenarioHeader.vue +++ b/frontend/src/business/components/api/automation/scenario/maximize/ScenarioHeader.vue @@ -19,7 +19,7 @@ 共享cookie + @showPopover="showPopover" :project-list="projectList" ref="envPopover" class="ms-right"/> {{$t('api_test.request.debug')}} @@ -37,7 +37,12 @@ export default { name: "ScenarioHeader", components: {EnvPopover}, - props: {currentScenario: {}, scenarioDefinition: Array, enableCookieShare: Boolean, projectEnvMap: Map, projectIds: Set, projectList: Array}, + props: {currentScenario: {}, scenarioDefinition: Array, enableCookieShare: Boolean, + projectEnvMap: Map, + projectIds: Set, + projectList: Array, + isFullUrl: Boolean + }, data() { return { envMap: new Map, @@ -102,7 +107,25 @@ setProjectEnvMap(projectEnvMap) { this.$emit('setProjectEnvMap', projectEnvMap); this.envMap = projectEnvMap; - } + }, + showPopover() { + let definition = JSON.parse(JSON.stringify(this.currentScenario)); + definition.hashTree = this.scenarioDefinition; + this.getEnv(JSON.stringify(definition)).then(() => { + this.$refs.envPopover.openEnvSelect(); + }) + }, + getEnv(definition) { + return new Promise((resolve) => { + this.$post("/api/automation/getApiScenarioEnv", {definition: definition}, res => { + if (res.data) { + this.$emit("update:projectIds", new Set(res.data.projectIds)) + this.$emit("update:isFullUrl", res.data.fullUrl) + } + resolve(); + }) + }); + }, }, } diff --git a/frontend/src/business/components/api/automation/scenario/testplan/TestPlanList.vue b/frontend/src/business/components/api/automation/scenario/testplan/TestPlanList.vue index af4b987937..2e3f7a0249 100644 --- a/frontend/src/business/components/api/automation/scenario/testplan/TestPlanList.vue +++ b/frontend/src/business/components/api/automation/scenario/testplan/TestPlanList.vue @@ -152,9 +152,7 @@ import {TEST_PLAN_CONFIGS} from "../../../../common/components/search/search-com import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent"; import {getCurrentProjectID} from "../../../../../../common/js/utils"; import {_filter, _sort} from "@/common/js/tableUtils"; -import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover"; - - +import EnvPopover from "@/business/components/track/common/EnvPopover"; export default { name: "TestPlanList", components: { diff --git a/frontend/src/business/components/track/case/components/BatchEdit.vue b/frontend/src/business/components/track/case/components/BatchEdit.vue index 3c4a5fb55b..4f5c8e63c2 100644 --- a/frontend/src/business/components/track/case/components/BatchEdit.vue +++ b/frontend/src/business/components/track/case/components/BatchEdit.vue @@ -41,8 +41,7 @@ + + diff --git a/frontend/src/business/components/track/common/EnvSelect.vue b/frontend/src/business/components/track/common/EnvSelect.vue new file mode 100644 index 0000000000..f88f2b53a7 --- /dev/null +++ b/frontend/src/business/components/track/common/EnvSelect.vue @@ -0,0 +1,285 @@ + + + + + diff --git a/frontend/src/business/components/track/plan/view/comonents/api/RelevanceScenarioList.vue b/frontend/src/business/components/track/plan/view/comonents/api/RelevanceScenarioList.vue index 1ca672c50c..9c5e67ae5f 100644 --- a/frontend/src/business/components/track/plan/view/comonents/api/RelevanceScenarioList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/api/RelevanceScenarioList.vue @@ -68,7 +68,7 @@ import MsTestPlanList from "../../../../../api/automation/scenario/testplan/TestPlanList"; import TestPlanScenarioListHeader from "./TestPlanScenarioListHeader"; import {_handleSelect, _handleSelectAll} from "../../../../../../../common/js/tableUtils"; - import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover"; + import EnvPopover from "@/business/components/track/common/EnvPopover"; export default { name: "RelevanceScenarioList", diff --git a/frontend/src/business/components/track/review/view/components/ReviewRelevanceScenarioList.vue b/frontend/src/business/components/track/review/view/components/ReviewRelevanceScenarioList.vue index 8dfa06769a..fe798b6389 100644 --- a/frontend/src/business/components/track/review/view/components/ReviewRelevanceScenarioList.vue +++ b/frontend/src/business/components/track/review/view/components/ReviewRelevanceScenarioList.vue @@ -56,7 +56,7 @@