This commit is contained in:
fit2-zhao 2021-02-26 17:16:28 +08:00
commit 5735efc372
5 changed files with 17 additions and 35 deletions

View File

@ -2,7 +2,7 @@
<div></div>
</template>
<script>
import {getUUID, getCurrentProjectID} from "@/common/js/utils";
import {getUUID, getCurrentProjectID, strMapToObj} from "@/common/js/utils";
import {createComponent} from "../../definition/components/jmeter/components";
export default {
@ -117,22 +117,15 @@
threadGroup.hashTree.push(this.runData);
testPlan.hashTree.push(threadGroup);
let reqObj = {id: this.reportId, reportId: this.reportId, scenarioName: this.runData.name,
scenarioId: this.runData.id, testElement: testPlan, projectId: getCurrentProjectID(), environmentMap: this.strMapToObj(map)};
scenarioId: this.runData.id, testElement: testPlan, projectId: getCurrentProjectID(), environmentMap: strMapToObj(map)};
let bodyFiles = this.getBodyUploadFiles(reqObj);
let url = "/api/automation/run/debug";
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
this.runId = response.data;
this.$emit('runRefresh', {});
}, erro => {
}, error => {
});
},
strMapToObj(strMap){
let obj= Object.create(null);
for (let[k,v] of strMap) {
obj[k] = v;
}
return obj;
}
}
}
</script>

View File

@ -221,7 +221,7 @@ import {
import {parseEnvironment} from "../../definition/model/EnvironmentModel";
import {ELEMENT_TYPE, ELEMENTS} from "./Setting";
import MsApiCustomize from "./ApiCustomize";
import {getCurrentProjectID, getUUID} from "@/common/js/utils";
import {getCurrentProjectID, getUUID, objToStrMap, strMapToObj} from "@/common/js/utils";
import ApiEnvironmentConfig from "../../definition/components/environment/ApiEnvironmentConfig";
import MsInputTag from "./MsInputTag";
import MsRun from "./DebugRun";
@ -901,14 +901,6 @@ export default {
}
})
},
objToStrMap(obj) {
let strMap = new Map();
for (let k of Object.keys(obj)) {
strMap.set(k, obj[k]);
}
return strMap;
},
getApiScenario() {
if (this.currentScenario.tags != undefined && !(this.currentScenario.tags instanceof Array)) {
this.currentScenario.tags = JSON.parse(this.currentScenario.tags);
@ -928,7 +920,7 @@ export default {
if (obj) {
this.currentEnvironmentId = obj.environmentId;
if (obj.environmentMap) {
this.projectEnvMap = this.objToStrMap(obj.environmentMap);
this.projectEnvMap = objToStrMap(obj.environmentMap);
} else {
//
this.projectEnvMap.set(getCurrentProjectID(), obj.environmentId);
@ -964,13 +956,6 @@ export default {
})
}
},
strMapToObj(strMap){
let obj= Object.create(null);
for (let[k,v] of strMap) {
obj[k] = v;
}
return obj;
},
setParameter() {
this.currentScenario.stepTotal = this.scenarioDefinition.length;
this.currentScenario.projectId = getCurrentProjectID();
@ -984,7 +969,7 @@ export default {
variables: this.currentScenario.variables,
headers: this.currentScenario.headers,
referenced: 'Created',
environmentMap: this.strMapToObj(this.projectEnvMap),
environmentMap: strMapToObj(this.projectEnvMap),
hashTree: this.scenarioDefinition,
projectId: this.projectId,
};

View File

@ -1,6 +1,6 @@
<template>
<div>
<ms-run :debug="true" :environment="currentEnvironmentId" :reportId="reportId" :run-data="debugData"
<ms-run :debug="true" :environment="envMap" :reportId="reportId" :run-data="debugData"
@runRefresh="runRefresh" ref="runTest"/>
<api-base-component
@copy="copyRow"
@ -115,6 +115,7 @@ export default {
type: Boolean,
default: false,
},
envMap: Map
},
created() {
// this.initResult();
@ -193,11 +194,6 @@ export default {
}
},
runDebug() {
/*触发执行操作*/
if (!this.currentEnvironmentId) {
this.$error(this.$t('api_test.environment.select_environment'));
return;
}
if (!this.controller.hashTree || this.controller.hashTree.length < 1) {
this.$warning("当前循环下没有请求,不能执行")
return;

View File

@ -86,7 +86,7 @@
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
this.runId = response.data;
this.getResult();
}, erro => {
}, error => {
this.$emit('runRefresh', {});
});
}

View File

@ -340,3 +340,11 @@ export function strMapToObj(strMap) {
}
return null;
}
export function objToStrMap(obj) {
let strMap = new Map();
for (let k of Object.keys(obj)) {
strMap.set(k, obj[k]);
}
return strMap;
}