From 1b00732b9773807ff9efb56726b25083d1fa726b Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Thu, 21 Jul 2022 13:56:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=87=E4=BB=B6=E5=AF=BC=E5=85=A5=E6=97=B6?= =?UTF-8?q?=E7=BC=BA=E5=B0=91=E4=B8=80=E4=BA=9B=E9=BB=98=E8=AE=A4=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 --bug=1014998 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014998 --bug=1014819 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014819 --- .../components/case/ApiCaseList.vue | 89 ++++++++++++------- .../definition/components/list/ApiList.vue | 44 +++++++++ 2 files changed, 100 insertions(+), 33 deletions(-) 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 9d12eb4139..46da5035fb 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue @@ -3,40 +3,40 @@
+ :loading="singleLoading && singleRunId ===item.id || batchLoadingIds.indexOf(item.id) > -1" + @refresh="refresh" + @singleRun="singleRun" + @stop="stop" + @refreshModule="refreshModule" + @copyCase="copyCase" + @showExecResult="showExecResult" + @showHistory="showHistory" + @reLoadCase="reLoadCase" + :environment="environment" + @setSelectedCaseId="setSelectedCaseId" + :is-case-edit="isCaseEdit" + :api="api" + :currentApi="currentApi" + :loaded="loaded" + :maintainerOptions="maintainerOptions" + :api-case="item" ref="apiCaseItem"/>
@@ -62,6 +62,7 @@ import MsDrawer from "../../../../common/components/MsDrawer"; import {CASE_ORDER} from "../../model/JsonData"; import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components"; import {parseEnvironment} from "@/business/components/api/definition/model/EnvironmentModel"; +import {Body} from "@/business/components/api/definition/model/ApiTestModel"; export default { name: 'ApiCaseList', @@ -325,12 +326,12 @@ export default { this.$get('/api/environment/list/' + this.projectId, response => { this.environments = response.data; // 获取原数据源名称 - if(env === obj.originalEnvironmentId && obj.originalDataSourceId){ + if (env === obj.originalEnvironmentId && obj.originalDataSourceId) { obj.dataSourceId = obj.originalDataSourceId; obj.environmentId = env; this.getTargetSourceName(this.environments, obj); } - if(!obj.targetDataSourceName){ + if (!obj.targetDataSourceName) { this.getTargetSourceName(this.environments, obj); } @@ -344,12 +345,12 @@ export default { }); } else { // 获取原数据源名称 - if(env === obj.originalEnvironmentId && obj.originalDataSourceId){ + if (env === obj.originalEnvironmentId && obj.originalDataSourceId) { obj.dataSourceId = obj.originalDataSourceId; obj.environmentId = env; this.getTargetSourceName(this.environments, obj); } - if(!obj.targetDataSourceName){ + if (!obj.targetDataSourceName) { this.getTargetSourceName(this.environments, obj); } // 设置新环境 @@ -418,6 +419,28 @@ export default { } if (Object.prototype.toString.call(apiCase.request).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object') { apiCase.request = JSON.parse(apiCase.request); + if (!apiCase.request.body) { + apiCase.request.body = new Body(); + } + if (!apiCase.request.headers) { + apiCase.request.headers = []; + } + if (!apiCase.request.rest) { + apiCase.request.rest = []; + } + if (!apiCase.request.arguments) { + apiCase.request.arguments = [ + { + contentType: "text/plain", + enable: true, + file: false, + required: false, + type: "text", + urlEncode: false, + valid: false + } + ]; + } } if (!apiCase.request.hashTree) { apiCase.request.hashTree = []; @@ -529,7 +552,7 @@ export default { this.$emit('showExecResult', row); }, singleRun(row) { - let methods =["SQL","DUBBO","dubbo://","TCP" ]; + let methods = ["SQL", "DUBBO", "dubbo://", "TCP"]; if (row.apiMethod && methods.indexOf(row.apiMethod) === -1 && !this.environment) { this.$warning(this.$t('api_test.environment.select_environment')); return; diff --git a/frontend/src/business/components/api/definition/components/list/ApiList.vue b/frontend/src/business/components/api/definition/components/list/ApiList.vue index 7f1f3ec350..2fc231cf60 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiList.vue @@ -676,6 +676,50 @@ export default { item.tags = JSON.parse(item.tags); } item.caseTotal = parseInt(item.caseTotal); + if (!item.response) { + let response = {headers: [], body: new Body(), statusCode: [], type: "HTTP"}; + item.response = JSON.stringify(response); + } + if (item.response) { + item.response = JSON.parse(item.response); + if (!item.response.body) { + item.response.body = new Body(); + } + if (!item.response.headers) { + item.response.headers = []; + } + if (!item.response.statusCode) { + item.response.statusCode = []; + } + item.response = JSON.stringify(item.response); + } + //request + if (item.request) { + item.request = JSON.parse(item.request); + if (!item.request.body) { + item.request.body = new Body(); + } + if (!item.request.headers) { + item.request.headers = []; + } + if (!item.request.rest) { + item.request.rest = []; + } + if (!item.request.arguments) { + item.request.arguments = [ + { + contentType: "text/plain", + enable: true, + file: false, + required: false, + type: "text", + urlEncode: false, + valid: false + } + ]; + } + item.request = JSON.stringify(item.request); + } }); this.$emit('getTrashApi'); if (this.$refs.table) {