From 8cfdf5455f4d739ee952307dd87d127c239b0da2 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 15 Mar 2023 10:13:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmock=E6=9C=8D=E5=8A=A1=E4=B8=8D=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=8E=A5=E5=8F=97get=E8=AF=B7=E6=B1=82=E5=86=85body?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1024452 --user=宋天阳 [接口测试]github#22682在MOCK里设置mock请求参数和请求内容,点击执行,输入mock参数进行发送,响应的不是设置好的mock请求,而是该接口的响应内容 https://www.tapd.cn/55049933/s/1350225 --- .../api/dto/mock/RequestMockParams.java | 12 ++++++- .../report/detail/ui/RequestResult.vue | 33 +++++++++++++++---- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/mock/RequestMockParams.java b/api-test/backend/src/main/java/io/metersphere/api/dto/mock/RequestMockParams.java index 972da0d5a0..3551c818e2 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/mock/RequestMockParams.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/mock/RequestMockParams.java @@ -3,6 +3,7 @@ package io.metersphere.api.dto.mock; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.StringUtils; +import org.json.JSONArray; import org.json.JSONObject; /** @@ -29,12 +30,21 @@ public class RequestMockParams { public boolean isEmpty() { + boolean isJsonParamEmpty = false; + if (jsonParam instanceof JSONObject) { + isJsonParamEmpty = ((JSONObject) jsonParam).isEmpty(); + } else if (jsonParam instanceof JSONArray) { + isJsonParamEmpty = ((JSONArray) jsonParam).isEmpty(); + } else { + isJsonParamEmpty = jsonParam == null; + } if (isPost) { return (restParamsObj == null || restParamsObj.isEmpty()) && + isJsonParamEmpty && (queryParamsObj == null || queryParamsObj.isEmpty()) && StringUtils.isBlank(raw); } else { - return (restParamsObj == null || restParamsObj.isEmpty()) && + return (restParamsObj == null || restParamsObj.isEmpty()) && isJsonParamEmpty && (queryParamsObj == null || queryParamsObj.isEmpty()); } diff --git a/test-track/frontend/src/business/plan/view/comonents/report/detail/ui/RequestResult.vue b/test-track/frontend/src/business/plan/view/comonents/report/detail/ui/RequestResult.vue index f0ab939e71..6f42b017a8 100644 --- a/test-track/frontend/src/business/plan/view/comonents/report/detail/ui/RequestResult.vue +++ b/test-track/frontend/src/business/plan/view/comonents/report/detail/ui/RequestResult.vue @@ -45,13 +45,20 @@ :open-delay="800" >
{{ baseErrorCode }}
{{ baseErrorCode }} @@ -97,13 +104,20 @@ :open-delay="800" >
{{ request.responseResult.responseCode }}
{{ request.responseResult.responseCode }} @@ -145,13 +159,20 @@
{{ request.responseResult.responseTime }}
{{ request.responseResult.responseTime }}