fix: 用例默认值对脑图不生效

--bug=1010305 --user=陈建星 【测试用例】 #10607自定义字段用例字段默认改为P2,脑图编辑的用例保存不生效[BUG] https://www.tapd.cn/55049933/s/1105527
This commit is contained in:
chenjianxing 2022-02-18 11:58:28 +08:00 committed by fit2-zhao
parent 1c4760c373
commit 6d2d338e74
6 changed files with 35 additions and 21 deletions

View File

@ -184,23 +184,11 @@ public class TestCaseTemplateService extends TemplateBaseService {
} }
public Map<String,List<String>> getCaseLevelAndStatusMapByProjectId(String projectId){ public Map<String,List<String>> getCaseLevelAndStatusMapByProjectId(String projectId){
Project project = projectService.getProjectById(projectId); TestCaseTemplateDao template = getTemplate(projectId);
String caseTemplateId = project.getCaseTemplateId(); List<CustomFieldDao> result = template.getCustomFields();
TestCaseTemplateWithBLOBs caseTemplate = null;
TestCaseTemplateDao caseTemplateDao = new TestCaseTemplateDao();
if (StringUtils.isNotBlank(caseTemplateId)) {
caseTemplate = testCaseTemplateMapper.selectByPrimaryKey(caseTemplateId);
if (caseTemplate == null) {
caseTemplate = getDefaultTemplate(project.getWorkspaceId());
}
} else {
caseTemplate = getDefaultTemplate(project.getWorkspaceId());
}
BeanUtils.copyBean(caseTemplateDao, caseTemplate);
List<CustomFieldDao> result = customFieldService.getCustomFieldByTemplateId(caseTemplate.getId());
Map<String, List<String>> returnMap = new HashMap<>(); Map<String, List<String>> returnMap = new HashMap<>();
for (CustomFieldDao field:result) { for (CustomFieldDao field : result) {
if(StringUtils.equalsAnyIgnoreCase(field.getScene(),"TEST_CASE")){ if(StringUtils.equalsAnyIgnoreCase(field.getScene(),"TEST_CASE")){
if(StringUtils.equalsAnyIgnoreCase(field.getName(),"用例等级")){ if(StringUtils.equalsAnyIgnoreCase(field.getName(),"用例等级")){
try { try {
@ -231,7 +219,7 @@ public class TestCaseTemplateService extends TemplateBaseService {
public TestCaseTemplateDao getTemplate(String projectId) { public TestCaseTemplateDao getTemplate(String projectId) {
Project project = projectService.getProjectById(projectId); Project project = projectService.getProjectById(projectId);
String caseTemplateId = project.getCaseTemplateId(); String caseTemplateId = project.getCaseTemplateId();
TestCaseTemplateWithBLOBs caseTemplate = null; TestCaseTemplateWithBLOBs caseTemplate;
TestCaseTemplateDao caseTemplateDao = new TestCaseTemplateDao(); TestCaseTemplateDao caseTemplateDao = new TestCaseTemplateDao();
if (StringUtils.isNotBlank(caseTemplateId)) { if (StringUtils.isNotBlank(caseTemplateId)) {
caseTemplate = testCaseTemplateMapper.selectByPrimaryKey(caseTemplateId); caseTemplate = testCaseTemplateMapper.selectByPrimaryKey(caseTemplateId);

View File

@ -1851,7 +1851,9 @@ public class TestCaseService {
editTestCase(editRequest); editTestCase(editRequest);
changeOrder(item, request.getProjectId()); changeOrder(item, request.getProjectId());
} else { } else {
item.setMaintainer(SessionUtils.getUserId()); if (StringUtils.isBlank(item.getMaintainer())) {
item.setMaintainer(SessionUtils.getUserId());
}
EditTestCaseRequest editTestCaseRequest = new EditTestCaseRequest(); EditTestCaseRequest editTestCaseRequest = new EditTestCaseRequest();
BeanUtils.copyBean(editTestCaseRequest, item); BeanUtils.copyBean(editTestCaseRequest, item);
addTestCase(editTestCaseRequest); addTestCase(editTestCaseRequest);

View File

@ -621,6 +621,7 @@ export default {
this.page.result.loading = true; this.page.result.loading = true;
this.testCaseTemplate = template; this.testCaseTemplate = template;
this.fields = getTableHeaderWithCustomFields('TRACK_TEST_CASE', this.testCaseTemplate.customFields); this.fields = getTableHeaderWithCustomFields('TRACK_TEST_CASE', this.testCaseTemplate.customFields);
this.setTestCaseDefaultValue(template);
this.page.result.loading = false; this.page.result.loading = false;
if (this.$refs.table) { if (this.$refs.table) {
this.$refs.table.reloadTable(); this.$refs.table.reloadTable();
@ -629,6 +630,19 @@ export default {
getCustomFieldBatchEditOption(template.customFields, this.typeArr, this.valueArr, this.members); getCustomFieldBatchEditOption(template.customFields, this.typeArr, this.valueArr, this.members);
}); });
}, },
setTestCaseDefaultValue(template) {
let testCaseDefaultValue = {};
template.customFields.forEach(item => {
if (item.system) {
if (item.defaultValue) {
testCaseDefaultValue[item.name] = JSON.parse(item.defaultValue);
} else {
testCaseDefaultValue[item.name] = "";
}
}
});
this.$store.commit('setTestCaseDefaultValue', testCaseDefaultValue);
},
getCustomFieldValue(row, field) { getCustomFieldValue(row, field) {
let value = getCustomFieldValue(row, field, this.members); let value = getCustomFieldValue(row, field, this.members);
if (!value) { if (!value) {

View File

@ -98,6 +98,9 @@ name: "TestCaseMinder",
moduleOptions() { moduleOptions() {
return this.$store.state.testCaseModuleOptions; return this.$store.state.testCaseModuleOptions;
}, },
testCaseDefaultValue() {
return this.$store.state.testCaseDefaultValue;
},
disabled() { disabled() {
return !hasPermission('PROJECT_TRACK_CASE:READ+EDIT'); return !hasPermission('PROJECT_TRACK_CASE:READ+EDIT');
}, },
@ -129,7 +132,7 @@ name: "TestCaseMinder",
methods: { methods: {
handleAfterMount() { handleAfterMount() {
listenNodeSelected(() => { listenNodeSelected(() => {
// //
loadSelectNodes(this.getParam(), getTestCasesForMinder, null, getMinderExtraNode); loadSelectNodes(this.getParam(), getTestCasesForMinder, null, getMinderExtraNode);
}); });
@ -338,6 +341,10 @@ name: "TestCaseMinder",
let isChange = false; let isChange = false;
let nodeId = parent ? (parent.newId ? parent.newId : parent.id) : ""; let nodeId = parent ? (parent.newId ? parent.newId : parent.id) : "";
let priorityDefaultValue = (data.priority ? 'P' + data.priority - 1 :
(this.testCaseDefaultValue['用例等级'] ? this.testCaseDefaultValue['用例等级'] : 'P' + 0)
);
let testCase = { let testCase = {
id: data.id, id: data.id,
name: data.text, name: data.text,
@ -345,12 +352,13 @@ name: "TestCaseMinder",
nodePath: getNodePath(nodeId, this.moduleOptions), nodePath: getNodePath(nodeId, this.moduleOptions),
type: data.type ? data.type : 'functional', type: data.type ? data.type : 'functional',
method: data.method ? data.method: 'manual', method: data.method ? data.method: 'manual',
maintainer: data.maintainer, maintainer: this.testCaseDefaultValue['责任人'] ? this.testCaseDefaultValue['责任人'] : data.maintainer,
priority: 'P' + (data.priority ? data.priority - 1 : 0), priority: priorityDefaultValue,
prerequisite: "", prerequisite: "",
remark: "", remark: "",
stepDescription: "", stepDescription: "",
expectedResult: "", expectedResult: "",
status: this.testCaseDefaultValue['用例状态'],
steps: "[]" steps: "[]"
}; };
if (data.changed) isChange = true; if (data.changed) isChange = true;

View File

@ -33,7 +33,8 @@ const state = {
apiMap: new Map(), apiMap: new Map(),
apiStatus: new Map(), apiStatus: new Map(),
testCaseMap: new Map(), testCaseMap: new Map(),
curTabId: null curTabId: null,
testCaseDefaultValue: {}
} }
const store = new Vuex.Store({ const store = new Vuex.Store({

View File

@ -18,6 +18,7 @@ const mutations = {
setCurrentProjectIsCustomNum: (state, value) => state.currentProjectIsCustomNum = value, setCurrentProjectIsCustomNum: (state, value) => state.currentProjectIsCustomNum = value,
setTestCaseTemplate: (state, value) => state.testCaseTemplate = value, setTestCaseTemplate: (state, value) => state.testCaseTemplate = value,
setCurTabId: (state, value) => state.curTabId = value, setCurTabId: (state, value) => state.curTabId = value,
setTestCaseDefaultValue: (state, value) => state.testCaseDefaultValue = value,
} }
export default mutations; export default mutations;