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); },