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,
isShowNum: false,
response: {},
dataWorkspaceId: '',
}
},
created() {
@ -683,36 +682,20 @@ export default {
},
clickResource(resource) {
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: this.dataWorkspaceId,
}
});
window.open(definitionData.href, '_blank');
} else if (resource.refType && resource.refType === 'CASE') {
this.$get("/api/testcase/findById/" + resource.id, response => {
let workspaceId;
let isTurnSpace = true
if(resource.projectId!==getCurrentProjectID()){
isTurnSpace = false;
this.$get("/project/get/" + resource.projectId, response => {
if (response.data) {
response.data.sourceId = resource.resourceId;
response.data.type = resource.type;
response.data.refType = resource.refType;
response.data.workspaceId = this.dataWorkspaceId;
this.clickCase(response.data)
} else {
this.$error("接口用例场景场景已经被删除");
workspaceId = response.data.workspaceId;
isTurnSpace = true;
this.gotoTurn(resource,workspaceId,isTurnSpace);
}
});
}else{
this.gotoTurn(resource,workspaceId,isTurnSpace);
}
},
clickCase(resource) {
let uri = getUrl(resource);
@ -739,16 +722,44 @@ export default {
let element = document.getElementById(id);
element.parentNode.removeChild(element);
},
getWorkspaceId(projectId) {
this.$get("/project/get/" + projectId, response => {
if (response.data) {
this.dataWorkspaceId = response.data.workspaceId
}
});
},
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>

View File

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