fix(接口测试): 修复场景步骤执行结果获取不到问题

--bug=1009281 --user=赵勇 [github#8902]接口自动化中部分引用场景会存在执行后无执行记录 https://www.tapd.cn/55049933/s/1087601
This commit is contained in:
fit2-zhao 2021-12-28 14:40:00 +08:00 committed by fit2-zhao
parent f44e54e261
commit 47759b90e1
2 changed files with 37 additions and 33 deletions

View File

@ -627,25 +627,27 @@ export default {
}); });
}, },
stop() { stop() {
let url = "/api/automation/stop/" + this.reportId; if (this.reportId) {
this.$get(url, response => { let url = "/api/automation/stop/" + this.reportId;
this.debugLoading = false; this.$get(url, response => {
try {
if (this.websocket) {
this.websocket.close();
}
if (this.messageWebSocket) {
this.messageWebSocket.close();
}
this.clearNodeStatus(this.$refs.stepTree.root.childNodes);
this.clearDebug();
this.$success(this.$t('report.test_stop_success'));
this.showHide();
} catch (e) {
this.debugLoading = false; this.debugLoading = false;
} try {
}); if (this.websocket) {
this.runScenario = undefined; this.websocket.close();
}
if (this.messageWebSocket) {
this.messageWebSocket.close();
}
this.clearNodeStatus(this.$refs.stepTree.root.childNodes);
this.clearDebug();
this.$success(this.$t('report.test_stop_success'));
this.showHide();
} catch (e) {
this.debugLoading = false;
}
});
this.runScenario = undefined;
}
}, },
clearDebug() { clearDebug() {
this.reqError = 0; this.reqError = 0;

View File

@ -22,7 +22,7 @@
<i class="el-icon-warning"/> <i class="el-icon-warning"/>
</el-tooltip> </el-tooltip>
</span> </span>
<span v-xpack v-if="scenario.versionEnable">{{$t('project.version.name')}}: {{ scenario.versionName }}</span> <span v-xpack v-if="scenario.versionEnable">{{ $t('project.version.name') }}: {{ scenario.versionName }}</span>
</template> </template>
<template v-slot:behindHeaderLeft> <template v-slot:behindHeaderLeft>
@ -104,7 +104,7 @@ export default {
}, },
}, },
created() { created() {
if(this.scenario.num){ if (this.scenario.num) {
this.isShowNum = true; this.isShowNum = true;
} }
if (!this.scenario.projectId) { if (!this.scenario.projectId) {
@ -127,7 +127,7 @@ export default {
if (this.scenario.hashTree) { if (this.scenario.hashTree) {
this.setDisabled(this.scenario.hashTree, this.scenario.projectId); this.setDisabled(this.scenario.hashTree, this.scenario.projectId);
} }
if(response.data.num){ if (response.data.num) {
this.scenario.num = response.data.num; this.scenario.num = response.data.num;
this.getWorkspaceId(response.data.projectId); this.getWorkspaceId(response.data.projectId);
} }
@ -140,11 +140,10 @@ export default {
this.$emit('refReload'); this.$emit('refReload');
} }
}) })
} } else if (this.scenario.id && (this.scenario.referenced === 'Copy' || this.scenario.referenced === 'Created') && !this.scenario.loaded) {
else if(this.scenario.id && (this.scenario.referenced === 'Copy'||this.scenario.referenced === 'Created') && !this.scenario.loaded){
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) {
if(response.data.num){ if (response.data.num) {
this.scenario.num = response.data.num; this.scenario.num = response.data.num;
this.getWorkspaceId(response.data.projectId); this.getWorkspaceId(response.data.projectId);
} else { } else {
@ -163,8 +162,8 @@ export default {
return { return {
loading: false, loading: false,
isShowInput: false, isShowInput: false,
isShowNum:false, isShowNum: false,
isSameSpace:true isSameSpace: true
} }
}, },
computed: { computed: {
@ -181,7 +180,9 @@ export default {
methods: { methods: {
run() { run() {
this.scenario.run = true; this.scenario.run = true;
this.$emit('runScenario', this.scenario); let runScenario = JSON.parse(JSON.stringify(this.scenario));
runScenario.hashTree = [this.scenario];
this.$emit('runScenario', runScenario);
}, },
stop() { stop() {
this.scenario.run = false; this.scenario.run = false;
@ -284,16 +285,16 @@ export default {
clickResource(resource) { clickResource(resource) {
let automationData = this.$router.resolve({ let automationData = this.$router.resolve({
name: 'ApiAutomation', name: 'ApiAutomation',
params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + resource.id,projectId:resource.projectId} params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + resource.id, projectId: resource.projectId}
}); });
window.open(automationData.href, '_blank'); window.open(automationData.href, '_blank');
}, },
getWorkspaceId(projectId){ getWorkspaceId(projectId) {
this.$get("/project/get/" + projectId, response => { this.$get("/project/get/" + projectId, response => {
if(response.data){ if (response.data) {
if(response.data.workspaceId===getCurrentWorkspaceId()){ if (response.data.workspaceId === getCurrentWorkspaceId()) {
this.isShowNum = true; this.isShowNum = true;
}else { } else {
this.isSameSpace = false; this.isSameSpace = false;
} }
} }
@ -363,7 +364,8 @@ export default {
.ms-test-running { .ms-test-running {
color: #6D317C; color: #6D317C;
} }
.ms-num{
.ms-num {
margin-left: 1rem; margin-left: 1rem;
font-size: 15px; font-size: 15px;
color: #de9d1c; color: #de9d1c;