mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-03 12:39:12 +08:00
fix(测试跟踪): 功能用例库跨项目查看信息为空
--bug=1023394 --user=陈建星 【测试跟踪】功能用例-公共用例库-操作-查看用例详情-点击编辑-模块未显示 https://www.tapd.cn/55049933/s/1338445
This commit is contained in:
parent
ad1f32013e
commit
05a05d4bd2
@ -1194,7 +1194,7 @@
|
||||
<if test="request.refId != null">
|
||||
and ${versionTable}.ref_id = #{request.refId}
|
||||
</if>
|
||||
<if test="request.versionId == null and request.refId == null">
|
||||
<if test="request.versionId == null and request.refId == null and request.casePublic != true">
|
||||
AND ${versionTable}.latest = 1
|
||||
</if>
|
||||
</sql>
|
||||
|
@ -415,6 +415,7 @@ public class TestCaseService {
|
||||
customFieldTestCaseService.editFields(testCase.getId(), testCase.getEditFields());
|
||||
customFieldTestCaseService.addFields(testCase.getId(), testCase.getAddFields());
|
||||
|
||||
// latest 字段 createNewVersionOrNot 已经设置过了,不更新
|
||||
testCase.setLatest(null);
|
||||
|
||||
testCaseMapper.updateByPrimaryKeySelective(testCase);
|
||||
@ -476,10 +477,15 @@ public class TestCaseService {
|
||||
if (StringUtils.isBlank(testCase.getVersionId())) {
|
||||
return;
|
||||
}
|
||||
testCase.setLatest(false);
|
||||
TestCaseExample example = new TestCaseExample();
|
||||
example.createCriteria().andIdEqualTo(testCase.getId())
|
||||
.andVersionIdEqualTo(testCase.getVersionId());
|
||||
|
||||
String defaultVersion = baseProjectVersionMapper.getDefaultVersion(testCase.getProjectId());
|
||||
if (StringUtils.equalsIgnoreCase(testCase.getVersionId(), defaultVersion)) {
|
||||
testCase.setLatest(false);
|
||||
}
|
||||
|
||||
if (testCaseMapper.updateByExampleSelective(testCase, example) == 0) {
|
||||
// 插入新版本的数据
|
||||
TestCaseWithBLOBs oldTestCase = testCaseMapper.selectByPrimaryKey(testCase.getId());
|
||||
@ -494,7 +500,7 @@ public class TestCaseService {
|
||||
dealWithOtherInfoOfNewVersion(testCase, oldTestCase.getId());
|
||||
testCaseMapper.insertSelective(testCase);
|
||||
}
|
||||
String defaultVersion = baseProjectVersionMapper.getDefaultVersion(testCase.getProjectId());
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(testCase.getVersionId(), defaultVersion)) {
|
||||
checkAndSetLatestVersion(testCase.getRefId());
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import {getCurrentProjectID, getCurrentWorkspaceId} from "metersphere-frontend/s
|
||||
|
||||
const BASE_URL = "/project_application/";
|
||||
|
||||
export function getProjectApplicationConfig(type) {
|
||||
let projectId = getCurrentProjectID();
|
||||
export function getProjectApplicationConfig(type, projectId) {
|
||||
projectId = projectId ? projectId : getCurrentProjectID();
|
||||
return get(BASE_URL + `get/${projectId}/${type}`);
|
||||
}
|
||||
|
@ -562,7 +562,8 @@ export default {
|
||||
// 1 表示是直接保存
|
||||
// 2 表示式保存并创建
|
||||
// 3 表示
|
||||
saveType: 1
|
||||
saveType: 1,
|
||||
projectId: null
|
||||
};
|
||||
},
|
||||
props: {
|
||||
@ -578,10 +579,10 @@ export default {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
publicCaseId: String
|
||||
publicCaseId: String,
|
||||
},
|
||||
computed: {
|
||||
projectId() {
|
||||
routeProjectId() {
|
||||
let pId = this.$route.params.projectId;
|
||||
return pId ? pId : getCurrentProjectID();
|
||||
},
|
||||
@ -682,9 +683,9 @@ export default {
|
||||
if (this.form.id) {
|
||||
store.testCaseMap.set(this.form.id, 0);
|
||||
}
|
||||
|
||||
},
|
||||
activated() {
|
||||
// 用例跳转编辑走这里
|
||||
this.loadTestCase();
|
||||
},
|
||||
created(){
|
||||
@ -727,19 +728,21 @@ export default {
|
||||
setIsLastedVersion(isLastedVersion) {
|
||||
this.isLastedVersion = isLastedVersion;
|
||||
},
|
||||
loadTestCase() {
|
||||
// 校验路径中的项目ID
|
||||
this.checkCurrentProject();
|
||||
async loadTestCase() {
|
||||
|
||||
let initFuc = this.initEdit;
|
||||
this.loading = true;
|
||||
getTestTemplate().then((template) => {
|
||||
|
||||
// 校验路径中的项目ID
|
||||
await this.checkCurrentProject();
|
||||
|
||||
getTestTemplate(this.projectId).then((template) => {
|
||||
this.testCaseTemplate = template;
|
||||
store.testCaseTemplate = this.testCaseTemplate;
|
||||
initFuc();
|
||||
});
|
||||
|
||||
getProjectApplicationConfig('CASE_CUSTOM_NUM')
|
||||
getProjectApplicationConfig('CASE_CUSTOM_NUM', this.projectId)
|
||||
.then(result => {
|
||||
let data = result.data;
|
||||
if (data && data.typeValue === 'true') {
|
||||
@ -776,7 +779,8 @@ export default {
|
||||
}
|
||||
}
|
||||
});
|
||||
getProjectApplicationConfig("CASE_PUBLIC").then((res) => {
|
||||
|
||||
getProjectApplicationConfig("CASE_PUBLIC", this.projectId).then((res) => {
|
||||
let data = res.data;
|
||||
if (data && data.typeValue === "true") {
|
||||
this.isPublic = true;
|
||||
@ -784,6 +788,7 @@ export default {
|
||||
this.isPublic = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (hasLicense()) {
|
||||
this.isXpack = true;
|
||||
} else {
|
||||
@ -965,23 +970,32 @@ export default {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
checkCurrentProject() {
|
||||
if (this.projectId) {
|
||||
// 创建时会带 projectId,校验是否是当前项目
|
||||
if (getCurrentProjectID() !== this.projectId) {
|
||||
setCurrentProjectID(this.projectId);
|
||||
location.reload();
|
||||
}
|
||||
async checkCurrentProject() {
|
||||
if (this.isPublicShow) {
|
||||
// 如果是用例库查看用例
|
||||
await getSimpleTestCase(this.caseId).then((response) => {
|
||||
let testCase = response.data;
|
||||
this.projectId = testCase.projectId;
|
||||
});
|
||||
} else {
|
||||
if (this.caseId) {
|
||||
getSimpleTestCase(this.caseId).then((response) => {
|
||||
let testCase = response.data;
|
||||
if (getCurrentProjectID() !== testCase.projectId) {
|
||||
// 如果不是当前项目,先切项目
|
||||
setCurrentProjectID(testCase.projectId);
|
||||
location.reload();
|
||||
}
|
||||
})
|
||||
this.projectId = this.routeProjectId;
|
||||
if (this.routeProjectId) {
|
||||
// 创建时会带 projectId,校验是否是当前项目
|
||||
if (getCurrentProjectID() !== this.projectId) {
|
||||
setCurrentProjectID(this.projectId);
|
||||
location.reload();
|
||||
}
|
||||
} else {
|
||||
if (this.caseId) {
|
||||
await getSimpleTestCase(this.caseId).then((response) => {
|
||||
let testCase = response.data;
|
||||
if (getCurrentProjectID() !== testCase.projectId) {
|
||||
// 如果不是当前项目,先切项目
|
||||
setCurrentProjectID(testCase.projectId);
|
||||
location.reload();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -1500,7 +1514,7 @@ export default {
|
||||
},
|
||||
setLatest(version) {
|
||||
let param = {
|
||||
projectId: getCurrentProjectID(),
|
||||
projectId: this.projectId,
|
||||
type: "TEST_CASE",
|
||||
versionId: version.id,
|
||||
resourceId: this.caseId,
|
||||
|
@ -8,8 +8,14 @@
|
||||
class="case-desc-drawer-layout"
|
||||
>
|
||||
<div style="height: 100%; overflow: auto">
|
||||
<test-case-edit :is-public-show="true" :public-case-id.sync="publicCaseId" @close="close" @previousCase="previous" @nextCase="next"
|
||||
:is-first-public.sync="isFirstPublic" :is-last-public.sync="isLastPublic"/>
|
||||
<test-case-edit :is-public-show="true"
|
||||
:public-case-id.sync="publicCaseId"
|
||||
:is-first-public.sync="isFirstPublic"
|
||||
:is-last-public.sync="isLastPublic"
|
||||
@close="close"
|
||||
@previousCase="previous"
|
||||
@nextCase="next"
|
||||
ref="testCaseEdit"/>
|
||||
</div>
|
||||
</el-drawer>
|
||||
</template>
|
||||
@ -62,6 +68,10 @@ export default {
|
||||
open(caseId) {
|
||||
this.visible = true;
|
||||
this.publicCaseId = caseId;
|
||||
// 公共用例库走这里
|
||||
this.$nextTick(() => {
|
||||
this.$refs.testCaseEdit.loadTestCase();
|
||||
});
|
||||
},
|
||||
close() {
|
||||
this.visible = false;
|
||||
|
Loading…
Reference in New Issue
Block a user