fix(测试跟踪): 公共用例库选择修改用例责任人后,新的责任人仍不可编辑和删除该用例

--bug=1008907 --user=王孝刚 【公共用例库】-选择修改用例责任人后,新的责任人仍不可编辑和删除该用例
https://www.tapd.cn/55049933/s/1086358
This commit is contained in:
wxg0103 2021-12-23 11:35:58 +08:00 committed by BugKing
parent 0d74d9aac9
commit f1128fc055
7 changed files with 107 additions and 51 deletions

View File

@ -107,6 +107,12 @@ public class TestCaseController {
return testCaseService.listTestCaseIds(request); return testCaseService.listTestCaseIds(request);
} }
@PostMapping("/list/ids/public")
public List<TestCaseDTO> getTestPlanCaseIdsPublic(@RequestBody QueryTestCaseRequest request) {
return testCaseService.publicListTestCase(request);
}
@GetMapping("/relationship/case/{id}/{relationshipType}") @GetMapping("/relationship/case/{id}/{relationshipType}")
public List<RelationshipEdgeDTO> getRelationshipCase(@PathVariable("id") String id, @PathVariable("relationshipType") String relationshipType) { public List<RelationshipEdgeDTO> getRelationshipCase(@PathVariable("id") String id, @PathVariable("relationshipType") String relationshipType) {
return testCaseService.getRelationshipCase(id, relationshipType); return testCaseService.getRelationshipCase(id, relationshipType);
@ -184,7 +190,6 @@ public class TestCaseController {
@GetMapping("/get/{testCaseId}") @GetMapping("/get/{testCaseId}")
public TestCaseWithBLOBs getTestCase(@PathVariable String testCaseId) { public TestCaseWithBLOBs getTestCase(@PathVariable String testCaseId) {
checkPermissionService.checkTestCaseOwner(testCaseId);
return testCaseService.getTestCase(testCaseId); return testCaseService.getTestCase(testCaseId);
} }

View File

@ -1337,6 +1337,7 @@ public class TestCaseService {
BeanUtils.copyBean(batchCopy, item); BeanUtils.copyBean(batchCopy, item);
checkTestCaseExist(batchCopy); checkTestCaseExist(batchCopy);
batchCopy.setId(UUID.randomUUID().toString()); batchCopy.setId(UUID.randomUUID().toString());
batchCopy.setName("copy_" + item.getName());
batchCopy.setCreateTime(System.currentTimeMillis()); batchCopy.setCreateTime(System.currentTimeMillis());
batchCopy.setUpdateTime(System.currentTimeMillis()); batchCopy.setUpdateTime(System.currentTimeMillis());
batchCopy.setNum(getNextNum(SessionUtils.getCurrentProjectId())); batchCopy.setNum(getNextNum(SessionUtils.getCurrentProjectId()));

View File

@ -2,7 +2,9 @@
<div id="app" v-loading="loading"> <div id="app" v-loading="loading">
<el-tabs v-model="activeName" @tab-click="handleClick"> <el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane :label="$t('organization.message.template')" name="apiTemplate"> <el-tab-pane :label="$t('organization.message.template')" name="apiTemplate">
<el-button type="primary" size="mini" style="margin: 10px 10px 0px" @click="openOneClickOperation">导入</el-button> <el-button type="primary" size="mini" style="margin: 10px 10px 0px" @click="openOneClickOperation">
{{ this.$t('commons.import') }}
</el-button>
<div style="min-height: 200px"> <div style="min-height: 200px">
<json-schema-editor class="schema" :value="schema" lang="zh_CN" custom/> <json-schema-editor class="schema" :value="schema" lang="zh_CN" custom/>
</div> </div>

View File

@ -75,6 +75,7 @@
:isRedirectEdit="isRedirectEdit" :isRedirectEdit="isRedirectEdit"
:tree-nodes="treeNodes" :tree-nodes="treeNodes"
:trash-enable="false" :trash-enable="false"
:public-enable="false"
@refreshTable="refresh" @refreshTable="refresh"
@testCaseEdit="editTestCase" @testCaseEdit="editTestCase"
@testCaseCopy="copyTestCase" @testCaseCopy="copyTestCase"
@ -112,6 +113,7 @@
:tree-nodes="treeNodes" :tree-nodes="treeNodes"
:select-node="selectNode" :select-node="selectNode"
:select-condition="condition" :select-condition="condition"
:public-enable="currentActiveName === 'default' ? false : true"
:type="type" :type="type"
@addTab="addTab" @addTab="addTab"
ref="testCaseEdit"> ref="testCaseEdit">
@ -128,7 +130,7 @@
:select-node="selectNode" :select-node="selectNode"
:select-condition="condition" :select-condition="condition"
:type="type" :type="type"
:is-public="publicEnable" :public-enable="currentActiveName === 'default' ? false : true"
@addTab="addTabShow" @addTab="addTabShow"
ref="testCaseEditShow"> ref="testCaseEditShow">
</test-case-edit-show> </test-case-edit-show>
@ -202,6 +204,7 @@ export default {
showPublic: false, showPublic: false,
condition: {}, condition: {},
activeName: 'default', activeName: 'default',
currentActiveName: '',
tabs: [], tabs: [],
renderComponent: true, renderComponent: true,
loading: false, loading: false,
@ -344,12 +347,18 @@ export default {
let label = this.$t('test_track.case.create'); let label = this.$t('test_track.case.create');
let name = getUUID().substring(0, 8); let name = getUUID().substring(0, 8);
this.activeName = name; this.activeName = name;
this.currentActiveName = 'default'
this.type = 'add'; this.type = 'add';
this.tabs.push({label: label, name: name, testCaseInfo: {testCaseModuleId: "", id: getUUID()}}); this.tabs.push({label: label, name: name, testCaseInfo: {testCaseModuleId: "", id: getUUID()}});
} }
if (tab.name === 'edit') { if (tab.name === 'edit') {
let label = this.$t('test_track.case.create'); let label = this.$t('test_track.case.create');
let name = getUUID().substring(0, 8); let name = getUUID().substring(0, 8);
if (this.activeName === 'public') {
this.currentActiveName = 'public'
} else {
this.currentActiveName = 'default'
}
this.activeName = name; this.activeName = name;
label = tab.testCaseInfo.name; label = tab.testCaseInfo.name;
this.tabs.push({label: label, name: name, testCaseInfo: tab.testCaseInfo}); this.tabs.push({label: label, name: name, testCaseInfo: tab.testCaseInfo});
@ -367,6 +376,7 @@ export default {
let label = this.$t('test_track.case.create'); let label = this.$t('test_track.case.create');
let name = getUUID().substring(0, 8); let name = getUUID().substring(0, 8);
this.activeName = name; this.activeName = name;
this.currentActiveName = 'public'
label = tab.testCaseInfo.name; label = tab.testCaseInfo.name;
this.tabs.push({label: label, name: name, testCaseInfo: tab.testCaseInfo}); this.tabs.push({label: label, name: name, testCaseInfo: tab.testCaseInfo});
} }

View File

@ -18,23 +18,15 @@
<el-link type="primary" style="margin-right: 20px" @click="openHis" v-if="form.id"> <el-link type="primary" style="margin-right: 20px" @click="openHis" v-if="form.id">
{{ $t('operating_log.change_history') }} {{ $t('operating_log.change_history') }}
</el-link> </el-link>
<ms-table-button v-if="this.path!=='/test/case/add'" <el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand"
id="inputDelay"
type="primary"
:content="$t('commons.save')"
size="small" @click="saveCase"
icon=""
:disabled="readOnly"
title="ctrl + s"/>
<el-dropdown v-else split-button type="primary" class="ms-api-buttion" @click="handleCommand"
@command="handleCommand" size="small" style="float: right;margin-right: 20px"> @command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{ $t('commons.save') }} {{ $t('commons.save') }}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="ADD_AND_CREATE">{{ <el-dropdown-item command="ADD_AND_CREATE" v-if="this.path =='/test/case/add'">{{
$t('test_track.case.save_create_continue') $t('test_track.case.save_create_continue')
}} }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="ADD_AND_PUBLIC" v-if="this.publicEnable && this.isXpack">{{ <el-dropdown-item command="ADD_AND_PUBLIC" v-if="this.isPublic && this.isXpack">{{
$t('test_track.case.save_add_public') $t('test_track.case.save_add_public')
}} }}
</el-dropdown-item> </el-dropdown-item>
@ -55,12 +47,22 @@
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item :label="$t('test_track.case.module')" :label-width="formLabelWidth" prop="module"> <el-form-item :label="$t('test_track.case.module')" :label-width="formLabelWidth" prop="module"
v-if="!publicEnable">
<ms-select-tree :disabled="readOnly" :data="treeNodes" :defaultKey="form.module" :obj="moduleObj" <ms-select-tree :disabled="readOnly" :data="treeNodes" :defaultKey="form.module" :obj="moduleObj"
@getValue="setModule" clearable checkStrictly size="small"/> @getValue="setModule" clearable checkStrictly size="small"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8">
<el-form-item :label="$t('test_track.case.project')" :label-width="formLabelWidth" prop="projectId"
v-if="publicEnable">
<el-select v-model="form.projectId" filterable clearable>
<el-option v-for="item in projectList" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item :label="$t('commons.tag')" :label-width="formLabelWidth" prop="tag"> <el-form-item :label="$t('commons.tag')" :label-width="formLabelWidth" prop="tag">
<ms-input-tag :read-only="readOnly" :currentScenario="form" v-if="showInputTag" ref="tag" <ms-input-tag :read-only="readOnly" :currentScenario="form" v-if="showInputTag" ref="tag"
@ -198,9 +200,10 @@ export default {
return { return {
// sysList: [],// // sysList: [],//
path: "/test/case/add", path: "/test/case/add",
publicEnable: false, isPublic: false,
isXpack: false, isXpack: false,
testCaseTemplate: {}, testCaseTemplate: {},
projectList: [],
options: REVIEW_STATUS, options: REVIEW_STATUS,
statuOptions: API_STATUS, statuOptions: API_STATUS,
comments: [], comments: [],
@ -294,6 +297,11 @@ export default {
type: Object type: Object
}, },
type: String, type: String,
publicEnable: {
type: Boolean,
default: false,
},
activeName: String
}, },
computed: { computed: {
projectIds() { projectIds() {
@ -367,6 +375,11 @@ export default {
this.$store.state.testCaseMap.set(this.form.id, 0); this.$store.state.testCaseMap.set(this.form.id, 0);
}, },
created() { created() {
if (!this.projectList || this.projectList.length === 0) { //
this.$get("/project/listAll", (response) => {
this.projectList = response.data; //,
})
}
this.projectId = this.projectIds; this.projectId = this.projectIds;
let initAddFuc = this.initAddFuc; let initAddFuc = this.initAddFuc;
getTestTemplate() getTestTemplate()
@ -401,7 +414,7 @@ export default {
this.result = this.$get('/project/get/' + this.projectId, res => { this.result = this.$get('/project/get/' + this.projectId, res => {
let data = res.data; let data = res.data;
if (data.casePublic) { if (data.casePublic) {
this.publicEnable = true; this.isPublic = true;
} }
}) })
if (hasLicense()) { if (hasLicense()) {
@ -583,16 +596,28 @@ export default {
this.getTestCase(this.index); this.getTestCase(this.index);
}, },
initTestCases(testCase) { initTestCases(testCase) {
this.selectCondition.workspaceId = null; if (this.publicEnable) {
this.result = this.$post('/test/case/list/ids', this.selectCondition, response => { this.result = this.$post('/test/case/list/ids/public', this.selectCondition, response => {
this.testCases = response.data; this.testCases = response.data;
for (let i = 0; i < this.testCases.length; i++) { for (let i = 0; i < this.testCases.length; i++) {
if (this.testCases[i].id === testCase.id) { if (this.testCases[i].id === testCase.id) {
this.index = i; this.index = i;
this.getTestCase(i); this.getTestCase(i);
}
} }
} });
}); } else {
this.selectCondition.workspaceId = null;
this.result = this.$post('/test/case/list/ids', this.selectCondition, response => {
this.testCases = response.data;
for (let i = 0; i < this.testCases.length; i++) {
if (this.testCases[i].id === testCase.id) {
this.index = i;
this.getTestCase(i);
}
}
});
}
}, },
getTestCase(index) { getTestCase(index) {
let id = ""; let id = "";

View File

@ -59,7 +59,7 @@
<el-form v-if="isFormAlive" :model="customFieldForm" :rules="customFieldRules" ref="customFieldForm" <el-form v-if="isFormAlive" :model="customFieldForm" :rules="customFieldRules" ref="customFieldForm"
class="case-form"> class="case-form">
<custom-filed-form-item :form="customFieldForm" :form-label-width="formLabelWidth" <custom-filed-form-item :form="customFieldForm" :form-label-width="formLabelWidth"
:issue-template="testCaseTemplate" :is-public="isPublic"/> :issue-template="testCaseTemplate" :is-public="publicEnable"/>
</el-form> </el-form>
<el-row v-if="isCustomNum"> <el-row v-if="isCustomNum">
@ -121,7 +121,7 @@
<ms-change-history ref="changeHistory"/> <ms-change-history ref="changeHistory"/>
</div> </div>
<batch-move ref="testBatchMove" :public-enable="isPublic" <batch-move ref="testBatchMove" :public-enable="publicEnable"
@copyPublic="copyPublic"/> @copyPublic="copyPublic"/>
</el-card> </el-card>
@ -191,7 +191,7 @@ export default {
path: "/test/case/add", path: "/test/case/add",
selectIds: [], selectIds: [],
projectList: [], projectList: [],
publicEnable: false, isPublic: false,
isXpack: false, isXpack: false,
testCaseTemplate: {}, testCaseTemplate: {},
options: REVIEW_STATUS, options: REVIEW_STATUS,
@ -287,8 +287,9 @@ export default {
type: Object type: Object
}, },
type: String, type: String,
isPublic: { publicEnable: {
type: Boolean type: Boolean,
default: false
} }
}, },
computed: { computed: {
@ -381,7 +382,7 @@ export default {
this.result = this.$get('/project/get/' + this.projectId, res => { this.result = this.$get('/project/get/' + this.projectId, res => {
let data = res.data; let data = res.data;
if (data.casePublic) { if (data.casePublic) {
this.publicEnable = true; this.isPublic = true;
} }
}) })
if (hasLicense()) { if (hasLicense()) {
@ -562,16 +563,28 @@ export default {
this.getTestCase(this.index); this.getTestCase(this.index);
}, },
initTestCases(testCase) { initTestCases(testCase) {
this.selectCondition.workspaceId = null; if (this.publicEnable) {
this.result = this.$post('/test/case/list/ids', this.selectCondition, response => { this.result = this.$post('/test/case/list/ids/public', this.selectCondition, response => {
this.testCases = response.data; this.testCases = response.data;
for (let i = 0; i < this.testCases.length; i++) { for (let i = 0; i < this.testCases.length; i++) {
if (this.testCases[i].id === testCase.id) { if (this.testCases[i].id === testCase.id) {
this.index = i; this.index = i;
this.getTestCase(i); this.getTestCase(i);
}
} }
} });
}); } else {
this.selectCondition.workspaceId = null;
this.result = this.$post('/test/case/list/ids', this.selectCondition, response => {
this.testCases = response.data;
for (let i = 0; i < this.testCases.length; i++) {
if (this.testCases[i].id === testCase.id) {
this.index = i;
this.getTestCase(i);
}
}
});
}
}, },
getTestCase(index) { getTestCase(index) {
let id = ""; let id = "";

View File

@ -757,10 +757,14 @@ export default {
}, },
handleEdit(testCase, column) { handleEdit(testCase, column) {
if (column.label !== this.$t('test_track.case.case_desc')) { if (column.label !== this.$t('test_track.case.case_desc')) {
this.$get('test/case/get/' + testCase.id, response => { if (this.publicEnable) {
let testCase = response.data; return;
this.$emit('testCaseEdit', testCase); } else {
}); this.$get('test/case/get/' + testCase.id, response => {
let testCase = response.data;
this.$emit('testCaseEdit', testCase);
});
}
} }
}, },
@ -774,14 +778,10 @@ export default {
}, },
isPublic(testCase) { isPublic(testCase) {
if (testCase.maintainer && testCase.maintainer !== getCurrentUserId()) { if ((testCase.maintainer && testCase.maintainer === getCurrentUserId()) || (testCase.createUser && testCase.createUser === getCurrentUserId())) {
return true;
}
if (testCase.createUser && testCase.createUser !== getCurrentUserId()) {
return true;
} else {
return false; return false;
} }
return true;
}, },
getCase(id) { getCase(id) {
this.$refs.testCasePreview.open(); this.$refs.testCasePreview.open();