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