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