diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index 0c237fd1d1..7585c17f0d 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -11,8 +11,6 @@ import io.metersphere.api.dto.definition.request.ElementUtil; import io.metersphere.api.dto.definition.request.ParameterConfig; import io.metersphere.api.dto.definition.request.auth.MsAuthManager; import io.metersphere.api.dto.definition.request.dns.MsDNSCacheManager; -import io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor; -import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor; import io.metersphere.api.dto.scenario.Body; import io.metersphere.api.dto.scenario.HttpConfig; import io.metersphere.api.dto.scenario.HttpConfigCondition; @@ -284,6 +282,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { } } + private void initConnectAndResponseTimeout(ParameterConfig config) { if (config.isEffective(this.getProjectId())) { String useEvnId = config.getConfig().get(this.getProjectId()).getApiEnvironmentid(); @@ -604,7 +603,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { stringBuffer.append(path); stringBuffer.append("/"); Map keyValueMap = new HashMap<>(); - this.getRest().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).forEach(keyValue -> + this.getRest().stream().filter(KeyValue::isEnable).filter(KeyValue::isValid).filter(KeyValue::valueIsNotEmpty).forEach(keyValue -> keyValueMap.put(keyValue.getName(), keyValue.getValue() != null && keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue()) ); @@ -613,7 +612,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { Matcher m = p.matcher(path); while (m.find()) { String group = m.group(2); - if (!isVariable(path, group)) { + if (!isVariable(path, group) && keyValueMap.containsKey(group)) { path = path.replace("{" + group + "}", keyValueMap.get(group)); } } diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/KeyValue.java b/backend/src/main/java/io/metersphere/api/dto/scenario/KeyValue.java index 6365e40d43..494849d8c6 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/KeyValue.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/KeyValue.java @@ -58,6 +58,10 @@ public class KeyValue { this(name, value, description, "", required); } + public boolean valueIsNotEmpty() { + return StringUtils.isNotEmpty(this.getValue()); + } + public boolean isValid() { return (StringUtils.isNotBlank(name) || "JSON-SCHEMA".equals(type)) && !StringUtils.equalsIgnoreCase(type, "file"); } diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseHeader.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseHeader.vue index 1c8724de45..54de3f1c40 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseHeader.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseHeader.vue @@ -2,13 +2,12 @@ - - + {{api.name}} - + {{ api.method}} @@ -16,34 +15,6 @@
{{api.path ===null ? " " : api.path}}
- -
{{$t('test_track.plan_view.case_count')}}:{{apiCaseList.length}}
-
- -
- - - -
-
- - -
- - - - - - {{$t('commons.adv_search.title')}} - - -
-
-
- - - -
- - - -
@@ -72,22 +35,18 @@ import MsTag from "../../../../common/components/MsTag"; import MsEnvironmentSelect from "./MsEnvironmentSelect"; import {API_METHOD_COLOUR} from "../../model/JsonData"; - import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar"; - export default { name: "ApiCaseHeader", - components: {MsEnvironmentSelect, MsTag, ApiEnvironmentConfig, MsTableAdvSearchBar}, + components: {MsEnvironmentSelect, MsTag, ApiEnvironmentConfig}, data() { return { methodColorMap: new Map(API_METHOD_COLOUR), - isSelectAll: false } }, props: { api: Object, projectId: String, priorities: Array, - apiCaseList: Array, isReadOnly: Boolean, useEnvironment: String, isCaseEdit: Boolean, @@ -100,11 +59,6 @@ }, created() { }, - watch: { - isSelectAll() { - this.$emit('selectAll', this.isSelectAll); - }, - }, methods: { refreshEnvironment(){ this.$refs.environmentSelect.refreshEnvironment(); @@ -114,16 +68,6 @@ this.$emit('setEnvironment', data.id); } }, - search() { - if (this.priorities && this.condition.order) { - for (let index in this.priorities) { - if (this.priorities[index].id === this.condition.order) { - this.condition.orders = [this.priorities[index]]; - } - } - } - this.$emit('getApiTest'); - }, open() { this.$refs.searchBar.open(); }, diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue index 3cc7af23d5..b6b80786af 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue @@ -2,24 +2,6 @@
- - - - - - - - - -
-
{{ index + 1 }}
-
- - - -
-
-
@@ -43,6 +25,11 @@
+ + + + + - + - + @@ -65,7 +52,7 @@
+ @change="saveTestCase(apiCase,true)" style="width: 100%" :disabled="loaded">
- +
@@ -86,7 +73,7 @@ + class="run-button" size="mini" :disabled="!apiCase.id || loaded" circle v-if="!loading"/>
@@ -95,14 +82,14 @@ + size="mini" :disabled="!apiCase.id || isCaseEdit || loaded" circle/> - + {{ getResult(apiCase.execResult) }} @@ -128,16 +115,16 @@

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

- + - +

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

-
- +
+
@@ -225,8 +212,7 @@ export default { ['error', this.$t('test_track.plan_view.execute_result') + ':' + this.$t('api_test.home_page.detail_card.execution_failed')], ['default', this.$t('test_track.plan_view.execute_result') + ':' + this.$t('api_test.home_page.detail_card.unexecute')] ]), - showXpackCompnent: false, - isReadOnly: false, + isXpack: false, selectedEvent: Object, priorities: PRIORITY, runData: [], @@ -236,17 +222,17 @@ export default { condition: {}, responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []}, isShowInput: false, - buttons: [ - {name: this.$t('api_test.automation.batch_execute'), handleClick: this.handleRunBatch}, - {name: this.$t('test_track.case.batch_edit_case'), handleClick: this.handleEditBatch} - ], methodColorMap: new Map(API_METHOD_COLOUR), saveLoading: false, + beforeRequest: {}, } }, props: { runResult: {}, - selectSize: Number, + loaded: { + type: Boolean, + default: false, + }, apiCase: { type: Object, default() { @@ -266,6 +252,7 @@ export default { return {} } }, + currentApi: {}, type: String, isCaseEdit: Boolean, loading: { @@ -278,35 +265,27 @@ export default { }, created() { if (requireComponent != null && JSON.stringify(esbDefinition) != '{}' && JSON.stringify(esbDefinitionResponse) != '{}') { - this.showXpackCompnent = true; + this.isXpack = true; } if (this.apiCase && this.apiCase.id) { this.$get('/api/testcase/follow/' + this.apiCase.id, response => { this.apiCase.follows = response.data; }); } - }, - watch: { - 'apiCase.selected'() { - this.$emit('apiCaseSelected'); + if (this.currentApi && this.currentApi.request) { + this.beforeRequest = JSON.parse(JSON.stringify(this.currentApi.request)); } }, methods: { hasPermission, openHis(row) { - this.$refs.changeHistory.open(row.id,["接口定义用例" , "接口定義用例" , "Api definition case"]); - }, - handleRunBatch() { - this.$emit('batchRun'); + this.$refs.changeHistory.open(row.id, ["接口定义用例", "接口定義用例", "Api definition case"]); }, getColor(enable, method) { if (enable) { return this.methodColorMap.get(method); } }, - handleEditBatch() { - this.$emit('batchEditCase'); - }, deleteCase(index, row) { this.$alert(this.$t('api_test.definition.request.delete_case_confirm') + ' ' + row.name + " ?", '', { confirmButtonText: this.$t('commons.confirm'), @@ -348,14 +327,14 @@ export default { } if ($event.currentTarget.className.indexOf('is-selected') > 0) { $event.currentTarget.className = "el-card is-always-shadow"; - this.$emit('selectTestCase', null); + this.currentApi.request = this.beforeRequest; } else { if (this.selectedEvent.currentTarget != undefined) { this.selectedEvent.currentTarget.className = "el-card is-always-shadow"; } this.selectedEvent.currentTarget = $event.currentTarget; $event.currentTarget.className = "el-card is-always-shadow is-selected"; - this.$emit('selectTestCase', item); + this.currentApi.request = item.request; } }, changePriority(row) { diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue index 45f4f1035f..8af5086ffd 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue @@ -4,43 +4,37 @@
- +
@@ -49,11 +43,7 @@ - - - -