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; let apiTest = this.$store.state.test;
if (apiTest && apiTest.name) { if (apiTest && apiTest.name) {
this.$set(this.test, "name", apiTest.name); this.$set(this.test, "name", apiTest.name);
let blob = new Blob([apiTest.jmx.xml], {type: "application/octet-stream"}); if (apiTest.jmx.scenarioId) {
let suffixIndex = apiTest.jmx.name.lastIndexOf(".jmx"); this.$refs.basicConfig.importScenario(apiTest.jmx.scenarioId);
let jmxName = apiTest.jmx.name.substring(0, suffixIndex) + "_" + new Date().getTime() + ".jmx"; this.$refs.basicConfig.handleUpload();
let file = new File([blob], jmxName); // }
this.$refs.basicConfig.beforeUploadJmx(file); if (apiTest.jmx.caseId) {
this.$refs.basicConfig.handleUpload({file: file}); this.$refs.basicConfig.importCase(apiTest.jmx);
}
if (JSON.stringify(apiTest.jmx.attachFiles) != "{}") { if (JSON.stringify(apiTest.jmx.attachFiles) != "{}") {
let attachFiles = []; let attachFiles = [];
for (let fileID in apiTest.jmx.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 MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import ExistFiles from "@/business/components/performance/test/components/ExistFiles"; import ExistFiles from "@/business/components/performance/test/components/ExistFiles";
import ExistScenarios from "@/business/components/performance/test/components/ExistScenarios"; import ExistScenarios from "@/business/components/performance/test/components/ExistScenarios";
import {findThreadGroup} from "@/business/components/performance/test/model/ThreadGroup";
export default { export default {
name: "PerformanceBasicConfig", name: "PerformanceBasicConfig",
@ -329,12 +330,30 @@ export default {
} }
return true; return true;
}, },
beforeUploadJmx(file) { importScenario(scenarioId) {
this.$refs.existFiles.beforeUploadFile(file); 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 // api
this.$refs.existFiles.handleUpload(file, true); this.$refs.existScenarios.handleImport();
}, },
}, },
} }