fix(接口测试): 修复场景调试结果显示问题 #github8902
This commit is contained in:
parent
c85c397eba
commit
44c7ff8ad2
|
@ -213,6 +213,7 @@
|
|||
@runScenario="runDebug"
|
||||
@stopScenario="stop"
|
||||
@setDomain="setDomain"
|
||||
@reloadResult="reloadResult"
|
||||
@openScenario="openScenario"/>
|
||||
</span>
|
||||
</el-tree>
|
||||
|
@ -466,7 +467,8 @@ export default {
|
|||
runScenario: undefined,
|
||||
showFollow: false,
|
||||
envGroupId: "",
|
||||
environmentType: ENV_TYPE.JSON
|
||||
environmentType: ENV_TYPE.JSON,
|
||||
debugResults: [],
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -639,6 +641,7 @@ export default {
|
|||
this.reqTotalTime = 0;
|
||||
this.reqTotal = 0;
|
||||
this.reqSuccess = 0;
|
||||
this.debugResults = [];
|
||||
},
|
||||
clearResult(arr) {
|
||||
if (arr) {
|
||||
|
@ -735,7 +738,11 @@ export default {
|
|||
})
|
||||
} else if ((item.data && item.data.id + "_" + item.data.parentIndex === data.resourceId)
|
||||
|| (item.data && item.data.resourceId + "_" + item.data.parentIndex === data.resourceId)) {
|
||||
item.data.requestResult.push(data);
|
||||
if (item.data.requestResult) {
|
||||
item.data.requestResult.push(data);
|
||||
} else {
|
||||
item.data.requestResult = [data];
|
||||
}
|
||||
// 更新父节点状态
|
||||
this.resultEvaluation(data.resourceId, data.success);
|
||||
item.data.testing = false;
|
||||
|
@ -750,6 +757,23 @@ export default {
|
|||
}
|
||||
})
|
||||
},
|
||||
setParentIndex(stepArray, fullPath) {
|
||||
for (let i in stepArray) {
|
||||
// 添加debug结果
|
||||
stepArray[i].data.parentIndex = fullPath ? fullPath + "_" + stepArray[i].data.index : stepArray[i].data.index;
|
||||
if (stepArray[i].childNodes && stepArray[i].childNodes.length > 0) {
|
||||
this.setParentIndex(stepArray[i].childNodes, stepArray[i].data.parentIndex);
|
||||
}
|
||||
}
|
||||
},
|
||||
reloadResult() {
|
||||
if (this.debugResults && this.debugResults.length > 0) {
|
||||
this.setParentIndex(this.$refs.stepTree.root.childNodes);
|
||||
this.debugResults.forEach(item => {
|
||||
this.runningEvaluation(item);
|
||||
})
|
||||
}
|
||||
},
|
||||
runningEvaluation(resultData) {
|
||||
if (this.$refs.stepTree && this.$refs.stepTree.root) {
|
||||
this.$refs.stepTree.root.childNodes.forEach(item => {
|
||||
|
@ -794,12 +818,16 @@ export default {
|
|||
}
|
||||
}
|
||||
this.runningEvaluation(e.data);
|
||||
if (e.data && e.data.startsWith("result_")) {
|
||||
this.debugResults.push(e.data);
|
||||
}
|
||||
this.message = getUUID();
|
||||
if (e.data && e.data.indexOf("MS_TEST_END") !== -1) {
|
||||
this.runScenario = undefined;
|
||||
this.debugLoading = false;
|
||||
this.message = "stop";
|
||||
this.stopDebug = "stop";
|
||||
this.currentScenario.debugResults = this.debugResults;
|
||||
this.reload();
|
||||
}
|
||||
},
|
||||
|
|
|
@ -69,12 +69,14 @@ import MsDubboBasisParameters from "../../../definition/components/request/dubbo
|
|||
import MsApiRequestForm from "../../../definition/components/request/http/ApiHttpRequestForm";
|
||||
import ApiBaseComponent from "../common/ApiBaseComponent";
|
||||
import {getCurrentProjectID, getCurrentWorkspaceId, getUUID, strMapToObj} from "@/common/js/utils";
|
||||
import {STEP} from "@/business/components/api/automation/scenario/Setting";
|
||||
import {ELEMENT_TYPE, STEP, TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
|
||||
import {KeyValue} from "@/business/components/api/definition/model/ApiTestModel";
|
||||
|
||||
export default {
|
||||
name: "ApiScenarioComponent",
|
||||
props: {
|
||||
scenario: {},
|
||||
currentScenario: {},
|
||||
message: String,
|
||||
node: {},
|
||||
isMax: {
|
||||
|
@ -111,9 +113,6 @@ export default {
|
|||
this.scenario.projectId = getCurrentProjectID();
|
||||
}
|
||||
if (this.scenario.id && this.scenario.referenced === 'REF' && !this.scenario.loaded) {
|
||||
let scenarios = JSON.parse(JSON.stringify(this.scenario.hashTree));
|
||||
let map = new Map();
|
||||
this.formatResult(map, scenarios);
|
||||
this.result = this.$get("/api/automation/getApiScenario/" + this.scenario.id, response => {
|
||||
if (response.data) {
|
||||
this.scenario.loaded = true;
|
||||
|
@ -122,7 +121,6 @@ export default {
|
|||
obj = JSON.parse(response.data.scenarioDefinition);
|
||||
this.scenario.hashTree = obj.hashTree;
|
||||
}
|
||||
this.setResult(this.scenario.hashTree, map);
|
||||
this.scenario.projectId = response.data.projectId;
|
||||
const pro = this.projectList.find(p => p.id === response.data.projectId);
|
||||
if (!pro) {
|
||||
|
@ -139,6 +137,7 @@ export default {
|
|||
this.scenario.headers = obj.headers;
|
||||
this.scenario.variables = obj.variables;
|
||||
this.scenario.environmentMap = obj.environmentMap;
|
||||
this.$emit('reloadResult');
|
||||
this.$emit('refReload');
|
||||
}
|
||||
})
|
||||
|
@ -186,31 +185,6 @@ export default {
|
|||
runScenario.stepScenario = true;
|
||||
this.$emit('runScenario', runScenario);
|
||||
},
|
||||
formatResult(map, scenarios) {
|
||||
scenarios.forEach(item => {
|
||||
if (this.stepFilter.get("AllSamplerProxy").indexOf(item.type) !== -1 && item.requestResult) {
|
||||
let key = (item.id ? item.id : item.resourceId) + "_" + item.index;
|
||||
if (map.has(key)) {
|
||||
map.get(key).push(... item.requestResult);
|
||||
} else {
|
||||
map.set(key, item.requestResult);
|
||||
}
|
||||
}
|
||||
if (item.hashTree && item.hashTree.length > 0) {
|
||||
this.formatResult(map, item.hashTree);
|
||||
}
|
||||
})
|
||||
},
|
||||
setResult(array, scenarios) {
|
||||
if (array && scenarios) {
|
||||
array.forEach(item => {
|
||||
let key = (item.id ? item.id : item.resourceId) + "_" + item.index;
|
||||
if (scenarios.has(key)) {
|
||||
item.requestResult = scenarios.get(key);
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
stop() {
|
||||
this.scenario.run = false;
|
||||
this.$emit('stopScenario');
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
@refReload="refReload"
|
||||
@openScenario="openScenario"
|
||||
@setDomain="setDomain"
|
||||
@reloadResult="reloadResult"
|
||||
/>
|
||||
</keep-alive>
|
||||
</div>
|
||||
|
@ -234,6 +235,9 @@ export default {
|
|||
},
|
||||
setDomain() {
|
||||
this.$emit("setDomain");
|
||||
},
|
||||
reloadResult() {
|
||||
this.$emit('reloadResult');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,9 @@
|
|||
this.reload();
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.$emit('reloadResult');
|
||||
},
|
||||
methods: {
|
||||
reload() {
|
||||
this.loading = true
|
||||
|
|
|
@ -161,6 +161,9 @@ export default {
|
|||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.$emit('reloadResult');
|
||||
},
|
||||
watch: {
|
||||
message() {
|
||||
this.reload();
|
||||
|
|
Loading…
Reference in New Issue