From 6e97d412ee559a72021563a6c297369f3de7276d Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 25 Mar 2021 12:22:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E4=BE=8B=E5=92=8C=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=96=87=E4=BB=B6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../performance/test/EditPerformanceTest.vue | 13 ++++----- .../components/PerformanceBasicConfig.vue | 27 ++++++++++++++++--- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/frontend/src/business/components/performance/test/EditPerformanceTest.vue b/frontend/src/business/components/performance/test/EditPerformanceTest.vue index 656a867d25..27338c86b5 100644 --- a/frontend/src/business/components/performance/test/EditPerformanceTest.vue +++ b/frontend/src/business/components/performance/test/EditPerformanceTest.vue @@ -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) { diff --git a/frontend/src/business/components/performance/test/components/PerformanceBasicConfig.vue b/frontend/src/business/components/performance/test/components/PerformanceBasicConfig.vue index bd5272b216..418ebf9224 100644 --- a/frontend/src/business/components/performance/test/components/PerformanceBasicConfig.vue +++ b/frontend/src/business/components/performance/test/components/PerformanceBasicConfig.vue @@ -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(); }, }, }