diff --git a/framework/sdk-parent/frontend/src/components/environment/EnvironmentEdit.vue b/framework/sdk-parent/frontend/src/components/environment/EnvironmentEdit.vue index eb97f4f755..2920bfdad8 100644 --- a/framework/sdk-parent/frontend/src/components/environment/EnvironmentEdit.vue +++ b/framework/sdk-parent/frontend/src/components/environment/EnvironmentEdit.vue @@ -459,6 +459,18 @@ export default { this.$warning(message); return; } + if (environment.config.assertions && environment.config.assertions.document && environment.config.assertions.document.originalData) { + this.mergeEnvDocumentData( + environment.config.assertions.document.originalData, + environment.config.assertions.document.tableData, + environment.config.assertions.document.rootData + ); + if (environment.config.assertions.document.type === 'JSON') { + environment.config.assertions.document.data.json = environment.config.assertions.document.originalData; + } else { + environment.config.assertions.document.data.xml = environment.config.assertions.document.originalData; + } + } let bodyFiles = this.geFiles(environment); let variablesFiles = this.getVariablesFiles(environment); @@ -513,6 +525,39 @@ export default { clearValidate() { this.$refs["environment"].clearValidate(); }, + mergeEnvDocumentData(originalData, childMap, rootData) { + originalData.forEach((item) => { + if (item.id === "root" && rootData) { + 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.size !== 0 && + childMap instanceof Map && + 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) => { + let index = sourceData.findIndex((source) => source.id === target.id); + if (index !== -1) { + target.children = sourceData[index].children; + } + }); + if (item.children && item.children.length > 0) { + this.mergeEnvDocumentData(item.children, childMap); + } + } + }); + } }, } diff --git a/project-management/frontend/src/business/menu/environment/components/EnvironmentEdit.vue b/project-management/frontend/src/business/menu/environment/components/EnvironmentEdit.vue index 857215cb90..b0df0d43ea 100644 --- a/project-management/frontend/src/business/menu/environment/components/EnvironmentEdit.vue +++ b/project-management/frontend/src/business/menu/environment/components/EnvironmentEdit.vue @@ -473,6 +473,19 @@ export default { formData.append("variablesFiles", f); }) } + if (environment.config.assertions && environment.config.assertions.document && environment.config.assertions.document.originalData) { + this.mergeDocumentData( + environment.config.assertions.document.originalData, + environment.config.assertions.document.tableData, + environment.config.assertions.document.rootData + ); + if (environment.config.assertions.document.type === 'JSON') { + environment.config.assertions.document.data.json = environment.config.assertions.document.originalData; + } else { + environment.config.assertions.document.data.xml = environment.config.assertions.document.originalData; + } + } + let param = this.buildParam(environment); formData.append('request', new Blob([JSON.stringify(param)], {type: "application/json"})); editEnv(formData, param).then((response) => { @@ -484,6 +497,39 @@ export default { }); }, + mergeDocumentData(originalData, childMap, rootData) { + originalData.forEach((item) => { + if (item.id === "root" && rootData) { + 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.size !== 0 && + childMap instanceof Map && + 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) => { + let index = sourceData.findIndex((source) => source.id === target.id); + if (index !== -1) { + target.children = sourceData[index].children; + } + }); + if (item.children && item.children.length > 0) { + this.mergeDocumentData(item.children, childMap); + } + } + }); + }, buildParam: function (environment) { let param = {}; Object.assign(param, environment);