From 1c197dd589b46beb1b161455bf292be3ec0a6a85 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 21 May 2024 13:55:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=8E=AF=E5=A2=83=E4=BF=9D=E5=AD=98=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E5=8F=82=E6=95=B0=E6=97=A0=E6=95=88=E7=9A=84=E7=BC=BA?= =?UTF-8?q?=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../environment/EnvironmentEdit.vue | 45 ++++++++++++++++++ .../components/EnvironmentEdit.vue | 46 +++++++++++++++++++ 2 files changed, 91 insertions(+) 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);