From 29763edbe9646ae72ff1aceabf86e2bfcb79634f Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 23 Aug 2021 17:05:15 +0800 Subject: [PATCH] =?UTF-8?q?fix=20(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):?= =?UTF-8?q?=20=E5=AE=8C=E5=96=84=E9=9C=80=E6=B1=823=E9=81=97=E6=BC=8F?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/definition/ApiDefinition.vue | 59 +++++-------- .../components/case/ApiCaseList.vue | 84 +++++++++++-------- .../definition/components/list/ApiList.vue | 14 +--- 3 files changed, 73 insertions(+), 84 deletions(-) diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index f4d94f930c..0090cfa5ff 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -110,6 +110,7 @@ :selectDataRange="selectDataRange" :is-read-only="isReadOnly" @runTest="runTest" + @handleTestCase="handleTestCase" @refreshTree="refreshTree" @changeSelectDataRangeAll="changeSelectDataRangeAll" @editApi="editApi" @@ -141,7 +142,7 @@ :module-ids="selectNodeIds"/> -
+
- -
- - - - -
@@ -367,6 +333,7 @@ export default { initApiTableOpretion: 'init', param: {}, useEnvironment: String, + activeTab: "api" }; }, activated() { @@ -609,6 +576,7 @@ export default { name = this.$t('api_test.definition.request.title'); } } + this.activeTab = "api"; if (row != null && row.tags != 'null' && row.tags != '' && row.tags != undefined) { if (Object.prototype.toString.call(row.tags).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object' && Object.prototype.toString.call(row.tags).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'array') { @@ -663,9 +631,26 @@ export default { } }, runTest(data) { + this.activeTab = "test"; this.handleTabsEdit(this.$t("commons.api"), "TEST", data); this.setTabTitle(data); }, + handleTestCase(row) { + this.activeTab = "testCase"; + let name = ""; + if (row.name) { + name = this.$t('api_test.definition.request.edit_api') + "-" + row.name; + } else { + name = this.$t('api_test.definition.request.title'); + } + if (row != null && row.tags != 'null' && row.tags != '' && row.tags != undefined) { + if (Object.prototype.toString.call(row.tags).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object' + && Object.prototype.toString.call(row.tags).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'array') { + row.tags = JSON.parse(row.tags); + } + } + this.handleTabsEdit(name, "ADD", row); + }, mockConfig(data) { let targetName = this.$t("commons.mock") + "-" + data.apiName; this.handleMockTabsConfig(targetName, "MOCK", data); 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 80683766a8..eff112d225 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue @@ -3,19 +3,19 @@ @@ -215,27 +215,33 @@ export default { sysAddition(apiCase) { this.condition.projectId = this.projectId; this.condition.apiDefinitionId = this.api.id; - this.$post("/api/testcase/list", this.condition, response => { - let data = response.data; - data.forEach(apiCase => { - if (apiCase.tags && apiCase.tags.length > 0) { - apiCase.tags = JSON.parse(apiCase.tags); - this.$set(apiCase, 'selected', false); - } - if (Object.prototype.toString.call(apiCase.request).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object') { - apiCase.request = JSON.parse(apiCase.request); - } - if (!apiCase.request.hashTree) { - apiCase.request.hashTree = []; - } - }); - this.apiCaseList = data; - if (apiCase) { - this.copyCase(apiCase); - } else { - this.addCase(); - } - }); + this.apiCaseList = []; + if (apiCase) { + this.copyCase(apiCase); + } else { + this.addCase(); + } + // this.$post("/api/testcase/list", this.condition, response => { + // let data = response.data; + // data.forEach(apiCase => { + // if (apiCase.tags && apiCase.tags.length > 0) { + // apiCase.tags = JSON.parse(apiCase.tags); + // this.$set(apiCase, 'selected', false); + // } + // if (Object.prototype.toString.call(apiCase.request).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object') { + // apiCase.request = JSON.parse(apiCase.request); + // } + // if (!apiCase.request.hashTree) { + // apiCase.request.hashTree = []; + // } + // }); + // this.apiCaseList = data; + // if (apiCase) { + // this.copyCase(apiCase); + // } else { + // this.addCase(); + // } + // }); }, apiCaseClose() { @@ -503,7 +509,15 @@ export default { this.$success(this.$t('commons.save_success')); } this.selectdCases = []; - this.getApiTest(); + this.getResult(); + }); + }, + getResult() { + this.apiCaseList.forEach(apiCase => { + const index = this.runData.findIndex(d => d.name === apiCase.id); + if (index !== -1) { + apiCase.active = true; + } }); }, showHistory(id) { 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 f86d8ec878..bd81d598d5 100644 --- a/frontend/src/business/components/api/definition/components/list/ApiList.vue +++ b/frontend/src/business/components/api/definition/components/list/ApiList.vue @@ -729,18 +729,8 @@ export default { }); }, handleTestCase(api) { - this.selectApi = api; - let request = {}; - if (Object.prototype.toString.call(api.request).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') { - request = api.request; - } else { - request = JSON.parse(api.request); - } - if (!request.hashTree) { - request.hashTree = []; - } - this.selectApi.url = request.path; - this.$refs.caseList.open(this.selectApi); + this.$emit("handleTestCase",api) + // this.$refs.caseList.open(this.selectApi); }, handleDelete(api) { if (this.trashEnable) {