fix(性能测试): 修复用例和场景转换性能测试保存文件的问题

This commit is contained in:
Captain.B 2021-03-25 12:22:07 +08:00
parent cf39bb066d
commit 6e97d412ee
2 changed files with 30 additions and 10 deletions

View File

@ -126,12 +126,13 @@ export default {
let apiTest = this.$store.state.test;
if (apiTest && apiTest.name) {
this.$set(this.test, "name", apiTest.name);
let blob = new Blob([apiTest.jmx.xml], {type: "application/octet-stream"});
let suffixIndex = apiTest.jmx.name.lastIndexOf(".jmx");
let jmxName = apiTest.jmx.name.substring(0, suffixIndex) + "_" + new Date().getTime() + ".jmx";
let file = new File([blob], jmxName); //
this.$refs.basicConfig.beforeUploadJmx(file);
this.$refs.basicConfig.handleUpload({file: file});
if (apiTest.jmx.scenarioId) {
this.$refs.basicConfig.importScenario(apiTest.jmx.scenarioId);
this.$refs.basicConfig.handleUpload();
}
if (apiTest.jmx.caseId) {
this.$refs.basicConfig.importCase(apiTest.jmx);
}
if (JSON.stringify(apiTest.jmx.attachFiles) != "{}") {
let attachFiles = [];
for (let fileID in apiTest.jmx.attachFiles) {

View File

@ -116,6 +116,7 @@ import MsTableOperatorButton from "@/business/components/common/components/MsTab
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import ExistFiles from "@/business/components/performance/test/components/ExistFiles";
import ExistScenarios from "@/business/components/performance/test/components/ExistScenarios";
import {findThreadGroup} from "@/business/components/performance/test/model/ThreadGroup";
export default {
name: "PerformanceBasicConfig",
@ -329,12 +330,30 @@ export default {
}
return true;
},
beforeUploadJmx(file) {
this.$refs.existFiles.beforeUploadFile(file);
importScenario(scenarioId) {
this.$refs.existScenarios.selectIds.add(scenarioId);
},
handleUpload(file) {
importCase(caseObj) {
console.log("case: ", caseObj);
let suffixIndex = caseObj.name.lastIndexOf(".jmx");
let jmxName = caseObj.name.substring(0, suffixIndex) + "_" + new Date().getTime() + ".jmx";
let threadGroups = findThreadGroup(caseObj.xml, jmxName);
threadGroups.forEach(tg => {
tg.options = {};
});
this.fileChange(threadGroups);
let file = new File([caseObj.xml], jmxName);
this.uploadList.push(file);
this.tableData.push({
name: file.name,
size: (file.size / 1024).toFixed(2) + ' KB',
type: 'JMX',
updateTime: file.lastModified,
});
},
handleUpload() {
// api
this.$refs.existFiles.handleUpload(file, true);
this.$refs.existScenarios.handleImport();
},
},
}