From d75477db11e05bbbb412634ef1e41f9c4d03905b Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 11 Dec 2020 11:21:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=89=E6=8B=A9=E6=A1=88=E4=BE=8B=E7=BC=BA?= =?UTF-8?q?=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/scenario/EditApiScenario.vue | 2 +- .../automation/scenario/api/ApiCaseList.vue | 494 ++++++++++++++++++ .../automation/scenario/api/ApiDefinition.vue | 151 ++++++ .../api/automation/scenario/api/ApiList.vue | 412 +++++++++++++++ .../api/definition/components/ApiCaseList.vue | 75 +-- .../api/definition/components/ApiList.vue | 167 +++--- .../components/runtest/RunTestDubboPage.vue | 2 +- .../components/runtest/RunTestHTTPPage.vue | 2 +- .../components/runtest/RunTestSQLPage.vue | 2 +- .../components/runtest/RunTestTCPPage.vue | 2 +- 10 files changed, 1165 insertions(+), 144 deletions(-) create mode 100644 frontend/src/business/components/api/automation/scenario/api/ApiCaseList.vue create mode 100644 frontend/src/business/components/api/automation/scenario/api/ApiDefinition.vue create mode 100644 frontend/src/business/components/api/automation/scenario/api/ApiList.vue diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index d18e7fe79c..7a81fb266e 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -281,7 +281,7 @@ import MsIfController from "./IfController"; import MsApiAssertions from "../../definition/components/assertion/ApiAssertions"; import MsApiExtract from "../../definition/components/extract/ApiExtract"; - import MsApiDefinition from "../../definition/ApiDefinition"; + import MsApiDefinition from "./api/ApiDefinition"; import MsApiComponent from "./ApiComponent"; import {ELEMENTS, ELEMENT_TYPE} from "./Setting"; import MsApiCustomize from "./ApiCustomize"; diff --git a/frontend/src/business/components/api/automation/scenario/api/ApiCaseList.vue b/frontend/src/business/components/api/automation/scenario/api/ApiCaseList.vue new file mode 100644 index 0000000000..a8e832c117 --- /dev/null +++ b/frontend/src/business/components/api/automation/scenario/api/ApiCaseList.vue @@ -0,0 +1,494 @@ + + + + diff --git a/frontend/src/business/components/api/automation/scenario/api/ApiDefinition.vue b/frontend/src/business/components/api/automation/scenario/api/ApiDefinition.vue new file mode 100644 index 0000000000..8241a6a026 --- /dev/null +++ b/frontend/src/business/components/api/automation/scenario/api/ApiDefinition.vue @@ -0,0 +1,151 @@ + + + + + diff --git a/frontend/src/business/components/api/automation/scenario/api/ApiList.vue b/frontend/src/business/components/api/automation/scenario/api/ApiList.vue new file mode 100644 index 0000000000..7186684e2f --- /dev/null +++ b/frontend/src/business/components/api/automation/scenario/api/ApiList.vue @@ -0,0 +1,412 @@ + + + + + diff --git a/frontend/src/business/components/api/definition/components/ApiCaseList.vue b/frontend/src/business/components/api/definition/components/ApiCaseList.vue index 40dd1ffd5e..f1b056d9ef 100644 --- a/frontend/src/business/components/api/definition/components/ApiCaseList.vue +++ b/frontend/src/business/components/api/definition/components/ApiCaseList.vue @@ -23,11 +23,7 @@
- - - - - +
{{index+1}}
@@ -139,13 +135,12 @@ MsApiExtendBtns }, props: { - api: { - type: Object - }, createCase: String, loaded: Boolean, refreshSign: String, - currentRow: Object, + currentApi: { + type: Object + }, }, data() { return { @@ -162,22 +157,22 @@ projectId: "", checkedCases: new Set(), visible: false, - condition: {} - + condition: {}, + api: {} } }, watch: { refreshSign() { - if (this.currentRow) { - this.currentRow.cases = []; - } + this.api = this.currentApi; this.getApiTest(); }, createCase() { + this.api = this.currentApi; this.sysAddition(); } }, created() { + this.api = this.currentApi; this.projectId = getCurrentProjectID(); if (this.createCase) { this.sysAddition(); @@ -186,21 +181,16 @@ } }, methods: { - open() { - this.init(); - this.visible = true; - }, - init() { - if (this.currentRow) { - this.currentRow.cases = []; - } + open(api) { + this.api = api; this.getApiTest(); + this.visible = true; }, setEnvironment(environment) { this.environment = environment; }, sysAddition() { - this.condition.projectId = this.api.projectId; + this.condition.projectId = this.projectId; this.condition.apiDefinitionId = this.api.id; this.$post("/api/testcase/list", this.condition, response => { for (let index in response.data) { @@ -332,18 +322,20 @@ return bodyUploadFiles; }, getApiTest() { - this.condition.projectId = this.api.projectId; - this.condition.apiDefinitionId = this.api.id; - this.result = this.$post("/api/testcase/list", this.condition, response => { - for (let index in response.data) { - let test = response.data[index]; - test.request = JSON.parse(test.request); - } - this.apiCaseList = response.data; - if (this.apiCaseList.length == 0) { - this.addCase(); - } - }); + if (this.api) { + this.condition.projectId = this.projectId; + this.condition.apiDefinitionId = this.api.id; + this.result = this.$post("/api/testcase/list", this.condition, response => { + for (let index in response.data) { + let test = response.data[index]; + test.request = JSON.parse(test.request); + } + this.apiCaseList = response.data; + if (this.apiCaseList.length == 0) { + this.addCase(); + } + }); + } }, validate(row) { if (!row.name) { @@ -356,7 +348,7 @@ return; } let bodyFiles = this.getBodyUploadFiles(row); - row.projectId = this.api.projectId; + row.projectId = this.projectId; row.apiDefinitionId = row.apiDefinitionId || this.api.id; let url = "/api/testcase/create"; if (row.id) { @@ -386,17 +378,6 @@ } }, - caseChecked(row) { - row.protocol = this.api.protocol; - row.hashTree = []; - if (this.checkedCases.has(row)) { - this.checkedCases.delete(row); - } else { - this.checkedCases.add(row) - } - let arr = Array.from(this.checkedCases); - this.currentRow.cases = arr; - }, handleClose() { this.visible = false; } diff --git a/frontend/src/business/components/api/definition/components/ApiList.vue b/frontend/src/business/components/api/definition/components/ApiList.vue index 5cf4513c32..1828e6322c 100644 --- a/frontend/src/business/components/api/definition/components/ApiList.vue +++ b/frontend/src/business/components/api/definition/components/ApiList.vue @@ -1,94 +1,87 @@ @@ -146,9 +139,6 @@ visible: { type: Boolean, default: false, - }, - currentRow: { - type: Object, } }, created: function () { @@ -198,9 +188,6 @@ this.selectRows.add(row); } let arr = Array.from(this.selectRows); - if (this.currentRow) { - this.currentRow.apis = arr; - } // 选中1个以上的用例时显示更多操作 if (this.selectRows.size === 1) { this.$set(arr[0], "showMore", false); @@ -228,10 +215,6 @@ this.$set(row, "showMore", false); }) } - if (this.currentRow) { - let arr = Array.from(this.selectRows); - this.currentRow.apis = arr; - } }, search() { this.initApiTable(); @@ -283,11 +266,11 @@ }); } }, - handleTestCase(testCase) { - this.selectApi = testCase; - let request = JSON.parse(testCase.request); + handleTestCase(api) { + this.selectApi = api; + let request = JSON.parse(api.request); this.selectApi.url = request.path; - this.$refs.caseList.open(); + this.$refs.caseList.open(this.selectApi); }, handleDelete(api) { if (this.currentModule != undefined && this.currentModule.id == "gc") { diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue index d0ae264e20..fd9f604c8e 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue @@ -30,7 +30,7 @@ - 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 b9efc62597..108a496606 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue @@ -74,7 +74,7 @@ :loaded="loaded" :refreshSign="refreshSign" :createCase="createCase" - :api="api" + :currentApi="api" ref="caseList"/> diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue index 9de5d56272..c156f530a5 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue @@ -29,7 +29,7 @@ - diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue index bd4fb08241..30858d8c18 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue @@ -30,7 +30,7 @@ -