From 0c92343d11b53e04317e1e0576b3c3888f3e37b4 Mon Sep 17 00:00:00 2001
From: MeterSphere Bot <78466014+metersphere-bot@users.noreply.github.com>
Date: Tue, 17 May 2022 09:55:56 +0800
Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?=
=?UTF-8?q?=20=E4=BC=98=E5=8C=96=E5=9C=BA=E6=99=AF=E6=96=AD=E8=A8=80,?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=AD=E8=A8=80=E5=90=8E=E7=BD=AE=E9=A1=B6?=
=?UTF-8?q?=20(#13630)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: wxg0103 <727495428@qq.com>
---
.../automation/scenario/EditApiScenario.vue | 30 ++++++++++++++++---
.../scenario/common/ApiBaseComponent.vue | 3 +-
.../assertion/ScenarioAssertions.vue | 1 +
3 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
index 271de706d7..9608e15007 100644
--- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
+++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
@@ -395,6 +395,7 @@ import {
} from "@/business/components/api/automation/api-automation";
import MsComponentConfig from "./component/ComponentConfig";
import {ENV_TYPE} from "@/common/js/constants";
+import {hisDataProcessing} from "@/business/components/api/definition/api-definition";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const versionHistory = requireComponent.keys().length > 0 ? requireComponent("./version/VersionHistory.vue") : {};
@@ -1134,7 +1135,21 @@ export default {
}
},
addComponent(type, plugin) {
- setComponent(type, this, plugin);
+ let isAssertions = false;
+ if (type === 'Assertions') {
+ this.scenarioDefinition.forEach(item => {
+ if (item.type === type) {
+ item.active = true;
+ isAssertions = true;
+ return;
+ }
+ })
+ if (!isAssertions) {
+ setComponent(type, this, plugin);
+ }
+ } else {
+ setComponent(type, this, plugin);
+ }
},
nodeClick(data, node) {
if ((data.referenced != 'REF' && data.referenced != 'Deleted' && !data.disabled && this.stepFilter) || data.refType === 'CASE') {
@@ -1622,7 +1637,7 @@ export default {
} else {
this.onSampleError = obj.onSampleError;
}
- this.dataProcessing(obj.hashTree);
+ this.dataProcessing(obj.hashTree, obj);
this.scenarioDefinition = obj.hashTree;
}
}
@@ -1664,9 +1679,16 @@ export default {
})
}
},
- dataProcessing(stepArray) {
+ dataProcessing(stepArray, obj) {
if (stepArray) {
for (let i in stepArray) {
+ if (stepArray[i].type === "Assertions") {
+ hisDataProcessing(stepArray, obj)
+ let assertions = stepArray[i];
+ stepArray.splice(i, 1);
+ stepArray.unshift(assertions);
+ this.sort();
+ }
let typeArray = ["JDBCPostProcessor", "JDBCSampler", "JDBCPreProcessor"]
if (typeArray.indexOf(stepArray[i].type) !== -1) {
stepArray[i].originalDataSourceId = stepArray[i].dataSourceId;
@@ -1682,7 +1704,7 @@ export default {
};
}
if (stepArray[i].hashTree.length > 0) {
- this.dataProcessing(stepArray[i].hashTree);
+ this.dataProcessing(stepArray[i].hashTree, stepArray[i]);
}
}
}
diff --git a/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue b/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue
index 24c11ad7fe..6ce7548875 100644
--- a/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue
+++ b/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue
@@ -42,7 +42,8 @@
-