fix(接口测试): 修复创建场景附件丢失问题

--bug=1011218 --user=赵勇 【接口自动化】-创建新场景-导入api接口-post请求-请求体格式是file-上传的excel-保存场景后文件丢失 https://www.tapd.cn/55049933/s/1118298
This commit is contained in:
fit2-zhao 2022-03-15 17:59:18 +08:00 committed by 刘瑞斌
parent bd24ab842f
commit 03150ff1c5
1 changed files with 40 additions and 17 deletions

View File

@ -692,7 +692,9 @@ export default {
let data = JSON.parse(res.data);
if (data.hashTree) {
this.sort(data.hashTree);
Object.assign(this.scenarioDefinition, data.hashTree)
let domainMap = new Map();
this.getEnvDomain(data.hashTree, domainMap);
this.margeDomain(this.scenarioDefinition, domainMap);
this.cancelBatchProcessing();
if (this.$store.state.currentApiCase) {
this.$store.state.currentApiCase.resetDataSource = getUUID();
@ -704,6 +706,27 @@ export default {
})
}
},
margeDomain(array, map) {
array.forEach(item => {
if (item && map.has(item.resourceId)) {
item.domain = map.get(item.resourceId);
item.resourceId = getUUID();
}
if (item && item.hashTree && item.hashTree.length > 0) {
this.margeDomain(item.hashTree, map);
}
})
},
getEnvDomain(array, map) {
array.forEach(item => {
if (item && item.resourceId && item.domain) {
map.set(item.resourceId, item.domain);
}
if (item && item.hashTree && item.hashTree.length > 0) {
this.getEnvDomain(item.hashTree, map);
}
})
},
initPlugins() {
if (this.plugins) {
this.plugins.forEach(item => {
@ -746,25 +769,25 @@ export default {
},
stop() {
if (this.reportId) {
this.debugLoading = false;
try {
if (this.messageWebSocket) {
this.messageWebSocket.close();
}
if (this.websocket) {
this.websocket.close();
}
this.clearNodeStatus(this.$refs.stepTree.root.childNodes);
this.clearDebug();
this.$success(this.$t('report.test_stop_success'));
} catch (e) {
this.debugLoading = false;
}
this.runScenario = undefined;
// jmeter
let url = "/api/automation/stop/" + this.reportId;
this.$get(url, response => {
this.debugLoading = false;
try {
if (this.websocket) {
this.websocket.close();
}
if (this.messageWebSocket) {
this.messageWebSocket.close();
}
this.clearNodeStatus(this.$refs.stepTree.root.childNodes);
this.clearDebug();
this.$success(this.$t('report.test_stop_success'));
this.forceRerender();
} catch (e) {
this.debugLoading = false;
}
});
this.runScenario = undefined;
}
},
clearDebug() {