fix(接口自动化): 修复场景调试无环境报错问题 #09e9b5b7
--bug=1005268 --user=赵勇 【接口自动化】编辑场... https://www.tapd.cn/55049933/s/1026836
This commit is contained in:
parent
dd1758493a
commit
34811a9613
|
@ -1393,9 +1393,11 @@ public class ApiAutomationService {
|
|||
if (map != null) {
|
||||
map.keySet().forEach(id -> {
|
||||
ApiTestEnvironmentWithBLOBs environment = environmentService.get(map.get(id));
|
||||
if (environment != null && environment.getConfig() != null) {
|
||||
EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
env.setApiEnvironmentid(environment.getId());
|
||||
envConfig.put(id, env);
|
||||
}
|
||||
});
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -449,7 +449,9 @@ export default {
|
|||
.report-header {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
/deep/ .el-card__body{
|
||||
padding: 0px;
|
||||
}
|
||||
.report-header a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@
|
|||
:allow-drop="allowDrop" @node-drag-end="allowDrag" @node-click="nodeClick" v-if="!loading" draggable ref="stepTree">
|
||||
<span class="custom-tree-node father" slot-scope="{ node, data}" style="width: 96%">
|
||||
<!-- 步骤组件-->
|
||||
<ms-component-config :type="data.type" :scenario="data" :response="response" :currentScenario="currentScenario" :expandedNode="expandedNode"
|
||||
<ms-component-config :message="message" :type="data.type" :scenario="data" :response="response" :currentScenario="currentScenario" :expandedNode="expandedNode"
|
||||
:currentEnvironmentId="currentEnvironmentId" :node="node" :project-list="projectList" :env-map="projectEnvMap"
|
||||
@remove="remove" @copyRow="copyRow" @suggestClick="suggestClick" @refReload="refReload" @openScenario="openScenario"/>
|
||||
</span>
|
||||
|
@ -416,6 +416,7 @@ export default {
|
|||
stopDebug: "",
|
||||
isTop: false,
|
||||
stepSize: 0,
|
||||
message: "",
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -509,6 +510,7 @@ export default {
|
|||
if (e.data) {
|
||||
let data = JSON.parse(e.data);
|
||||
this.formatResult(data);
|
||||
this.message = getUUID();
|
||||
if (data.end) {
|
||||
this.removeReport();
|
||||
this.debugLoading = false;
|
||||
|
@ -561,7 +563,7 @@ export default {
|
|||
}
|
||||
this.debugResult = resMap;
|
||||
this.sort();
|
||||
this.reload();
|
||||
// this.reload();
|
||||
this.reloadDebug = getUUID();
|
||||
},
|
||||
removeReport() {
|
||||
|
@ -709,74 +711,44 @@ export default {
|
|||
this.isBtnHide = true;
|
||||
this.$refs.scenarioApiRelevance.open();
|
||||
},
|
||||
recursiveSorting(arr, scenarioProjectId) {
|
||||
for (let i in arr) {
|
||||
arr[i].index = Number(i) + 1;
|
||||
if (!arr[i].resourceId) {
|
||||
arr[i].resourceId = getUUID();
|
||||
sort(stepArray, scenarioProjectId) {
|
||||
if (!stepArray) {
|
||||
stepArray = this.scenarioDefinition;
|
||||
}
|
||||
if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) {
|
||||
arr[i].countController.proceed = true;
|
||||
for (let i in stepArray) {
|
||||
stepArray[i].index = Number(i) + 1;
|
||||
if (!stepArray[i].resourceId) {
|
||||
stepArray[i].resourceId = getUUID();
|
||||
}
|
||||
if (!arr[i].projectId) {
|
||||
if (stepArray[i].type === ELEMENT_TYPE.LoopController
|
||||
&& stepArray[i].loopType === "LOOP_COUNT"
|
||||
&& stepArray[i].hashTree
|
||||
&& stepArray[i].hashTree.length > 1) {
|
||||
stepArray[i].countController.proceed = true;
|
||||
}
|
||||
if (!stepArray[i].projectId) {
|
||||
// 如果自身没有ID并且场景有ID则赋值场景ID,否则赋值当前项目ID
|
||||
arr[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId;
|
||||
stepArray[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId;
|
||||
} else {
|
||||
const project = this.projectList.find(p => p.id === arr[i].projectId);
|
||||
const project = this.projectList.find(p => p.id === stepArray[i].projectId);
|
||||
if (!project) {
|
||||
arr[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId;
|
||||
stepArray[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId;
|
||||
}
|
||||
}
|
||||
// 添加debug结果
|
||||
let key = arr[i].resourceId;
|
||||
let key = stepArray[i].resourceId;
|
||||
if (this.debugResult && this.debugResult.get(key)) {
|
||||
arr[i].requestResult = this.debugResult.get(key);
|
||||
arr[i].result = null;
|
||||
arr[i].debug = this.debug;
|
||||
this.findNode(key, arr[i].requestResult[0].success);
|
||||
stepArray[i].requestResult = this.debugResult.get(key);
|
||||
stepArray[i].result = null;
|
||||
stepArray[i].debug = this.debug;
|
||||
this.findNode(key, stepArray[i].requestResult[0].success);
|
||||
}
|
||||
if (arr[i].hashTree && arr[i].hashTree.length > 0) {
|
||||
this.stepSize += arr[i].hashTree.length;
|
||||
this.recursiveSorting(arr[i].hashTree, arr[i].projectId);
|
||||
if (stepArray[i].hashTree && stepArray[i].hashTree.length > 0) {
|
||||
this.stepSize += stepArray[i].hashTree.length;
|
||||
this.sort(stepArray[i].hashTree, stepArray[i].projectId);
|
||||
}
|
||||
}
|
||||
},
|
||||
sort() {
|
||||
this.stepSize = this.scenarioDefinition.length;
|
||||
for (let i in this.scenarioDefinition) {
|
||||
// 排序
|
||||
this.scenarioDefinition[i].index = Number(i) + 1;
|
||||
if (!this.scenarioDefinition[i].resourceId) {
|
||||
this.scenarioDefinition[i].resourceId = getUUID();
|
||||
}
|
||||
// 设置循环控制
|
||||
if (this.scenarioDefinition[i].type === ELEMENT_TYPE.LoopController && this.scenarioDefinition[i].hashTree
|
||||
&& this.scenarioDefinition[i].hashTree.length > 1) {
|
||||
this.scenarioDefinition[i].countController.proceed = true;
|
||||
}
|
||||
// 设置项目ID
|
||||
if (!this.scenarioDefinition[i].projectId) {
|
||||
this.scenarioDefinition[i].projectId = this.projectId;
|
||||
} else {
|
||||
const project = this.projectList.find(p => p.id === this.scenarioDefinition[i].projectId);
|
||||
if (!project) {
|
||||
this.scenarioDefinition[i].projectId = this.projectId;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.scenarioDefinition[i].hashTree !== undefined && this.scenarioDefinition[i].hashTree.length > 0) {
|
||||
this.stepSize += this.scenarioDefinition[i].hashTree.length;
|
||||
this.recursiveSorting(this.scenarioDefinition[i].hashTree, this.scenarioDefinition[i].projectId);
|
||||
}
|
||||
// 添加debug结果
|
||||
if (this.debugResult && this.debugResult.get(this.scenarioDefinition[i].resourceId)) {
|
||||
this.scenarioDefinition[i].result = null;
|
||||
this.scenarioDefinition[i].requestResult = this.debugResult.get(this.scenarioDefinition[i].resourceId);
|
||||
this.scenarioDefinition[i].debug = this.debug;
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
addCustomizeApi(request) {
|
||||
this.customizeVisible = false;
|
||||
request.enable === undefined ? request.enable = true : request.enable;
|
||||
|
@ -970,7 +942,6 @@ export default {
|
|||
});
|
||||
}
|
||||
},
|
||||
|
||||
checkDataIsCopy() {
|
||||
// 如果是复制按钮创建的场景,直接进行保存
|
||||
if (this.currentScenario.copy) {
|
||||
|
@ -1148,8 +1119,7 @@ export default {
|
|||
this.currentScenario.apiScenarioModuleId = this.currentModule.id;
|
||||
}
|
||||
this.currentScenario.projectId = this.projectId;
|
||||
}
|
||||
,
|
||||
},
|
||||
runRefresh() {
|
||||
if (!this.debug) {
|
||||
this.debugVisible = true;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<el-tag size="mini" class="ms-tag" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
|
||||
</template>
|
||||
<template v-slot:debugStepCode>
|
||||
<span class="ms-step-debug-code" :class="request.requestResult[0].success?'ms-req-success':'ms-req-error'" v-if="request.debug && request.requestResult[0] && request.requestResult[0].responseResult">
|
||||
<span class="ms-step-debug-code" :class="request.requestResult[0].success?'ms-req-success':'ms-req-error'" v-if="!loading && request.debug && request.requestResult[0] && request.requestResult[0].responseResult">
|
||||
{{ request.requestResult[0].success ? 'success' : 'error' }}
|
||||
</span>
|
||||
</template>
|
||||
|
@ -133,7 +133,8 @@ export default {
|
|||
currentEnvironmentId: String,
|
||||
projectList: Array,
|
||||
expandedNode: Array,
|
||||
envMap: Map
|
||||
envMap: Map,
|
||||
message: String
|
||||
},
|
||||
components: {
|
||||
TemplateComponent,
|
||||
|
@ -188,6 +189,9 @@ export default {
|
|||
envMap() {
|
||||
this.getEnvironments();
|
||||
},
|
||||
message() {
|
||||
this.reload();
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
displayColor() {
|
||||
|
@ -337,7 +341,10 @@ export default {
|
|||
})
|
||||
}
|
||||
},
|
||||
recursiveSorting(arr) {
|
||||
sort(arr) {
|
||||
if (!arr) {
|
||||
arr = this.request.hashTree;
|
||||
}
|
||||
for (let i in arr) {
|
||||
arr[i].disabled = true;
|
||||
arr[i].index = Number(i) + 1;
|
||||
|
@ -345,19 +352,7 @@ export default {
|
|||
arr[i].resourceId = getUUID();
|
||||
}
|
||||
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
|
||||
this.recursiveSorting(arr[i].hashTree);
|
||||
}
|
||||
}
|
||||
},
|
||||
sort() {
|
||||
for (let i in this.request.hashTree) {
|
||||
if (!this.request.hashTree[i].resourceId) {
|
||||
this.request.hashTree[i].resourceId = getUUID();
|
||||
}
|
||||
this.request.hashTree[i].disabled = true;
|
||||
this.request.hashTree[i].index = Number(i) + 1;
|
||||
if (this.request.hashTree[i].hashTree != undefined && this.request.hashTree[i].hashTree.length > 0) {
|
||||
this.recursiveSorting(this.request.hashTree[i].hashTree);
|
||||
this.sort(arr[i].hashTree);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<span class="ms-tag">{{ getProjectName(scenario.projectId) }}</span>
|
||||
</template>
|
||||
<template v-slot:debugStepCode>
|
||||
<span class="ms-step-debug-code" :class="node.data.code ==='error'?'ms-req-error':'ms-req-success'" v-if="node.data.debug">
|
||||
<span class="ms-step-debug-code" :class="node.data.code ==='error'?'ms-req-error':'ms-req-success'" v-if="!loading && node.data.debug">
|
||||
{{ getCode() }}
|
||||
</span>
|
||||
</template>
|
||||
|
@ -43,6 +43,7 @@ export default {
|
|||
name: "ApiScenarioComponent",
|
||||
props: {
|
||||
scenario: {},
|
||||
message: String,
|
||||
node: {},
|
||||
isMax: {
|
||||
type: Boolean,
|
||||
|
@ -59,7 +60,11 @@ export default {
|
|||
currentEnvironmentId: String,
|
||||
projectList: Array
|
||||
},
|
||||
watch: {},
|
||||
watch: {
|
||||
message() {
|
||||
this.reload();
|
||||
},
|
||||
},
|
||||
created() {
|
||||
if (!this.scenario.projectId) {
|
||||
this.scenario.projectId = getCurrentProjectID();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<component v-bind:is="component" :isMax="isMax" :show-btn="showBtn" :expandedNode="expandedNode"
|
||||
:scenario="scenario" :controller="scenario" :timer="scenario" :assertions="scenario" :extract="scenario" :jsr223-processor="scenario" :request="scenario" :currentScenario="currentScenario" :currentEnvironmentId="currentEnvironmentId" :node="node"
|
||||
:draggable="draggable" :title="title" :color="titleColor" :background-color="backgroundColor" @suggestClick="suggestClick(node)" :response="response"
|
||||
@remove="remove" @copyRow="copyRow" @refReload="refReload" @openScenario="openScenario" :project-list="projectList" :env-map="envMap"/>
|
||||
@remove="remove" @copyRow="copyRow" @refReload="refReload" @openScenario="openScenario" :project-list="projectList" :env-map="envMap" :message="message"/>
|
||||
</keep-alive>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -28,6 +28,7 @@
|
|||
components: {MsConstantTimer, MsIfController, MsTransactionController, MsJsr233Processor, MsApiAssertions, MsApiExtract, MsApiComponent, MsLoopController, MsApiScenarioComponent, MsJdbcProcessor,JmeterElementComponent},
|
||||
props: {
|
||||
type: String,
|
||||
message: String,
|
||||
scenario: {},
|
||||
draggable: {
|
||||
type: Boolean,
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
</template>
|
||||
|
||||
<template v-slot:debugStepCode>
|
||||
<span class="ms-step-debug-code" :class="node.data.code ==='error'?'ms-req-error':'ms-req-success'" v-if="node.data.debug">
|
||||
<span class="ms-step-debug-code" :class="node.data.code ==='error'?'ms-req-error':'ms-req-success'" v-if="!loading && node.data.debug">
|
||||
{{ getCode() }}
|
||||
</span>
|
||||
</template>
|
||||
|
@ -43,6 +43,7 @@
|
|||
props: {
|
||||
controller: {},
|
||||
node: {},
|
||||
message: String,
|
||||
isMax: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
|
@ -59,6 +60,7 @@
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
operators: {
|
||||
EQ: {
|
||||
label: "commons.adv_search.operators.equals",
|
||||
|
@ -95,7 +97,18 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
message() {
|
||||
this.reload();
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
reload() {
|
||||
this.loading = true
|
||||
this.$nextTick(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
getCode() {
|
||||
if (this.node && this.node.data.debug) {
|
||||
if (this.node.data.code && this.node.data.code === 'error') {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</div>
|
||||
|
||||
<template v-slot:debugStepCode>
|
||||
<span class="ms-step-debug-code" :class="node.data.code ==='error'?'ms-req-error':'ms-req-success'" v-if="node.data.debug">
|
||||
<span class="ms-step-debug-code" :class="node.data.code ==='error'?'ms-req-error':'ms-req-success'" v-if="!loading && node.data.debug">
|
||||
{{ getCode() }}
|
||||
</span>
|
||||
</template>
|
||||
|
@ -38,6 +38,7 @@
|
|||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
message: String,
|
||||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default:
|
||||
|
@ -59,7 +60,23 @@
|
|||
defBackgroundColor: {type: String, default: "#F4F4FF"},
|
||||
node: {},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
message() {
|
||||
this.reload();
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
reload() {
|
||||
this.loading = true
|
||||
this.$nextTick(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
getCode() {
|
||||
if (this.node && this.node.data.debug) {
|
||||
if (this.node.data.code && this.node.data.code === 'error') {
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
</div>
|
||||
|
||||
<template v-slot:debugStepCode>
|
||||
<span class="ms-step-debug-code" :class="node.data.code ==='error'?'ms-req-error':'ms-req-success'" v-if="node.data.debug">
|
||||
<span class="ms-step-debug-code" :class="node.data.code ==='error'?'ms-req-error':'ms-req-success'" v-if="!loading && node.data.debug">
|
||||
{{ getCode() }}
|
||||
</span>
|
||||
</template>
|
||||
|
@ -95,6 +95,7 @@ export default {
|
|||
currentEnvironmentId: String,
|
||||
currentScenario: {},
|
||||
node: {},
|
||||
message: String,
|
||||
isMax: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
|
@ -156,6 +157,11 @@ export default {
|
|||
},
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
message() {
|
||||
this.reload();
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getCode() {
|
||||
if (this.node && this.node.data.debug) {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
background-color="#FCF6EE"
|
||||
:title="$t('api_test.automation.transcation_controller')">
|
||||
<template v-slot:debugStepCode>
|
||||
<span class="ms-step-debug-code" :class="node.data.code ==='error'?'ms-req-error':'ms-req-success'" v-if="node.data.debug">
|
||||
<span class="ms-step-debug-code" :class="node.data.code ==='error'?'ms-req-error':'ms-req-success'" v-if="!loading && node.data.debug">
|
||||
{{ getCode() }}
|
||||
</span>
|
||||
</template>
|
||||
|
@ -34,6 +34,7 @@ export default {
|
|||
props: {
|
||||
controller: {},
|
||||
node: {},
|
||||
message: String,
|
||||
isMax: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
|
@ -48,6 +49,11 @@ export default {
|
|||
default: false,
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
message() {
|
||||
this.reload();
|
||||
},
|
||||
},
|
||||
created() {
|
||||
if (this.controller.generateParentSample == null) {
|
||||
this.controller.generateParentSample = true;
|
||||
|
@ -58,6 +64,7 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
operators: {
|
||||
EQ: {
|
||||
label: "commons.adv_search.operators.equals",
|
||||
|
@ -95,6 +102,12 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
reload() {
|
||||
this.loading = true;
|
||||
this.$nextTick(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
getCode() {
|
||||
if (this.node && this.node.data.debug) {
|
||||
if (this.node.data.code && this.node.data.code === 'error') {
|
||||
|
|
Loading…
Reference in New Issue