perf(接口测试): 接口自动化跨空间跳转

--user=郭雨琦 接口自动化跨空间跳转
This commit is contained in:
guoyuqi 2022-03-15 12:47:59 +08:00 committed by xiaomeinvG
parent d10eca9ddc
commit 2b6ee03d83
2 changed files with 67 additions and 48 deletions

View File

@ -226,7 +226,6 @@ export default {
environmentMap: this.envMap, environmentMap: this.envMap,
isShowNum: false, isShowNum: false,
response: {}, response: {},
dataWorkspaceId: '',
} }
}, },
created() { created() {
@ -683,36 +682,20 @@ export default {
}, },
clickResource(resource) { clickResource(resource) {
if (resource.refType && resource.refType === 'API') { let workspaceId;
if (resource.protocol === 'dubbo://') { let isTurnSpace = true
resource.protocol = 'DUBBO' if(resource.projectId!==getCurrentProjectID()){
} isTurnSpace = false;
let definitionData = this.$router.resolve({ this.$get("/project/get/" + resource.projectId, response => {
name: 'ApiDefinition',
params: {
redirectID: getUUID(),
dataType: "api",
dataSelectRange: 'edit:' + resource.id,
projectId: resource.projectId,
type: resource.protocol,
workspaceId: this.dataWorkspaceId,
}
});
window.open(definitionData.href, '_blank');
} else if (resource.refType && resource.refType === 'CASE') {
this.$get("/api/testcase/findById/" + resource.id, response => {
if (response.data) { if (response.data) {
response.data.sourceId = resource.resourceId; workspaceId = response.data.workspaceId;
response.data.type = resource.type; isTurnSpace = true;
response.data.refType = resource.refType; this.gotoTurn(resource,workspaceId,isTurnSpace);
response.data.workspaceId = this.dataWorkspaceId;
this.clickCase(response.data)
} else {
this.$error("接口用例场景场景已经被删除");
} }
}); });
}else{
this.gotoTurn(resource,workspaceId,isTurnSpace);
} }
}, },
clickCase(resource) { clickCase(resource) {
let uri = getUrl(resource); let uri = getUrl(resource);
@ -739,16 +722,44 @@ export default {
let element = document.getElementById(id); let element = document.getElementById(id);
element.parentNode.removeChild(element); element.parentNode.removeChild(element);
}, },
getWorkspaceId(projectId) {
this.$get("/project/get/" + projectId, response => {
if (response.data) {
this.dataWorkspaceId = response.data.workspaceId
}
});
},
editScenarioAdvance(data) { editScenarioAdvance(data) {
this.$emit('editScenarioAdvance', data); this.$emit('editScenarioAdvance', data);
}, },
gotoTurn(resource, workspaceId, isTurnSpace) {
if (resource.refType && resource.refType === 'API') {
if (resource.protocol === 'dubbo://') {
resource.protocol = 'DUBBO'
}
let definitionData = this.$router.resolve({
name: 'ApiDefinition',
params: {
redirectID: getUUID(),
dataType: "api",
dataSelectRange: 'edit:' + resource.id,
projectId: resource.projectId,
type: resource.protocol,
workspaceId: workspaceId,
}
});
if(isTurnSpace){
window.open(definitionData.href, '_blank');
}
} else if (resource.refType && resource.refType === 'CASE') {
this.$get("/api/testcase/findById/" + resource.id, response => {
if (response.data) {
response.data.sourceId = resource.resourceId;
response.data.type = resource.type;
response.data.refType = resource.refType;
response.data.workspaceId = workspaceId;
if(isTurnSpace){
this.clickCase(response.data)
}
} else {
this.$error("接口用例场景场景已经被删除");
}
});
}
}
} }
} }
</script> </script>

View File

@ -119,7 +119,6 @@ export default {
created() { created() {
if (this.scenario.num) { if (this.scenario.num) {
this.isShowNum = true; this.isShowNum = true;
this.getWorkspaceId(this.scenario.projectId);
} else { } else {
this.isShowNum = false; this.isShowNum = false;
} }
@ -134,7 +133,6 @@ export default {
isShowInput: false, isShowInput: false,
isShowNum: false, isShowNum: false,
stepFilter: new STEP, stepFilter: new STEP,
dataWorkspaceId: '',
} }
}, },
computed: { computed: {
@ -142,9 +140,6 @@ export default {
return this.scenario.referenced !== undefined && this.scenario.referenced === 'Deleted' || this.scenario.referenced === 'REF'; return this.scenario.referenced !== undefined && this.scenario.referenced === 'Deleted' || this.scenario.referenced === 'REF';
}, },
/*projectId() {
return getCurrentProjectID();
},*/
}, },
methods: { methods: {
run() { run() {
@ -261,19 +256,32 @@ export default {
}, },
clickResource(resource) { clickResource(resource) {
let workspaceId;
let isTurnSpace = true
if(resource.projectId!==getCurrentProjectID()){
isTurnSpace = false;
this.$get("/project/get/" + resource.projectId, response => {
if (response.data) {
workspaceId = response.data.workspaceId;
isTurnSpace = true;
this.gotoTurn(resource,workspaceId,isTurnSpace);
}
});
}else {
this.gotoTurn(resource,workspaceId,isTurnSpace);
}
},
gotoTurn(resource,workspaceId,isTurnSpace){
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, workspaceId: this.dataWorkspaceId} params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + resource.id, projectId: resource.projectId, workspaceId: workspaceId}
});
window.open(automationData.href, '_blank');
},
getWorkspaceId(projectId) {
this.$get("/project/get/" + projectId, response => {
if (response.data) {
this.dataWorkspaceId = response.data.workspaceId;
}
}); });
if(isTurnSpace){
window.open(automationData.href, '_blank');
}
} }
} }
} }
</script> </script>