From 76d4f5dcb3d61240e7f0b8328d6d9db987a561fd Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 12 Jan 2022 19:06:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=BA=E6=99=AF=E8=B0=83=E8=AF=95=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=20#github8902?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/scenario/EditApiScenario.vue | 29 +++++++++++++++- .../component/ApiScenarioComponent.vue | 34 +++---------------- .../scenario/component/ComponentConfig.vue | 4 +++ .../scenario/component/IfController.vue | 3 ++ .../scenario/component/LoopController.vue | 3 ++ 5 files changed, 42 insertions(+), 31 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index ed527507c0..736fc44bb8 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -220,6 +220,7 @@ @stopScenario="stop" @setDomain="setDomain" @openScenario="openScenario" + @reloadResult="reloadResult" @editScenarioAdvance="editScenarioAdvance"/> @@ -515,6 +516,7 @@ export default { dialogVisible:false, newScenarioDefinition:[], currentItem: {}, + debugResults: [], } }, watch: { @@ -691,6 +693,7 @@ export default { this.reqTotalTime = 0; this.reqTotal = 0; this.reqSuccess = 0; + this.debugResults = []; }, clearResult(arr) { if (arr) { @@ -787,7 +790,11 @@ export default { }) } else if ((item.data && item.data.id + "_" + item.data.parentIndex === data.resourceId) || (item.data && item.data.resourceId + "_" + item.data.parentIndex === data.resourceId)) { - item.data.requestResult.push(data); + if (item.data.requestResult) { + item.data.requestResult.push(data); + } else { + item.data.requestResult = [data]; + } // 更新父节点状态 this.resultEvaluation(data.resourceId, data.success); item.data.testing = false; @@ -802,6 +809,23 @@ export default { } }) }, + setParentIndex(stepArray, fullPath) { + for (let i in stepArray) { + // 添加debug结果 + stepArray[i].data.parentIndex = fullPath ? fullPath + "_" + stepArray[i].data.index : stepArray[i].data.index; + if (stepArray[i].childNodes && stepArray[i].childNodes.length > 0) { + this.setParentIndex(stepArray[i].childNodes, stepArray[i].data.parentIndex); + } + } + }, + reloadResult() { + if (this.debugResults && this.debugResults.length > 0) { + this.setParentIndex(this.$refs.stepTree.root.childNodes); + this.debugResults.forEach(item => { + this.runningEvaluation(item); + }) + } + }, runningEvaluation(resultData) { if (this.$refs.stepTree && this.$refs.stepTree.root) { this.$refs.stepTree.root.childNodes.forEach(item => { @@ -846,6 +870,9 @@ export default { } } this.runningEvaluation(e.data); + if (e.data && e.data.startsWith("result_")) { + this.debugResults.push(e.data); + } this.message = getUUID(); if (e.data && e.data.indexOf("MS_TEST_END") !== -1) { this.runScenario = undefined; diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue index 5982271aa6..3285ea6c95 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue @@ -71,12 +71,14 @@ import MsDubboBasisParameters from "../../../definition/components/request/dubbo import MsApiRequestForm from "../../../definition/components/request/http/ApiHttpRequestForm"; import ApiBaseComponent from "../common/ApiBaseComponent"; import {getCurrentProjectID, getCurrentWorkspaceId, getUUID, strMapToObj} from "@/common/js/utils"; -import {STEP} from "@/business/components/api/automation/scenario/Setting"; +import {ELEMENT_TYPE, STEP, TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting"; +import {KeyValue} from "@/business/components/api/definition/model/ApiTestModel"; export default { name: "ApiScenarioComponent", props: { scenario: {}, + currentScenario: {}, message: String, node: {}, isMax: { @@ -117,9 +119,6 @@ export default { this.scenario.projectId = getCurrentProjectID(); } if (this.scenario.id && this.scenario.referenced === 'REF' && !this.scenario.loaded) { - let scenarios = JSON.parse(JSON.stringify(this.scenario.hashTree)); - let map = new Map(); - this.formatResult(map, scenarios); this.result = this.$get("/api/automation/getApiScenario/" + this.scenario.id, response => { if (response.data) { this.scenario.loaded = true; @@ -128,7 +127,6 @@ export default { obj = JSON.parse(response.data.scenarioDefinition); this.scenario.hashTree = obj.hashTree; } - this.setResult(this.scenario.hashTree, map); this.scenario.projectId = response.data.projectId; const pro = this.projectList.find(p => p.id === response.data.projectId); if (!pro) { @@ -147,6 +145,7 @@ export default { this.scenario.headers = obj.headers; this.scenario.variables = obj.variables; this.scenario.environmentMap = obj.environmentMap; + this.$emit('reloadResult'); this.$emit('refReload'); } }) @@ -196,31 +195,6 @@ export default { runScenario.stepScenario = true; this.$emit('runScenario', runScenario); }, - formatResult(map, scenarios) { - scenarios.forEach(item => { - if (this.stepFilter.get("AllSamplerProxy").indexOf(item.type) !== -1 && item.requestResult) { - let key = (item.id ? item.id : item.resourceId) + "_" + item.index; - if (map.has(key)) { - map.get(key).push(... item.requestResult); - } else { - map.set(key, item.requestResult); - } - } - if (item.hashTree && item.hashTree.length > 0) { - this.formatResult(map, item.hashTree); - } - }) - }, - setResult(array, scenarios) { - if (array && scenarios) { - array.forEach(item => { - let key = (item.id ? item.id : item.resourceId) + "_" + item.index; - if (scenarios.has(key)) { - item.requestResult = scenarios.get(key); - } - }) - } - }, stop() { this.scenario.run = false; this.$emit('stopScenario'); diff --git a/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue b/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue index 6d98e41425..e871b1cc43 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue @@ -39,6 +39,7 @@ @setDomain="setDomain" @savePreParams="savePreParams" @editScenarioAdvance="editScenarioAdvance" + @reloadResult="reloadResult" /> @@ -250,6 +251,9 @@ export default { editScenarioAdvance(data) { this.$emit('editScenarioAdvance', data); }, + reloadResult() { + this.$emit('reloadResult'); + } } } diff --git a/frontend/src/business/components/api/automation/scenario/component/IfController.vue b/frontend/src/business/components/api/automation/scenario/component/IfController.vue index 579ef185c9..b952f50ef8 100644 --- a/frontend/src/business/components/api/automation/scenario/component/IfController.vue +++ b/frontend/src/business/components/api/automation/scenario/component/IfController.vue @@ -111,6 +111,9 @@ this.reload(); }, }, + created() { + this.$emit('reloadResult'); + }, methods: { reload() { this.loading = true diff --git a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue index 5ec469ac6b..6b1553278d 100644 --- a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue +++ b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue @@ -165,6 +165,9 @@ export default { }, }; }, + created() { + this.$emit('reloadResult'); + }, watch: { message() { this.reload();