fix (接口自动化): 修复导入场景数据缺失问题 #1005681
--bug=1005681 --user=赵勇 【接口自动化】测试报... https://www.tapd.cn/55049933/s/1037540
This commit is contained in:
parent
2a6d2117ff
commit
5cc1b69764
|
@ -65,6 +65,20 @@ public class MsScenarioParser extends MsAbstractParser<ScenarioImport> {
|
|||
return scenarioWithBLOBs;
|
||||
}
|
||||
|
||||
private void formatHashTree(JSONArray hashTree) {
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
for (int i = 0; i < hashTree.size(); i++) {
|
||||
JSONObject object = (JSONObject) hashTree.get(i);
|
||||
object.put("index", i + 1);
|
||||
object.put("resourceId", UUID.randomUUID().toString());
|
||||
hashTree.set(i, object);
|
||||
if (CollectionUtils.isNotEmpty(object.getJSONArray("hashTree"))) {
|
||||
formatHashTree(object.getJSONArray("hashTree"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ScenarioImport parseMsFormat(String testStr, ApiTestImportRequest importRequest) {
|
||||
ScenarioImport scenarioImport = JSON.parseObject(testStr, ScenarioImport.class);
|
||||
List<ApiScenarioWithBLOBs> data = scenarioImport.getData();
|
||||
|
@ -88,6 +102,7 @@ public class MsScenarioParser extends MsAbstractParser<ScenarioImport> {
|
|||
JSONObject scenarioDefinition = JSONObject.parseObject(scenarioDefinitionStr);
|
||||
if (scenarioDefinition != null) {
|
||||
JSONArray hashTree = scenarioDefinition.getJSONArray("hashTree");
|
||||
formatHashTree(hashTree);
|
||||
setCopy(hashTree);
|
||||
JSONObject environmentMap = scenarioDefinition.getJSONObject("environmentMap");
|
||||
if (environmentMap != null) {
|
||||
|
|
|
@ -107,7 +107,13 @@ export default {
|
|||
},
|
||||
created() {
|
||||
if (this.scenarioId) {
|
||||
this.getApiScenario();
|
||||
this.getApiScenario().then(() => {
|
||||
this.initTree();
|
||||
this.initWebSocket();
|
||||
this.initMessageSocket();
|
||||
this.clearDebug();
|
||||
this.loading = false;
|
||||
});
|
||||
} else {
|
||||
if (this.scenario && this.scenario.scenarioDefinition) {
|
||||
this.content.scenarioStepTotal = this.scenario.scenarioDefinition.hashTree.length;
|
||||
|
@ -129,24 +135,21 @@ export default {
|
|||
methods: {
|
||||
getApiScenario() {
|
||||
this.loading = true;
|
||||
this.result = this.$get("/api/automation/getApiScenario/" + this.scenarioId, response => {
|
||||
if (response.data) {
|
||||
this.path = "/api/automation/update";
|
||||
if (response.data.scenarioDefinition != null) {
|
||||
let obj = JSON.parse(response.data.scenarioDefinition);
|
||||
this.scenario.scenarioDefinition = obj;
|
||||
this.scenario.name = response.data.name;
|
||||
this.content.scenarioStepTotal = obj.hashTree.length;
|
||||
this.initTree();
|
||||
this.initWebSocket();
|
||||
this.initMessageSocket();
|
||||
this.clearDebug();
|
||||
if (this.scenario.scenarioDefinition && this.scenario.scenarioDefinition.hashTree) {
|
||||
this.sort(this.scenario.scenarioDefinition.hashTree);
|
||||
return new Promise((resolve) => {
|
||||
this.result = this.$get("/api/automation/getApiScenario/" + this.scenarioId, response => {
|
||||
if (response.data) {
|
||||
if (response.data.scenarioDefinition != null) {
|
||||
let obj = JSON.parse(response.data.scenarioDefinition);
|
||||
this.scenario.scenarioDefinition = obj;
|
||||
this.scenario.name = response.data.name;
|
||||
this.content.scenarioStepTotal = obj.hashTree.length;
|
||||
if (this.scenario.scenarioDefinition && this.scenario.scenarioDefinition.hashTree) {
|
||||
this.sort(this.scenario.scenarioDefinition.hashTree);
|
||||
}
|
||||
resolve();
|
||||
}
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
sort(stepArray) {
|
||||
|
@ -156,7 +159,6 @@ export default {
|
|||
stepArray[i].resourceId = getUUID();
|
||||
}
|
||||
if (stepArray[i].hashTree && stepArray[i].hashTree.length > 0) {
|
||||
this.stepSize += stepArray[i].hashTree.length;
|
||||
this.sort(stepArray[i].hashTree);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue