fix(测试用例): 导出其他字段新增用例评论/执行评论/评审评论

--bug=1045181 --user=王旭 【测试用例】用例导出为excel-其它字段无用例评论/执行评论/评审评论字段 https://www.tapd.cn/55049933/s/1564047
This commit is contained in:
WangXu10 2024-08-16 14:32:28 +08:00 committed by Craftsman
parent 550a8fe96e
commit 149b233f9c
8 changed files with 29 additions and 3 deletions

View File

@ -287,6 +287,9 @@ case.export.system.other.columns.create_time=Create time
case.export.system.other.columns.update_user=Update user
case.export.system.other.columns.update_time=Update time
case.export.columns.case_edit_type=Edit type
case.export.system.other.columns.case_comment=Case comment
case.export.system.other.columns.execute_comment=Execute comment
case.export.system.other.columns.review_comment=Review comment
export_case_task_stop=Stop export
export_case_task_existed=Export task already exists

View File

@ -284,6 +284,9 @@ case.export.system.other.columns.create_time=创建时间
case.export.system.other.columns.update_user=更新人
case.export.system.other.columns.update_time=更新时间
case.export.columns.case_edit_type=编辑模式
case.export.system.other.columns.case_comment=用例评论
case.export.system.other.columns.execute_comment=执行评论
case.export.system.other.columns.review_comment=评审评论
export_case_task_stop=停止导出
export_case_task_existed=已有导出任务

View File

@ -288,6 +288,9 @@ case.export.system.other.columns.create_time=創建時間
case.export.system.other.columns.update_user=更新人
case.export.system.other.columns.update_time=更新時間
case.export.columns.case_edit_type=編輯模式
case.export.system.other.columns.case_comment=用例評論
case.export.system.other.columns.execute_comment=執行評論
case.export.system.other.columns.review_comment=評審評論
export_case_task_stop=停止導出
export_case_task_existed=已有導出任務

View File

@ -24,7 +24,7 @@ public class FunctionalCaseExportCaseCommentConverter implements FunctionalCaseE
List<FunctionalCaseComment> caseComments = caseCommentMap.get(functionalCase.getId());
caseComments.forEach(item -> {
String updateTime = DateUtils.getTimeString(item.getUpdateTime());
String content = item.getContent();
String content = parseHtml(item.getContent());
result.append(String.format(template, item.getCreateUser(), updateTime, content));
});
return result.toString();

View File

@ -9,6 +9,8 @@ import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 功能用例导出时解析其他字段对应的列
@ -33,4 +35,14 @@ public interface FunctionalCaseExportConverter {
}
return value;
}
default String parseHtml(String html) {
Pattern pattern = Pattern.compile("<p[^>]*>(.*?)</p>");
Matcher matcher = pattern.matcher(html);
if (matcher.find()) {
String content = matcher.group(1);
return content;
}
return StringUtils.EMPTY;
}
}

View File

@ -36,9 +36,10 @@ public class FunctionalCaseExportExecuteCommentConverter implements FunctionalCa
executeComment.forEach(item -> {
String status = getFromMapOfNullableWithTranslate(executeStatusMap, item.getStatus());
String createTime = DateUtils.getTimeString(item.getCreateTime());
String content = new String(item.getContent() == null ? new byte[0] : item.getContent(), StandardCharsets.UTF_8);
String content = parseHtml(new String(item.getContent() == null ? new byte[0] : item.getContent(), StandardCharsets.UTF_8));
result.append(String.format(template, item.getCreateUser(), status, createTime, content));
});
return result.toString();
}
return StringUtils.EMPTY;
}

View File

@ -35,9 +35,10 @@ public class FunctionalCaseExportReviewCommentConverter implements FunctionalCas
reviewComent.forEach(item -> {
String status = getFromMapOfNullableWithTranslate(reviewStatusMap, item.getStatus());
String createTime = DateUtils.getTimeString(item.getCreateTime());
String content = new String(item.getContent() == null ? new byte[0] : item.getContent(), StandardCharsets.UTF_8);
String content = parseHtml(new String(item.getContent() == null ? new byte[0] : item.getContent(), StandardCharsets.UTF_8));
result.append(String.format(template, item.getCreateUser(), status, createTime, content));
});
return result.toString();
}
return StringUtils.EMPTY;
}

View File

@ -34,6 +34,9 @@ public class FunctionalCaseExportColumns {
otherColumns.put("create_time", Translator.get("case.export.system.other.columns.create_time"));
otherColumns.put("update_user", Translator.get("case.export.system.other.columns.update_user"));
otherColumns.put("update_time", Translator.get("case.export.system.other.columns.update_time"));
otherColumns.put("case_comment", Translator.get("case.export.system.other.columns.case_comment"));
otherColumns.put("execute_comment", Translator.get("case.export.system.other.columns.execute_comment"));
otherColumns.put("review_comment", Translator.get("case.export.system.other.columns.review_comment"));
}