fix(接口测试): 修复场景导入跳转失败以及跳转权限问题

https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001018494
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001018498
--user=郭雨琦
This commit is contained in:
guoyuqi 2022-10-20 14:34:06 +08:00 committed by xiaomeinvG
parent 70020244d1
commit 624e64a398
3 changed files with 50 additions and 24 deletions

View File

@ -2126,6 +2126,7 @@ public class ApiScenarioService {
object.put("referenced", "Copy");
}
} else {
//将复制的或者类型不是引用case的步骤赋予当前项目id目的是为了运行的时候可以配置运行环境
object.put("projectId", projectId);
if (StringUtils.isEmpty(object.optString("url"))) {
object.put("isRefEnvironment", true);

View File

@ -168,7 +168,7 @@
</template>
<script>
import {getCaseById} from "@/api/api-test-case";
import {getApiCaseById, getCaseById} from "@/api/api-test-case";
import {getCurrentProjectID, getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token";
import {getUUID} from "metersphere-frontend/src/utils";
import {getUrl} from "@/business/automation/scenario/component/urlhelper";
@ -176,6 +176,7 @@ import {getCurrentByResourceId} from "@/api/user";
import {getOwnerProjectIds, getProject} from "@/api/project";
import {execStop} from "@/api/scenario";
import {useApiStore} from "@/store";
import {getDefinitionById} from "@/api/definition";
const store = useApiStore();
export default {
@ -599,18 +600,23 @@ export default {
clickResource(resource) {
let workspaceId = getCurrentWorkspaceId();
let isTurnSpace = true
if (resource.projectId !== getCurrentProjectID()) {
isTurnSpace = false;
getProject(resource.projectId).then(response => {
if (response.data) {
workspaceId = response.data.workspaceId;
isTurnSpace = true;
this.checkPermission(resource, workspaceId, isTurnSpace);
}
});
} else {
this.checkPermission(resource, workspaceId, isTurnSpace);
if (resource.num) {
if (resource.refType === 'API') {
getDefinitionById(resource.id).then(res => {
if (res.data) {
this.getWorkspaceId(resource, res.data, isTurnSpace, workspaceId);
}
})
} else {
getApiCaseById(resource.id).then(res => {
if (res.data) {
this.getWorkspaceId(resource, res.data, isTurnSpace, workspaceId);
}
})
}
}
},
clickCase(resource) {
let uri = getUrl(resource);
@ -685,6 +691,21 @@ export default {
}
})
},
getWorkspaceId(resource, data, isTurnSpace, workspaceId) {
resource.projectId = data.projectId;
if (data.projectId !== getCurrentProjectID()) {
isTurnSpace = false;
getProject(data.projectId).then(response => {
if (response.data) {
workspaceId = response.data.workspaceId;
isTurnSpace = true;
this.checkPermission(resource, workspaceId, isTurnSpace);
}
});
} else {
this.checkPermission(resource, workspaceId, isTurnSpace);
}
}
}
}

View File

@ -85,7 +85,7 @@ import {getCurrentProjectID, getCurrentWorkspaceId} from "metersphere-frontend/s
import {getUUID, strMapToObj} from "metersphere-frontend/src/utils";
import {STEP} from "@/business/automation/scenario/Setting";
import {getOwnerProjectIds, getProject} from "@/api/project";
import {checkScenarioEnv, setScenarioDomain} from "@/api/scenario";
import {checkScenarioEnv, getScenarioById, setScenarioDomain} from "@/api/scenario";
export default {
name: "ApiScenarioComponent",
@ -288,19 +288,23 @@ export default {
clickResource(resource) {
let workspaceId = getCurrentWorkspaceId();
let isTurnSpace = true
if (resource.projectId !== getCurrentProjectID()) {
isTurnSpace = false;
getProject(resource.projectId).then(response => {
if (response.data) {
workspaceId = response.data.workspaceId;
isTurnSpace = true;
getScenarioById(resource.id).then(res => {
if (res.data) {
resource.projectId = res.data.projectId;
if (resource.projectId !== getCurrentProjectID()) {
isTurnSpace = false;
getProject(resource.projectId).then(response => {
if (response.data) {
workspaceId = response.data.workspaceId;
isTurnSpace = true;
this.checkPermission(resource, workspaceId, isTurnSpace);
}
});
} else {
this.checkPermission(resource, workspaceId, isTurnSpace);
}
});
} else {
this.checkPermission(resource, workspaceId, isTurnSpace);
}
}
})
},
gotoTurn(resource, workspaceId, isTurnSpace) {
let automationData = this.$router.resolve({