fix(测试跟踪): 功能用例导出字段过长,其他字段也显示为空

--bug=1026585 --user=陈建星 【测试跟踪】github#24655,功能字段自定义字段过长时,导出功能用例为Excel,导出成功,但自定义字段均为空 https://www.tapd.cn/55049933/s/1379430
This commit is contained in:
chenjianxing 2023-06-07 09:44:55 +08:00 committed by fit2-zhao
parent a8b46ce905
commit 8bd8200ffe
4 changed files with 13 additions and 13 deletions

View File

@ -1835,7 +1835,7 @@ public class TestCaseService {
buildExportCustomField(customSelectValueMap, customNameMap, t, data, textFields); buildExportCustomField(customSelectValueMap, customNameMap, t, data, textFields);
buildExportOtherField(data, t, otherHeaders); buildExportOtherField(data, t, otherHeaders);
this.validateExportTextField(t); this.validateExportTextField(data);
if (CollectionUtils.isNotEmpty(stepDescList)) { if (CollectionUtils.isNotEmpty(stepDescList)) {
// 如果有多条步骤则添加多条数据之后合并单元格 // 如果有多条步骤则添加多条数据之后合并单元格
buildExportMergeData(rowMergeInfo, list, stepDescList, stepResultList, data); buildExportMergeData(rowMergeInfo, list, stepDescList, stepResultList, data);
@ -1846,19 +1846,20 @@ public class TestCaseService {
return list; return list;
} }
private void validateExportTextField(TestCaseDTO data) { private void validateExportTextField(TestCaseExcelData data) {
List<String> textValues= Arrays.asList(data.getPrerequisite(), data.getStepDescription(), data.getExpectedResult(), data.getRemark()); data.setPrerequisite(validateExportText(data.getPrerequisite()));
for (String textValue : textValues) { data.setRemark(validateExportText(data.getRemark()));
validateExportText(data.getName(), textValue); data.setStepDesc(validateExportText(data.getStepDesc()));
} data.setStepResult(validateExportText(data.getStepResult()));
} }
private void validateExportText(String name, String textValue) { private String validateExportText(String textValue) {
// poi 导出的单个单元格最大字符数量为 32767 这里添加校验提示 // poi 导出的单个单元格最大字符数量为 32767 这里添加校验提示
int maxLength = 32767; int maxLength = 32767;
if (StringUtils.isNotBlank(textValue) && textValue.length() > maxLength) { if (StringUtils.isNotBlank(textValue) && textValue.length() > maxLength) {
MSException.throwException(String.format(Translator.get("case_export_text_validate_tip"), name, maxLength)); return String.format(Translator.get("case_export_text_validate_tip"), maxLength);
} }
return textValue;
} }
private void buildExportOtherField(TestCaseExcelData data, TestCaseDTO t, List<TestCaseExportRequest.TestCaseExportHeader> otherHeaders) { private void buildExportOtherField(TestCaseExcelData data, TestCaseDTO t, List<TestCaseExportRequest.TestCaseExportHeader> otherHeaders) {
@ -1926,8 +1927,7 @@ public class TestCaseService {
//进行key value对换 //进行key value对换
String id = field.getFieldId(); String id = field.getFieldId();
if (textFields.contains(id)) { if (textFields.contains(id)) {
map.put(customNameMap.get(id), field.getTextValue()); map.put(customNameMap.get(id), this.validateExportText(field.getTextValue()));
this.validateExportText(data.getName(), field.getTextValue());
continue; continue;
} }
if (StringUtils.isNotBlank(field.getValue())) { if (StringUtils.isNotBlank(field.getValue())) {

View File

@ -234,6 +234,6 @@ api_status_fake_error=FakeError
serial=Serial serial=Serial
parallel=Parallel parallel=Parallel
rerun_warning=The report is being rerun, check it later rerun_warning=The report is being rerun, check it later
case_export_text_validate_tip=Use case %s contains extremely long text, currently supported up to %s! case_export_text_validate_tip=Contains extremely long text, currently supported up to %s!
case_import_table_header_missing=Header information is missing! case_import_table_header_missing=Header information is missing!
relate_resource=relate relate_resource=relate

View File

@ -205,6 +205,6 @@ api_status_fake_error=误报
serial=串行 serial=串行
parallel=并行 parallel=并行
rerun_warning=报告正在重跑中,稍后查看 rerun_warning=报告正在重跑中,稍后查看
case_export_text_validate_tip=用例 %s 包含超长文本,目前支持最大长度为 %s case_export_text_validate_tip=包含超长文本,目前支持最大长度为 %s
case_import_table_header_not_exist=缺少表头信息! case_import_table_header_not_exist=缺少表头信息!
relate_resource=关联 relate_resource=关联

View File

@ -205,6 +205,6 @@ api_status_fake_error=誤報
serial=串行 serial=串行
parallel=並行 parallel=並行
rerun_warning=報告正在重跑中,稻後查看 rerun_warning=報告正在重跑中,稻後查看
case_export_text_validate_tip=用例 %s 包含超長文本,目前支持最大長度為 %s case_export_text_validate_tip=包含超長文本,目前支持最大長度為 %s
case_import_table_header_not_exist=缺少表頭信息! case_import_table_header_not_exist=缺少表頭信息!
relate_resource=關聯 relate_resource=關聯