From 41990ea2c4606ee44c865fa6a78ebb7e4d819229 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 22 Nov 2022 15:25:13 +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=8Djson=E6=96=87=E6=A1=A3=E6=96=AD=E8=A8=80?= =?UTF-8?q?=E4=BF=AE=E6=94=B9root=E5=B1=82=E7=BA=A7=E7=9A=84=E6=9C=9F?= =?UTF-8?q?=E6=9C=9B=E5=80=BC=E4=BF=9D=E5=AD=98=E5=A4=B1=E6=95=88=E7=9A=84?= =?UTF-8?q?=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1019961 --user=王孝刚 [接口测试] GitHub#19876接口定义,接口用例,json文档结构校验,在预期结果处输入值后,再打开,值不见了。 https://www.tapd.cn/55049933/s/1301119 --- .../src/business/definition/api-definition.js | 27 ++++++++++--------- .../assertion/document/DocumentBody.vue | 6 +++-- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/api-test/frontend/src/business/definition/api-definition.js b/api-test/frontend/src/business/definition/api-definition.js index d1894d040a..db6c288bce 100644 --- a/api-test/frontend/src/business/definition/api-definition.js +++ b/api-test/frontend/src/business/definition/api-definition.js @@ -230,13 +230,20 @@ export function stepCompute(array, request) { request.ruleSize = ruleSize; } -export function mergeDocumentData(originalData, childMap, rootName, rootType) { +export function mergeDocumentData(originalData, childMap, rootData) { originalData.forEach((item) => { if (item.id === 'root') { - item.name = rootName; - item.type = rootType; + item.type = rootData.type; + item.name = rootData.name; + item.typeVerification = rootData.typeVerification; + item.arrayVerification = rootData.arrayVerification; + item.contentVerification = rootData.contentVerification; + item.jsonPath = rootData.jsonPath; + item.expectedOutcome = rootData.expectedOutcome; + item.include = rootData.include; + item.conditions = rootData.conditions; } - if (childMap && childMap.has(item.id)) { + if (childMap && childMap.size !== 0 && childMap.has(item.id)) { let sourceData = JSON.parse(JSON.stringify(item.children)); item.children = JSON.parse(JSON.stringify(childMap.get(item.id))); item.children.forEach((target) => { @@ -256,19 +263,13 @@ export function mergeRequestDocumentData(request) { if (request && request.hashTree && request.hashTree.length > 0) { let index = request.hashTree.findIndex((item) => item.type === 'Assertions'); if (index !== -1) { - if ( - request.hashTree[index].document && - request.hashTree[index].document.originalData && - request.hashTree[index].document.tableData.size && - request.hashTree[index].document.tableData.size !== 0 - ) { + if (request.hashTree[index].document && request.hashTree[index].document.originalData) { mergeDocumentData( request.hashTree[index].document.originalData, request.hashTree[index].document.tableData, - request.hashTree[index].document.rootName, - request.hashTree[index].document.rootType + request.hashTree[index].document.rootData ); - if (request.hashTree[index].document.type === 'json') { + if (request.hashTree[index].document.type === 'JSON') { request.hashTree[index].document.data.json = request.hashTree[index].document.originalData; } else { request.hashTree[index].document.data.xml = request.hashTree[index].document.originalData; diff --git a/api-test/frontend/src/business/definition/components/assertion/document/DocumentBody.vue b/api-test/frontend/src/business/definition/components/assertion/document/DocumentBody.vue index 1e885b9466..929a459b5e 100644 --- a/api-test/frontend/src/business/definition/components/assertion/document/DocumentBody.vue +++ b/api-test/frontend/src/business/definition/components/assertion/document/DocumentBody.vue @@ -284,6 +284,9 @@ export default { // hasChildren 表示需要展示一个箭头图标 item.hasChildren = item.children && item.children.length > 0; item.idList = [item.id]; + if (item.id === 'root') { + this.$set(this.document, 'rootData', item); + } item.children = []; return item; }); @@ -324,8 +327,7 @@ export default { // 渲染子节点 resolve(resolveArr); if (tree.id === 'root') { - this.$set(this.document, 'rootName', tree.name); - this.$set(this.document, 'rootType', tree.type); + this.$set(this.document, 'rootData', tree); } this.mapData.set(tree.id, resolveArr); },