fix(测试跟踪): 功能用例导出文本类型的自定义字段为空
--bug=1016034 --user=陈建星 【测试跟踪】功能用例中包含自定义字段,导出后自定义字段内容是空的 https://www.tapd.cn/55049933/s/1230916
This commit is contained in:
parent
eb82a33e88
commit
a933b92500
|
@ -49,6 +49,8 @@ public class TestCaseExcelData {
|
||||||
private String priority;
|
private String priority;
|
||||||
@ExcelIgnore
|
@ExcelIgnore
|
||||||
Map<String, Object> customData = new LinkedHashMap<>();
|
Map<String, Object> customData = new LinkedHashMap<>();
|
||||||
|
@ExcelIgnore
|
||||||
|
Set<String> textFieldSet = new HashSet<>(2);
|
||||||
|
|
||||||
@ExcelIgnore
|
@ExcelIgnore
|
||||||
List<String> mergeStepDesc;
|
List<String> mergeStepDesc;
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||||
import io.metersphere.base.domain.TestCase;
|
import io.metersphere.base.domain.TestCase;
|
||||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||||
import io.metersphere.base.domain.ext.CustomFieldResource;
|
import io.metersphere.base.domain.ext.CustomFieldResource;
|
||||||
|
import io.metersphere.commons.constants.CustomFieldType;
|
||||||
import io.metersphere.commons.constants.TestCaseConstants;
|
import io.metersphere.commons.constants.TestCaseConstants;
|
||||||
import io.metersphere.commons.exception.CustomFieldValidateException;
|
import io.metersphere.commons.exception.CustomFieldValidateException;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
|
@ -410,6 +411,9 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
||||||
// 这里如果填的是选项值,替换成选项ID,保存
|
// 这里如果填的是选项值,替换成选项ID,保存
|
||||||
customData.put(fieldName, customFieldValidator.parse2Key(value.toString(), customField));
|
customData.put(fieldName, customFieldValidator.parse2Key(value.toString(), customField));
|
||||||
}
|
}
|
||||||
|
if (StringUtils.equalsAny(customField.getType(), CustomFieldType.TEXTAREA.getValue(), CustomFieldType.RICH_TEXT.getValue())) {
|
||||||
|
data.getTextFieldSet().add(fieldName);
|
||||||
|
}
|
||||||
} catch (CustomFieldValidateException e) {
|
} catch (CustomFieldValidateException e) {
|
||||||
stringBuilder.append(e.getMessage().concat(ERROR_MSG_SEPARATOR));
|
stringBuilder.append(e.getMessage().concat(ERROR_MSG_SEPARATOR));
|
||||||
}
|
}
|
||||||
|
@ -554,6 +558,7 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
||||||
*/
|
*/
|
||||||
private void buildTestCaseCustomFieldMap(TestCaseExcelData data, TestCaseWithBLOBs testCase) {
|
private void buildTestCaseCustomFieldMap(TestCaseExcelData data, TestCaseWithBLOBs testCase) {
|
||||||
Map<String, Object> customData = data.getCustomData();
|
Map<String, Object> customData = data.getCustomData();
|
||||||
|
Set<String> textFieldSet = data.getTextFieldSet();
|
||||||
List<CustomFieldResource> testCaseCustomFields = new ArrayList<>();
|
List<CustomFieldResource> testCaseCustomFields = new ArrayList<>();
|
||||||
customData.forEach((k, v) -> {
|
customData.forEach((k, v) -> {
|
||||||
if ((v instanceof List && CollectionUtils.isNotEmpty((List)v))
|
if ((v instanceof List && CollectionUtils.isNotEmpty((List)v))
|
||||||
|
@ -562,7 +567,11 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
||||||
if (customFieldDao != null) {
|
if (customFieldDao != null) {
|
||||||
CustomFieldResource customFieldResource = new CustomFieldResource();
|
CustomFieldResource customFieldResource = new CustomFieldResource();
|
||||||
customFieldResource.setFieldId(customFieldDao.getId());
|
customFieldResource.setFieldId(customFieldDao.getId());
|
||||||
|
if (textFieldSet.contains(customFieldDao.getId())) {
|
||||||
|
customFieldResource.setTextValue(v.toString());
|
||||||
|
} else {
|
||||||
customFieldResource.setValue(JSON.toJSONString(v));
|
customFieldResource.setValue(JSON.toJSONString(v));
|
||||||
|
}
|
||||||
customFieldResource.setResourceId(testCase.getId());
|
customFieldResource.setResourceId(testCase.getId());
|
||||||
testCaseCustomFields.add(customFieldResource);
|
testCaseCustomFields.add(customFieldResource);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ export function parseCustomField(data, template, rules, oldFields) {
|
||||||
let customField = data.fields[i];
|
let customField = data.fields[i];
|
||||||
if (customField.id === item.id) {
|
if (customField.id === item.id) {
|
||||||
try {
|
try {
|
||||||
if (customField.textValue) {
|
if (item.type === 'textarea' || item.type === 'richText') {
|
||||||
setDefaultValue(item, customField.textValue);
|
setDefaultValue(item, customField.textValue);
|
||||||
} else {
|
} else {
|
||||||
setDefaultValue(item, customField.value);
|
setDefaultValue(item, customField.value);
|
||||||
|
|
Loading…
Reference in New Issue