fix(接口定义): 修复json文档断言修改root层级的期望值保存失效的缺陷

--bug=1019961 --user=王孝刚 [接口测试]
GitHub#19876接口定义,接口用例,json文档结构校验,在预期结果处输入值后,再打开,值不见了。
https://www.tapd.cn/55049933/s/1301119
This commit is contained in:
wxg0103 2022-11-22 15:25:13 +08:00 committed by fit2-zhao
parent 46fdb49152
commit 41990ea2c4
2 changed files with 18 additions and 15 deletions

View File

@ -230,13 +230,20 @@ export function stepCompute(array, request) {
request.ruleSize = ruleSize; request.ruleSize = ruleSize;
} }
export function mergeDocumentData(originalData, childMap, rootName, rootType) { export function mergeDocumentData(originalData, childMap, rootData) {
originalData.forEach((item) => { originalData.forEach((item) => {
if (item.id === 'root') { if (item.id === 'root') {
item.name = rootName; item.type = rootData.type;
item.type = rootType; 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)); let sourceData = JSON.parse(JSON.stringify(item.children));
item.children = JSON.parse(JSON.stringify(childMap.get(item.id))); item.children = JSON.parse(JSON.stringify(childMap.get(item.id)));
item.children.forEach((target) => { item.children.forEach((target) => {
@ -256,19 +263,13 @@ export function mergeRequestDocumentData(request) {
if (request && request.hashTree && request.hashTree.length > 0) { if (request && request.hashTree && request.hashTree.length > 0) {
let index = request.hashTree.findIndex((item) => item.type === 'Assertions'); let index = request.hashTree.findIndex((item) => item.type === 'Assertions');
if (index !== -1) { if (index !== -1) {
if ( if (request.hashTree[index].document && request.hashTree[index].document.originalData) {
request.hashTree[index].document &&
request.hashTree[index].document.originalData &&
request.hashTree[index].document.tableData.size &&
request.hashTree[index].document.tableData.size !== 0
) {
mergeDocumentData( mergeDocumentData(
request.hashTree[index].document.originalData, request.hashTree[index].document.originalData,
request.hashTree[index].document.tableData, request.hashTree[index].document.tableData,
request.hashTree[index].document.rootName, request.hashTree[index].document.rootData
request.hashTree[index].document.rootType
); );
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; request.hashTree[index].document.data.json = request.hashTree[index].document.originalData;
} else { } else {
request.hashTree[index].document.data.xml = request.hashTree[index].document.originalData; request.hashTree[index].document.data.xml = request.hashTree[index].document.originalData;

View File

@ -284,6 +284,9 @@ export default {
// hasChildren // hasChildren
item.hasChildren = item.children && item.children.length > 0; item.hasChildren = item.children && item.children.length > 0;
item.idList = [item.id]; item.idList = [item.id];
if (item.id === 'root') {
this.$set(this.document, 'rootData', item);
}
item.children = []; item.children = [];
return item; return item;
}); });
@ -324,8 +327,7 @@ export default {
// //
resolve(resolveArr); resolve(resolveArr);
if (tree.id === 'root') { if (tree.id === 'root') {
this.$set(this.document, 'rootName', tree.name); this.$set(this.document, 'rootData', tree);
this.$set(this.document, 'rootType', tree.type);
} }
this.mapData.set(tree.id, resolveArr); this.mapData.set(tree.id, resolveArr);
}, },