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 21b416fb4e..498e178e37 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -242,12 +242,16 @@ public class ApiAutomationService { JSONObject element = JSON.parseObject(item.getScenarioDefinition()); MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class); // 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取 - LinkedList elements = mapper.readValue(element.getString("hashTree"), - new TypeReference>() {}); - LinkedList variables = mapper.readValue(element.getString("variables"), - new TypeReference>() {}); - scenario.setHashTree(elements); - scenario.setVariables(variables); + if (StringUtils.isNotEmpty(element.getString("hashTree"))) { + LinkedList elements = mapper.readValue(element.getString("hashTree"), + new TypeReference>() {}); + scenario.setHashTree(elements); + } + if (StringUtils.isNotEmpty(element.getString("variables"))) { + LinkedList variables = mapper.readValue(element.getString("variables"), + new TypeReference>() {}); + scenario.setVariables(variables); + } LinkedList scenarios = new LinkedList<>(); scenarios.add(scenario); group.setHashTree(scenarios); diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index 1c07087dfd..a3d9095a71 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -154,7 +154,10 @@ } }, handleTabAdd(e) { - let api = {status: "Underway", method: "GET", userId: getCurrentUser().id, url: "", protocol: this.currentProtocol}; + let api = { + status: "Underway", method: "GET", userId: getCurrentUser().id, + url: "", protocol: this.currentProtocol, environmentId: "" + }; this.handleTabsEdit(this.$t('api_test.definition.request.title'), e, api); }, handleTabClose() { diff --git a/frontend/src/business/components/api/definition/components/ApiCaseList.vue b/frontend/src/business/components/api/definition/components/ApiCaseList.vue index f1b056d9ef..3fbb20dad8 100644 --- a/frontend/src/business/components/api/definition/components/ApiCaseList.vue +++ b/frontend/src/business/components/api/definition/components/ApiCaseList.vue @@ -29,7 +29,7 @@ - + @@ -57,11 +57,11 @@ + style="background-color: #409EFF;color: white" size="mini" :disabled="item.type=='create'" circle/> + size="mini" :disabled="item.type=='create'" circle/> + size="mini" :disabled="item.type=='create'" circle/> @@ -222,7 +222,6 @@ this.$warning(this.$t('api_test.environment.select_environment')); return; } - this.loading = true; if (this.apiCaseList.length > 0) { this.apiCaseList.forEach(item => { if (item.type != "create") { @@ -231,9 +230,13 @@ this.runData.push(item.request); } }) - this.loading = true; - /*触发执行操作*/ - this.reportId = getUUID().substring(0, 8); + if (this.runData.length > 0) { + this.loading = true; + /*触发执行操作*/ + this.reportId = getUUID().substring(0, 8); + } else { + this.$warning("没有可执行的用例!"); + } } else { this.$warning("没有可执行的用例!"); } @@ -343,6 +346,11 @@ return true; } }, + changePriority(row) { + if (row.type != 'create') { + this.saveTestCase(row); + } + }, saveTestCase(row) { if (this.validate(row)) { return; diff --git a/frontend/src/business/components/api/definition/components/ApiConfig.vue b/frontend/src/business/components/api/definition/components/ApiConfig.vue index e9e1ae765b..1df8d46921 100644 --- a/frontend/src/business/components/api/definition/components/ApiConfig.vue +++ b/frontend/src/business/components/api/definition/components/ApiConfig.vue @@ -64,7 +64,11 @@ break; } if (this.currentApi.response != null && this.currentApi.response != 'null' && this.currentApi.response != undefined) { - this.response = new ResponseFactory(JSON.parse(this.currentApi.response)); + if (Object.prototype.toString.call(this.currentApi.response).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') { + this.response = this.currentApi.response; + } else { + this.response = new ResponseFactory(JSON.parse(this.currentApi.response)); + } } else { this.response = {headers: [], body: new Body(), statusCode: [], type: "HTTP"}; } 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 78b9ddfcd6..8fe0bef3d9 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseHeader.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseHeader.vue @@ -48,7 +48,7 @@
+ v-model="condition.name" @blur="getApiTest" @keyup.enter.native="getApiTest"/>
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 c65a36cc60..1b2ba625bb 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue @@ -236,7 +236,7 @@ let hasEnvironment = false; for (let i in this.environments) { if (this.environments[i].id === this.api.environmentId) { - this.api.environment = this.environments[i]; + this.api.environmentId = this.environments[i]; hasEnvironment = true; break; } @@ -261,7 +261,8 @@ environmentChange(value) { for (let i in this.environments) { if (this.environments[i].id === value) { - this.api.request.useEnvironment = this.environments[i].id; + this.api.environmentId = value; + this.api.request.useEnvironment = value; break; } }