From 80d964fcd3ce678509d87caa775481a67c922f0b Mon Sep 17 00:00:00 2001 From: baiqi Date: Wed, 13 Dec 2023 18:18:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E3=80=90=E3=80=90=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95=E3=80=91?= =?UTF-8?q?github#27933=EF=BC=8C=E3=80=90=E6=8E=A5=E5=8F=A3=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8C=96=E3=80=91=E5=BD=93=E5=9C=BA=E6=99=AF=E6=9C=89?= =?UTF-8?q?=E5=BE=88=E5=A4=9A=E8=87=AA=E5=AE=9A=E4=B9=89=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E7=82=B9=E5=87=BB=E8=B0=83=E8=AF=95=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E7=82=B9=E5=87=BB=E6=8E=A8=E8=8D=90jsonpath=E6=8F=90?= =?UTF-8?q?=E5=8F=96=EF=BC=8C=E4=BC=9A=E5=87=BA=E7=8E=B0"=E8=AF=B7?= =?UTF-8?q?=E5=85=88=E6=89=A7=E8=A1=8C=E8=B0=83=E8=AF=95=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E7=BB=93=E6=9E=9C"=E7=9A=84=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=EF=BC=8C=E4=BB=A5=E5=8F=8A=E5=87=BA=E7=8E=B0=E4=BA=86?= =?UTF-8?q?jsonpath=E6=8F=90=E5=8F=96=E5=86=85=E5=AE=B9=E4=B8=8E=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E5=86=85=E5=AE=B9=E4=B8=8D=E5=AF=B9=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1033563 --user=白奇 【接口测试】github#27933,【接口自动化】当场景有很多自定义请求时,点击调试后,点击推荐jsonpath提取,会出现"请先执行调试获取响应结果"的提示,以及出现了jsonpath提取内容与响应内容不对应的问题 https://www.tapd.cn/55049933/s/1443650 --- .../automation/scenario/EditApiScenario.vue | 10 +- .../scenario/component/ApiComponent.vue | 115 ++++++++++-------- 2 files changed, 70 insertions(+), 55 deletions(-) diff --git a/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue b/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue index b2dedce486..a1819616fd 100644 --- a/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue +++ b/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue @@ -251,7 +251,7 @@ -
+
@@ -1515,14 +1515,17 @@ export default { this.showAll(); this.buttonData = buttons(this); this.initPlugins(); - if (e && e.target.className && e.target.className.split(" ")[1] === "white--space") { + if (e && e.target.className && e.target.className.split(' ')[1] === 'white--space') { this.selectedTreeNode = undefined; this.selectedNode = undefined; } }, fabClick() { if (this.operatingElements && this.operatingElements.length < 1) { - if ((this.selectedTreeNode && this.selectedTreeNode.referenced === 'REF') || (this.selectedNode.disabled && this.selectedTreeNode.disabled)) { + if ( + (this.selectedTreeNode && this.selectedTreeNode.referenced === 'REF') || + (this.selectedNode.disabled && this.selectedTreeNode.disabled) + ) { this.$warning(this.$t('api_test.scenario.scenario_warning')); } else { this.$warning(this.$t('api_test.scenario.scenario_step_warning')); @@ -2016,6 +2019,7 @@ export default { } } if (this.scenarioDefinition !== null) { + this.stepCount = 0; this.dataProcessing(this.scenarioDefinition); } // 保存成功后刷新历史版本 diff --git a/api-test/frontend/src/business/automation/scenario/component/ApiComponent.vue b/api-test/frontend/src/business/automation/scenario/component/ApiComponent.vue index 462241e24e..1876b0513e 100644 --- a/api-test/frontend/src/business/automation/scenario/component/ApiComponent.vue +++ b/api-test/frontend/src/business/automation/scenario/component/ApiComponent.vue @@ -256,60 +256,15 @@ export default { }; }, created() { - this.request.protocol = this.request.protocol === 'ESB' ? 'TCP' : this.request.protocol; - // 历史数据兼容 - if (!this.request.requestResult) { - this.request.requestResult = [{ responseResult: {} }]; - } else if ( - this.request.requestResult && - Object.prototype.toString.call(this.request.requestResult) !== '[object Array]' - ) { - let obj = JSON.parse(JSON.stringify(this.request.requestResult)); - this.request.requestResult = [obj]; - } - // 跨项目关联,如果没有ID,则赋值本项目ID - if (!this.request.projectId) { - this.request.projectId = getCurrentProjectID(); - } - this.request.customizeReq = this.isCustomizeReq; - if (this.request.customizeReq) { - if (this.node.parent && this.node.parent.data && this.node.parent.data.length > 1) { - this.request.projectId = getCurrentProjectID(); - } else { - this.request.projectId = - this.node.parent.data instanceof Array ? this.node.parent.data[0].projectId : this.node.parent.data.projectId; - } - } - if (this.currentScenario) { - this.request.currentScenarioId = this.currentScenario.id; - } - // 传递场景ID - if (this.request.hashTree) { - this.setOwnEnvironment(this.request.hashTree); - } - if (this.request.id && this.request.referenced === 'REF') { - this.request.disabled = true; - this.request.root = this.node.parent.parent ? false : true; - this.request.showExtend = - this.node.parent && this.node.parent.data && this.node.parent.data.disabled ? false : true; - } - this.isShowNum = this.request.num ? true : false; - if (this.request.protocol === 'HTTP') { - // 历史数据 auth 处理 - if (this.request.hashTree) { - for (let index in this.request.hashTree) { - if (this.request.hashTree[index].type == 'AuthManager') { - this.request.authManager = this.request.hashTree[index]; - this.request.hashTree.splice(index, 1); - } - } - } - } - if (this.request.requestResult && this.request.requestResult.length > 0) { - this.response = this.request.requestResult[0]; - } + this.init(); }, watch: { + request: { + handler() { + this.init(); + }, + deep: true, + }, message() { this.forStatus(); this.reload(); @@ -374,6 +329,62 @@ export default { }, }, methods: { + init() { + this.request.protocol = this.request.protocol === 'ESB' ? 'TCP' : this.request.protocol; + // 历史数据兼容 + if (!this.request.requestResult) { + this.request.requestResult = [{ responseResult: {} }]; + } else if ( + this.request.requestResult && + Object.prototype.toString.call(this.request.requestResult) !== '[object Array]' + ) { + let obj = JSON.parse(JSON.stringify(this.request.requestResult)); + this.request.requestResult = [obj]; + } + // 跨项目关联,如果没有ID,则赋值本项目ID + if (!this.request.projectId) { + this.request.projectId = getCurrentProjectID(); + } + this.request.customizeReq = this.isCustomizeReq; + if (this.request.customizeReq) { + if (this.node.parent && this.node.parent.data && this.node.parent.data.length > 1) { + this.request.projectId = getCurrentProjectID(); + } else { + this.request.projectId = + this.node.parent.data instanceof Array + ? this.node.parent.data[0].projectId + : this.node.parent.data.projectId; + } + } + if (this.currentScenario) { + this.request.currentScenarioId = this.currentScenario.id; + } + // 传递场景ID + if (this.request.hashTree) { + this.setOwnEnvironment(this.request.hashTree); + } + if (this.request.id && this.request.referenced === 'REF') { + this.request.disabled = true; + this.request.root = this.node.parent.parent ? false : true; + this.request.showExtend = + this.node.parent && this.node.parent.data && this.node.parent.data.disabled ? false : true; + } + this.isShowNum = this.request.num ? true : false; + if (this.request.protocol === 'HTTP') { + // 历史数据 auth 处理 + if (this.request.hashTree) { + for (let index in this.request.hashTree) { + if (this.request.hashTree[index].type == 'AuthManager') { + this.request.authManager = this.request.hashTree[index]; + this.request.hashTree.splice(index, 1); + } + } + } + } + if (this.request.requestResult && this.request.requestResult.length > 0) { + this.response = this.request.requestResult[0]; + } + }, setOwnEnvironment(scenarioDefinition) { for (let i in scenarioDefinition) { let typeArray = ['JDBCPostProcessor', 'JDBCSampler', 'JDBCPreProcessor'];