refactor(接口测试): 场景步骤排序方法优化

This commit is contained in:
fit2-zhao 2022-06-22 09:59:54 +08:00 committed by f2c-ci-robot[bot]
parent 2b75096d2a
commit 212c73ecf4
1 changed files with 26 additions and 28 deletions

View File

@ -519,7 +519,6 @@ export default {
reloadDebug: "",
stopDebug: "",
isTop: false,
stepSize: 0,
message: "",
messageWebSocket: {},
buttonData: [],
@ -1239,40 +1238,39 @@ export default {
this.isBtnHide = true;
this.$refs.scenarioApiRelevance.open();
},
sort(stepArray, scenarioProjectId, fullPath) {
if (!stepArray) {
stepArray = this.scenarioDefinition;
}
sort(stepArray) {
stepArray = stepArray || this.scenarioDefinition;
this.recursionStep(stepArray);
},
recursionStep(stepArray, scenarioProjectId, fullPath, isGeneric) {
for (let i in stepArray) {
stepArray[i].index = Number(i) + 1;
if (!stepArray[i].resourceId) {
stepArray[i].resourceId = getUUID();
let step = stepArray[i];
step.index = !isGeneric ? Number(i) + 1 : step.index;
if (step.type === 'GenericController') {
this.pluginOrder(step);
isGeneric = true;
}
step.resourceId = step.resourceId || getUUID();
//
if (stepArray[i].type === "HTTPSamplerProxy" && !stepArray[i].headers) {
stepArray[i].headers = [new KeyValue()];
if (step.type === "HTTPSamplerProxy" && !step.headers) {
step.headers = [new KeyValue()];
}
if (stepArray[i].type === ELEMENT_TYPE.LoopController
&& stepArray[i].loopType === "LOOP_COUNT"
&& stepArray[i].hashTree
&& stepArray[i].hashTree.length > 1) {
stepArray[i].countController.proceed = true;
if (step.type === ELEMENT_TYPE.LoopController
&& step.loopType === "LOOP_COUNT"
&& step.hashTree
&& step.hashTree.length > 1) {
step.countController.proceed = true;
}
if (!stepArray[i].clazzName) {
stepArray[i].clazzName = TYPE_TO_C.get(stepArray[i].type);
}
if (stepArray[i] && stepArray[i].authManager && !stepArray[i].authManager.clazzName) {
stepArray[i].authManager.clazzName = TYPE_TO_C.get(stepArray[i].authManager.type);
}
if (!stepArray[i].projectId) {
// IDIDIDID
stepArray[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId;
step.clazzName = step.clazzName || TYPE_TO_C.get(step.type);
if (step && step.authManager && !step.authManager.clazzName) {
step.authManager.clazzName = TYPE_TO_C.get(step.authManager.type);
}
// IDIDIDID
step.projectId = step.projectId || scenarioProjectId || this.projectId;
// debug
stepArray[i].parentIndex = fullPath ? fullPath + "_" + stepArray[i].index : stepArray[i].index;
if (stepArray[i].hashTree && stepArray[i].hashTree.length > 0) {
this.stepSize += stepArray[i].hashTree.length;
this.sort(stepArray[i].hashTree, stepArray[i].projectId, stepArray[i].parentIndex);
step.parentIndex = fullPath ? fullPath + "_" + step.index : step.index;
if (step.hashTree && step.hashTree.length > 0) {
this.recursionStep(step.hashTree, step.projectId, step.parentIndex, isGeneric);
}
}
},