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){
Project project = projectService.getProjectById(projectId);
String caseTemplateId = project.getCaseTemplateId();
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());
TestCaseTemplateDao template = getTemplate(projectId);
List<CustomFieldDao> result = template.getCustomFields();
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.getName(),"用例等级")){
try {
@ -231,7 +219,7 @@ public class TestCaseTemplateService extends TemplateBaseService {
public TestCaseTemplateDao getTemplate(String projectId) {
Project project = projectService.getProjectById(projectId);
String caseTemplateId = project.getCaseTemplateId();
TestCaseTemplateWithBLOBs caseTemplate = null;
TestCaseTemplateWithBLOBs caseTemplate;
TestCaseTemplateDao caseTemplateDao = new TestCaseTemplateDao();
if (StringUtils.isNotBlank(caseTemplateId)) {
caseTemplate = testCaseTemplateMapper.selectByPrimaryKey(caseTemplateId);

View File

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

View File

@ -621,6 +621,7 @@ export default {
this.page.result.loading = true;
this.testCaseTemplate = template;
this.fields = getTableHeaderWithCustomFields('TRACK_TEST_CASE', this.testCaseTemplate.customFields);
this.setTestCaseDefaultValue(template);
this.page.result.loading = false;
if (this.$refs.table) {
this.$refs.table.reloadTable();
@ -629,6 +630,19 @@ export default {
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) {
let value = getCustomFieldValue(row, field, this.members);
if (!value) {

View File

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

View File

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

View File

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