From 291164f15ceaa347252feeb0f9812f913fa73ee2 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 4 Feb 2021 17:54:05 +0800 Subject: [PATCH 01/18] =?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=E6=AD=A5=E9=AA=A4=E4=B8=AD?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8E=A5=E5=8F=A3=E6=97=B6=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E5=8F=A6=E5=AD=98=E7=94=A8=E4=BE=8B=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/definition/components/debug/DebugDubboPage.vue | 3 ++- .../api/definition/components/debug/DebugHttpPage.vue | 1 + .../api/definition/components/debug/DebugJdbcPage.vue | 6 ++++-- .../api/definition/components/debug/DebugTcpPage.vue | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/src/business/components/api/definition/components/debug/DebugDubboPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugDubboPage.vue index 508f84f008..2554516739 100644 --- a/frontend/src/business/components/api/definition/components/debug/DebugDubboPage.vue +++ b/frontend/src/business/components/api/definition/components/debug/DebugDubboPage.vue @@ -2,7 +2,8 @@
- {{$t('commons.test')}} + {{$t('commons.test')}} diff --git a/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue index ac34fc7110..4e2bc6434d 100644 --- a/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue +++ b/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue @@ -15,6 +15,7 @@ + {{$t('commons.test')}} {{$t('commons.test')}} diff --git a/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue index b1bd7200ab..f3df5afb88 100644 --- a/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue +++ b/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue @@ -2,7 +2,9 @@
- {{$t('commons.test')}} + + {{$t('commons.test')}} @@ -49,7 +51,7 @@ export default { name: "ApiConfig", - components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters, MsJmxStep,MsApiCaseList}, + components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters, MsJmxStep, MsApiCaseList}, props: { currentProtocol: String, scenario: Boolean, diff --git a/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue index fc5dca9356..b94dc61d51 100644 --- a/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue +++ b/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue @@ -11,7 +11,9 @@ - {{$t('commons.test')}} + + {{$t('commons.test')}} From 039898c6355f30b83c4fbf76f768f6584cba1bb9 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 4 Feb 2021 19:12:36 +0800 Subject: [PATCH 02/18] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E5=BE=AA=E7=8E=AF=E7=BB=93=E6=9E=9C=E6=94=BE?= =?UTF-8?q?=E5=88=B0=E5=90=84=E8=87=AA=E8=AF=B7=E6=B1=82=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scenario/component/ApiComponent.vue | 20 +++++++- .../scenario/component/LoopController.vue | 49 ++++++++++++------- 2 files changed, 48 insertions(+), 21 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index bab86e7b27..abe40bbd6f 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -34,7 +34,16 @@

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

- +
+ + +
+ +
+
+
+
+ @@ -86,6 +95,7 @@ if (!this.request.requestResult) { this.request.requestResult = {responseResult: {}}; } + console.log(this.request) // 加载引用对象数据 this.getApiInfo(); if (this.request.protocol === 'HTTP') { @@ -155,7 +165,7 @@ return true } return false; - } + }, }, methods: { remove() { @@ -247,6 +257,7 @@ }, runRefresh(data) { this.request.requestResult = data; + this.request.result = undefined; this.loading = false; }, reload() { @@ -289,4 +300,9 @@ .icon.is-active { transform: rotate(90deg); } + + .ms-tabs >>> .el-icon-close:before { + content: ""; + + } diff --git a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue index 85a6931c48..b376bcb119 100644 --- a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue +++ b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue @@ -79,17 +79,17 @@ ms
-

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

-
- - -
- -
-
-
+ + + + + + + + + -
+ @@ -117,7 +117,7 @@ }, }, created() { - this.initResult(); + // this.initResult(); }, data() { return { @@ -202,7 +202,6 @@ this.$warning("当前循环下没有请求,不能执行") return; } - this.controller.active = true; this.loading = true; this.debugData = { id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario", @@ -224,7 +223,7 @@ }, changeRadio() { this.controller.active = true; - this.initResult(); + //this.initResult(); this.reload(); }, change(value) { @@ -258,6 +257,20 @@ this.success = this.requestResult.scenarios && this.requestResult.scenarios != null ? this.requestResult.scenarios.length - this.error : 0; } }, + setResult(hashTree) { + if (hashTree) { + hashTree.forEach(item => { + if (item.type === "HTTPSamplerProxy" || item.type === "DubboSampler" || item.type === "JDBCSampler" || item.type === "TCPSampler") { + item.result = this.requestResult; + item.activeName = this.activeName; + item.requestResult = undefined; + } + if (item.hashTree && item.hashTree.length > 0) { + this.setResult(item.hashTree); + } + }) + } + }, getReport() { if (this.reportId) { let url = "/api/scenario/report/get/" + this.reportId; @@ -285,11 +298,14 @@ break; } this.getFails(); + this.activeName = this.requestResult && this.requestResult.scenarios && this.requestResult.scenarios != null && this.requestResult.scenarios.length > 0 ? this.requestResult.scenarios[0].name : ""; + // 把请求结果分给各个请求 + this.setResult(this.controller.hashTree); } catch (e) { throw e; } this.loading = false; - this.activeName = this.requestResult && this.requestResult.scenarios && this.requestResult.scenarios != null && this.requestResult.scenarios.length > 0 ? this.requestResult.scenarios[0].name : ""; + this.reload(); } else { setTimeout(this.getReport, 2000) } @@ -333,11 +349,6 @@ margin: 20px 0; } - .ms-tabs >>> .el-icon-close:before { - content: ""; - - } - .icon.is-active { transform: rotate(90deg); } From d1a9332188703a10a9718c3d535a9c96801a0f42 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 5 Feb 2021 09:50:56 +0800 Subject: [PATCH 03/18] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E5=B1=95=E5=BC=80=E6=AD=A5?= =?UTF-8?q?=E9=AA=A4=E6=97=B6=E5=8D=A1=E6=AD=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/scenario/common/ApiBaseComponent.vue | 3 ++- .../automation/scenario/component/ApiComponent.vue | 2 +- .../scenario/component/ApiScenarioComponent.vue | 1 + .../automation/scenario/component/Jsr233Processor.vue | 5 +++++ .../automation/scenario/component/LoopController.vue | 1 + .../definition/components/assertion/ApiAssertions.vue | 2 +- .../api/definition/components/extract/ApiExtract.vue | 11 ++++++++--- 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue b/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue index d2a439c0f7..d6b4ebb9fd 100644 --- a/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue @@ -107,7 +107,8 @@ }, methods: { active() { - this.$set(this.data, 'active', !this.data.active); + // 这种写法性能极差,不要再放开了 + //this.$set(this.data, 'active', !this.data.active); this.$emit('active'); }, copyRow() { diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index abe40bbd6f..6ea4c3543c 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -3,6 +3,7 @@ v-loading="loading" @copy="copyRow" @remove="remove" + @active="active" :is-show-name-input="!isDeletedOrRef" :data="request" :draggable="true" @@ -95,7 +96,6 @@ if (!this.request.requestResult) { this.request.requestResult = {responseResult: {}}; } - console.log(this.request) // 加载引用对象数据 this.getApiInfo(); if (this.request.protocol === 'HTTP') { diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue index 8604026beb..ae6690aac9 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue @@ -3,6 +3,7 @@ v-loading="loading" @copy="copyRow" @remove="remove" + @active="active" :data="scenario" :show-collapse="false" :is-show-name-input="!isDeletedOrRef" diff --git a/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue b/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue index 1a5bbd8562..c03c1d7bae 100644 --- a/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue +++ b/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue @@ -2,6 +2,7 @@ diff --git a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue index b376bcb119..be8df59a1e 100644 --- a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue +++ b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue @@ -301,6 +301,7 @@ this.activeName = this.requestResult && this.requestResult.scenarios && this.requestResult.scenarios != null && this.requestResult.scenarios.length > 0 ? this.requestResult.scenarios[0].name : ""; // 把请求结果分给各个请求 this.setResult(this.controller.hashTree); + this.$emit('refReload'); } catch (e) { throw e; } diff --git a/frontend/src/business/components/api/definition/components/assertion/ApiAssertions.vue b/frontend/src/business/components/api/definition/components/assertion/ApiAssertions.vue index 82626640a9..d825f5cb74 100644 --- a/frontend/src/business/components/api/definition/components/assertion/ApiAssertions.vue +++ b/frontend/src/business/components/api/definition/components/assertion/ApiAssertions.vue @@ -131,7 +131,7 @@ }) }, active() { - // item.active = !item.active; + this.assertions.active = !this.assertions.active; this.reload(); }, remove() { diff --git a/frontend/src/business/components/api/definition/components/extract/ApiExtract.vue b/frontend/src/business/components/api/definition/components/extract/ApiExtract.vue index ed83fddc78..d8637ff3e6 100644 --- a/frontend/src/business/components/api/definition/components/extract/ApiExtract.vue +++ b/frontend/src/business/components/api/definition/components/extract/ApiExtract.vue @@ -2,12 +2,13 @@ -
+
{{$t('api_test.request.extract.description')}}
@@ -99,8 +100,8 @@ this.loading = false }) }, - active(item) { - item.active = !item.active; + active() { + this.extract.active = !this.extract.active; this.reload(); }, suggestJsonOpen() { @@ -157,6 +158,10 @@ border-radius: 5px; } + .icon.is-active { + transform: rotate(90deg); + } + /deep/ .el-card__body { padding: 15px; } From d258d7b6935d2f3d9c3bdc9e96fd52b7b2025219 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 5 Feb 2021 10:00:55 +0800 Subject: [PATCH 04/18] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8DJSR233=20=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/scenario/component/Jsr233Processor.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue b/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue index c03c1d7bae..3615531879 100644 --- a/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue +++ b/frontend/src/business/components/api/automation/scenario/component/Jsr233Processor.vue @@ -7,7 +7,7 @@ :draggable="draggable" :color="color" :background-color="backgroundColor" - :title="title"> + :title="title" v-loading="loading"> { + this.loading = false + }) + }, active() { this.jsr223Processor.active = !this.jsr223Processor.active; this.reload(); From f298817c917dec99b1e355423fd70844a91983a7 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Fri, 5 Feb 2021 15:38:19 +0800 Subject: [PATCH 05/18] =?UTF-8?q?refactor:=20=E7=BB=9F=E4=B8=80=E5=A4=84?= =?UTF-8?q?=E7=90=86sql=E5=BC=82=E5=B8=B8=EF=BC=8C=E4=B8=8D=E5=9C=A8?= =?UTF-8?q?=E5=89=8D=E5=8F=B0=E6=98=BE=E7=A4=BA=EF=BC=8C=E6=8F=90=E7=A4=BA?= =?UTF-8?q?sql=E9=94=99=E8=AF=AF=EF=BC=8C=E6=A3=80=E6=9F=A5=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/handler/RestControllerExceptionHandler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java b/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java index 411ccc6c42..6534abf2fe 100644 --- a/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java +++ b/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.sql.SQLException; @RestControllerAdvice @@ -30,6 +31,12 @@ public class RestControllerExceptionHandler { } + @ExceptionHandler(SQLException.class) + public ResultHolder sqlExceptionHandler(HttpServletRequest request, HttpServletResponse response, MSException e) { + response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); + return ResultHolder.error("SQL error happened, please check logs."); + } + @ExceptionHandler(MSException.class) public ResultHolder msExceptionHandler(HttpServletRequest request, HttpServletResponse response, MSException e) { response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); From 6c188f3f885c85f114257e76a3a99a0747e4b0d1 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 5 Feb 2021 16:38:03 +0800 Subject: [PATCH 06/18] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E5=BD=93=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E6=9C=AA=E5=AE=9A=E4=B9=89=E6=97=B6=20=E5=BD=B1=E5=93=8DIF?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E6=88=96=E9=9D=9E=E7=A9=BA=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/definition/request/controller/MsIfController.java | 4 ++-- .../dto/definition/request/controller/MsLoopController.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java index acbfa04709..2c273cfc4c 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java @@ -79,13 +79,13 @@ public class MsIfController extends MsTestElement { } if (StringUtils.equals(operator, "is empty")) { - variable = "!empty(" + variable + ")"; + variable = variable + "==" + "\"\\" + this.variable + "\"" + "|| empty(" + variable + ")"; operator = ""; value = ""; } if (StringUtils.equals(operator, "is not empty")) { - variable = "empty(" + variable + ")"; + variable = variable + "!=" + "\"\\" + this.variable + "\"" + "&& !empty(" + variable + ")"; operator = ""; value = ""; } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java index 3d05319d2b..b22949ed2a 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java @@ -123,13 +123,13 @@ public class MsLoopController extends MsTestElement { } if (StringUtils.equals(operator, "is empty")) { - variable = "!empty(" + variable + ")"; + variable = variable + "==" + "\"\\" + this.whileController.getVariable() + "\"" + "|| empty(" + variable + ")"; operator = ""; value = ""; } if (StringUtils.equals(operator, "is not empty")) { - variable = "empty(" + variable + ")"; + variable = variable + "!=" + "\"\\" + this.whileController.getVariable() + "\"" + "&& !empty(" + variable + ")"; operator = ""; value = ""; } From f3e0eb5b9de8e2b966e85f04af6776f886840e5b Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Sun, 7 Feb 2021 11:36:57 +0800 Subject: [PATCH 07/18] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89)?= =?UTF-8?q?:=20=E6=B5=8B=E8=AF=95=E4=B8=AD=E5=8F=A6=E5=AD=98=E6=96=B0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=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 --- .../definition/components/runtest/RunTestDubboPage.vue | 8 +++++--- .../api/definition/components/runtest/RunTestHTTPPage.vue | 6 +++--- .../api/definition/components/runtest/RunTestSQLPage.vue | 4 +++- .../api/definition/components/runtest/RunTestTCPPage.vue | 8 +++++--- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue index 1643d36bbb..364f7eb919 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue @@ -89,7 +89,7 @@ reportId: "", } }, - props: {apiData: {}, currentProtocol: String,syncTabs: Array, projectId: String}, + props: {apiData: {}, currentProtocol: String, syncTabs: Array, projectId: String}, methods: { handleCommand(e) { switch (e) { @@ -105,7 +105,7 @@ return this.runTest(); } }, - refresh(){ + refresh() { this.$emit('refresh'); }, runTest() { @@ -161,7 +161,9 @@ }, saveAsApi() { let data = {}; - data.request = JSON.stringify(this.api.request); + let req = this.api.request; + req.id = getUUID(); + data.request = JSON.stringify(req); data.method = this.api.method; data.status = this.api.status; data.userId = this.api.userId; diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue index 86e599809c..9a7fc0c0d0 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue @@ -186,11 +186,11 @@ }, saveAsApi() { let data = {}; - data.request = JSON.stringify(this.api.request); + let req = this.api.request; + req.id = getUUID(); + data.request = JSON.stringify(req); data.method = this.api.method; data.url = this.api.url; - let id = getUUID(); - data.id = id; data.status = this.api.status; data.userId = this.api.userId; data.description = this.api.description; diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue index 68af7c8962..b5731a2289 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue @@ -160,7 +160,9 @@ }, saveAsApi() { let data = {}; - data.request = JSON.stringify(this.api.request); + let req = this.api.request; + req.id = getUUID(); + data.request = JSON.stringify(req); data.method = this.api.method; data.status = this.api.status; data.userId = this.api.userId; diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue index e259438d5a..3253d23b5e 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue @@ -98,7 +98,7 @@ reportId: "", } }, - props: {apiData: {}, currentProtocol: String,syncTabs: Array, projectId: String}, + props: {apiData: {}, currentProtocol: String, syncTabs: Array, projectId: String}, methods: { handleCommand(e) { switch (e) { @@ -114,7 +114,7 @@ return this.$refs['requestForm'].validate(); } }, - refresh(){ + refresh() { this.$emit('refresh'); }, runTest() { @@ -173,7 +173,9 @@ }, saveAsApi() { let data = {}; - data.request = JSON.stringify(this.api.request); + let req = this.api.request; + req.id = getUUID(); + data.request = JSON.stringify(req); data.method = this.api.method; data.status = this.api.status; data.userId = this.api.userId; From 415900370e6e31800d19011dd4d4c27cb2468f4a Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 8 Feb 2021 11:34:32 +0800 Subject: [PATCH 08/18] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E5=BC=95=E7=94=A8=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E8=83=BD=E6=B7=BB=E5=8A=A0=20=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E6=AD=A5=E9=AA=A4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api/automation/scenario/EditApiScenario.vue | 2 +- .../components/api/definition/components/extract/ApiExtract.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 21ffb284f9..f443d1c6c2 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -503,7 +503,7 @@ this.sort(); }, nodeClick(data, node) { - if (data.referenced != 'REF' && data.referenced != 'Deleted') { + if (data.referenced != 'REF' && data.referenced != 'Deleted' && !data.disabled) { this.operatingElements = ELEMENTS.get(data.type); } else { this.operatingElements = []; diff --git a/frontend/src/business/components/api/definition/components/extract/ApiExtract.vue b/frontend/src/business/components/api/definition/components/extract/ApiExtract.vue index d8637ff3e6..728d9a0ebe 100644 --- a/frontend/src/business/components/api/definition/components/extract/ApiExtract.vue +++ b/frontend/src/business/components/api/definition/components/extract/ApiExtract.vue @@ -26,7 +26,7 @@ - Add + {{$t('commons.add')}}
From 5eb34cbae48c1630546abe3a0f8e16fc429c758e Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 8 Feb 2021 14:12:07 +0800 Subject: [PATCH 09/18] =?UTF-8?q?feat(=E5=9C=BA=E6=99=AF=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E5=9C=BA=E6=99=AF=E5=8F=98=E9=87=8F=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=AF=B7=E6=B1=82=E5=A4=B4=EF=BC=8C=E5=B9=B6=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E8=AF=B7=E6=B1=82=E5=A4=B4=E6=95=B0=E6=8D=AE=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=94=AF=E6=8C=81=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/definition/request/MsScenario.java | 11 +- .../service/HistoricalDataUpgradeService.java | 1 + .../automation/scenario/EditApiScenario.vue | 30 ++- .../scenario/component/ApiComponent.vue | 4 +- .../scenario/component/LoopController.vue | 4 +- .../scenario/variable/VariableList.vue | 189 +++++++++++++----- 6 files changed, 177 insertions(+), 62 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 4e37a95699..3686898bde 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 @@ -49,6 +49,9 @@ public class MsScenario extends MsTestElement { @JSONField(ordinal = 24) private boolean enableCookieShare; + @JSONField(ordinal = 26) + private List headers; + private static final String BODY_FILE_DIR = "/opt/metersphere/data/body"; @Override @@ -87,7 +90,7 @@ public class MsScenario extends MsTestElement { } // 场景变量和环境变量 tree.add(arguments(config)); - //this.addCsvDataSet(tree, variables); + this.addCsvDataSet(tree, variables); this.addCounter(tree, variables); this.addRandom(tree, variables); if (CollectionUtils.isNotEmpty(hashTree)) { @@ -131,6 +134,12 @@ public class MsScenario extends MsTestElement { arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") ); } + if (CollectionUtils.isNotEmpty(this.headers)) { + this.headers.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue -> + arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") + ); + } + return arguments; } diff --git a/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java b/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java index 0033018d34..580b8d470f 100644 --- a/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java +++ b/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java @@ -84,6 +84,7 @@ public class HistoricalDataUpgradeService { scenario.setReferenced("Upgrade"); scenario.setId(oldScenario.getId()); scenario.setResourceId(UUID.randomUUID().toString()); + scenario.setHeaders(oldScenario.getHeaders()); LinkedList testElements = new LinkedList<>(); int index = 1; for (Request request : oldScenario.getRequests()) { diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index f443d1c6c2..98c9d61247 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -106,7 +106,7 @@ {{$t('api_test.automation.scenario_total')}} - :{{this.currentScenario.variables!=undefined?this.currentScenario.variables.length: 0}} + :{{getVariableSize()}} 共享cookie @@ -427,8 +427,9 @@ getIdx(index) { return index - 0.33 }, - setVariables(v) { + setVariables(v, headers) { this.currentScenario.variables = v; + this.currentScenario.headers = headers; if (this.path.endsWith("/update")) { // 直接更新场景防止编辑内容丢失 this.editScenario(); @@ -679,7 +680,7 @@ this.editScenario(); this.debugData = { id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario", - variables: this.currentScenario.variables, referenced: 'Created', enableCookieShare: this.enableCookieShare, + variables: this.currentScenario.variables, referenced: 'Created', enableCookieShare: this.enableCookieShare, headers: this.currentScenario.headers, environmentId: this.currentEnvironmentId, hashTree: this.scenarioDefinition }; this.reportId = getUUID().substring(0, 8); @@ -863,6 +864,9 @@ if (!this.currentScenario.variables) { this.currentScenario.variables = []; } + if (!this.currentScenario.headers) { + this.currentScenario.headers = []; + } if (this.currentScenario.id) { this.result = this.$get("/api/automation/getApiScenario/" + this.currentScenario.id, response => { if (response.data) { @@ -887,6 +891,9 @@ } }) } + if (obj.headers) { + this.currentScenario.headers = obj.headers; + } this.enableCookieShare = obj.enableCookieShare; this.scenarioDefinition = obj.hashTree; } @@ -905,8 +912,9 @@ this.currentScenario.modulePath = this.getPath(this.currentScenario.apiScenarioModuleId); // 构建一个场景对象 方便引用处理 let scenario = { - id: this.currentScenario.id, enableCookieShare: this.enableCookieShare, name: this.currentScenario.name, variables: this.currentScenario.variables, - type: "scenario", referenced: 'Created', environmentId: this.currentEnvironmentId, hashTree: this.scenarioDefinition + id: this.currentScenario.id, enableCookieShare: this.enableCookieShare, name: this.currentScenario.name, type: "scenario", + variables: this.currentScenario.variables, headers: this.currentScenario.headers, + referenced: 'Created', environmentId: this.currentEnvironmentId, hashTree: this.scenarioDefinition }; this.currentScenario.scenarioDefinition = scenario; if (this.currentScenario.tags instanceof Array) { @@ -924,7 +932,7 @@ this.loading = false; }, showScenarioParameters() { - this.$refs.scenarioParameters.open(this.currentScenario.variables); + this.$refs.scenarioParameters.open(this.currentScenario.variables, this.currentScenario.headers); }, apiImport(importData) { if (importData && importData.data) { @@ -934,6 +942,16 @@ this.sort(); this.reload(); } + }, + getVariableSize() { + let size = 0; + if (this.currentScenario.variables) { + size += this.currentScenario.variables.length; + } + if (this.currentScenario.headers && this.currentScenario.headers.length > 1) { + size += this.currentScenario.headers.length - 1; + } + return size; } } } diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index 6ea4c3543c..625008a29f 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -248,8 +248,8 @@ this.request.customizeReq = this.isCustomizeReq; let debugData = { id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario", - variables: this.currentScenario.variables, referenced: 'Created', enableCookieShare: this.enableCookieShare, - environmentId: this.currentEnvironmentId, hashTree: [this.request] + variables: this.currentScenario.variables, referenced: 'Created', headers: this.currentScenario.headers, + enableCookieShare: this.enableCookieShare, environmentId: this.currentEnvironmentId, hashTree: [this.request] }; this.runData.push(debugData); /*触发执行操作*/ diff --git a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue index be8df59a1e..4ad787b7af 100644 --- a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue +++ b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue @@ -205,8 +205,8 @@ this.loading = true; this.debugData = { id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario", - variables: this.currentScenario.variables, referenced: 'Created', enableCookieShare: this.enableCookieShare, - environmentId: this.currentEnvironmentId, hashTree: [this.controller] + variables: this.currentScenario.variables, headers: this.currentScenario.headers, + referenced: 'Created', enableCookieShare: this.enableCookieShare, environmentId: this.currentEnvironmentId, hashTree: [this.controller] }; this.reportId = getUUID().substring(0, 8); }, diff --git a/frontend/src/business/components/api/automation/scenario/variable/VariableList.vue b/frontend/src/business/components/api/automation/scenario/variable/VariableList.vue index 8253a019e0..21026fd8d5 100644 --- a/frontend/src/business/components/api/automation/scenario/variable/VariableList.vue +++ b/frontend/src/business/components/api/automation/scenario/variable/VariableList.vue @@ -1,57 +1,89 @@