fix(测试跟踪): 功能用例库跨项目查看信息为空

--bug=1023394 --user=陈建星 【测试跟踪】功能用例-公共用例库-操作-查看用例详情-点击编辑-模块未显示 https://www.tapd.cn/55049933/s/1338445
This commit is contained in:
chenjianxing 2023-02-20 17:35:59 +08:00 committed by jianxing
parent ad1f32013e
commit 05a05d4bd2
5 changed files with 64 additions and 34 deletions

View File

@ -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>

View File

@ -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());
}

View File

@ -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}`);
}

View File

@ -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,

View File

@ -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;