fix(测试跟踪): 用例中包含超长文本导出内容为空
--bug=1024670 --user=陈建星 【测试跟踪】功能用例-全选所有页-导出excel文件-文件为空 https://www.tapd.cn/55049933/s/1353684
This commit is contained in:
parent
e464791a14
commit
e67e60c5e9
|
@ -225,10 +225,17 @@ export function downloadFile(method, url, data, fileName, processHandler) {
|
||||||
fileName = fileName.replaceAll("\"", "");
|
fileName = fileName.replaceAll("\"", "");
|
||||||
_downloadFile(fileName, res.data);
|
_downloadFile(fileName, res.data);
|
||||||
resolve();
|
resolve();
|
||||||
})
|
}).catch((e) => {
|
||||||
.catch((e) => {
|
// 报错后,将 blob 格式转成字符串,打印错误信息
|
||||||
$error(e.message);
|
let reader = new FileReader();
|
||||||
reject(e);
|
reader.readAsText(e.response.data, 'utf-8');
|
||||||
|
reader.onload = function (e) {
|
||||||
|
if (reader.result) {
|
||||||
|
let info = JSON.parse(reader.result);
|
||||||
|
reject(info);
|
||||||
|
$error(info.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1724,6 +1724,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);
|
||||||
if (CollectionUtils.isNotEmpty(stepDescList)) {
|
if (CollectionUtils.isNotEmpty(stepDescList)) {
|
||||||
// 如果有多条步骤则添加多条数据,之后合并单元格
|
// 如果有多条步骤则添加多条数据,之后合并单元格
|
||||||
buildExportMergeData(rowMergeInfo, list, stepDescList, stepResultList, data);
|
buildExportMergeData(rowMergeInfo, list, stepDescList, stepResultList, data);
|
||||||
|
@ -1734,6 +1735,21 @@ public class TestCaseService {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validateExportTextField(TestCaseDTO data) {
|
||||||
|
List<String> textValues= Arrays.asList(data.getPrerequisite(), data.getStepDescription(), data.getExpectedResult(), data.getRemark());
|
||||||
|
for (String textValue : textValues) {
|
||||||
|
validateExportText(data.getName(), textValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateExportText(String name, String textValue) {
|
||||||
|
// poi 导出的单个单元格最大字符数量为 32767 ,这里添加校验提示
|
||||||
|
int maxLength = 32767;
|
||||||
|
if (textValue.length() > maxLength) {
|
||||||
|
MSException.throwException(String.format(Translator.get("case_export_text_validate_tip"), name, maxLength));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void buildExportOtherField(TestCaseExcelData data, TestCaseDTO t, List<TestCaseExportRequest.TestCaseExportHeader> otherHeaders) {
|
private void buildExportOtherField(TestCaseExcelData data, TestCaseDTO t, List<TestCaseExportRequest.TestCaseExportHeader> otherHeaders) {
|
||||||
if (CollectionUtils.isEmpty(otherHeaders)) {
|
if (CollectionUtils.isEmpty(otherHeaders)) {
|
||||||
return;
|
return;
|
||||||
|
@ -1800,6 +1816,7 @@ public class TestCaseService {
|
||||||
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), field.getTextValue());
|
||||||
|
this.validateExportText(data.getName(), field.getTextValue());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(field.getValue())) {
|
if (StringUtils.isNotBlank(field.getValue())) {
|
||||||
|
|
|
@ -231,3 +231,4 @@ api_status_fake_error=FakeError
|
||||||
serial=Serial
|
serial=Serial
|
||||||
parallel=Parallel
|
parallel=Parallel
|
||||||
rerun_warning=The connection is abnormal, please check the environment configuration
|
rerun_warning=The connection is abnormal, please check the environment configuration
|
||||||
|
case_export_text_validate_tip=Use case %s contains extremely long text, currently supported up to %s!
|
||||||
|
|
|
@ -202,3 +202,4 @@ api_status_fake_error=误报
|
||||||
serial=串行
|
serial=串行
|
||||||
parallel=并行
|
parallel=并行
|
||||||
rerun_warning=连接异常,请检查环境配置
|
rerun_warning=连接异常,请检查环境配置
|
||||||
|
case_export_text_validate_tip=用例 %s 包含超长文本,目前支持最大长度为 %s !
|
||||||
|
|
|
@ -202,3 +202,4 @@ api_status_fake_error=誤報
|
||||||
serial=串行
|
serial=串行
|
||||||
parallel=並行
|
parallel=並行
|
||||||
rerun_warning=連接異常,請檢查環境配置
|
rerun_warning=連接異常,請檢查環境配置
|
||||||
|
case_export_text_validate_tip=用例 %s 包含超長文本,目前支持最大長度為 %s !
|
||||||
|
|
|
@ -314,6 +314,7 @@ import TestCaseReviewStatusTableItem from "@/business/common/tableItems/TestCase
|
||||||
import RelateDemand from "@/business/case/components/RelateDemand";
|
import RelateDemand from "@/business/case/components/RelateDemand";
|
||||||
import TestPlanCaseStatusTableItem from "@/business/common/tableItems/TestPlanCaseStatusTableItem";
|
import TestPlanCaseStatusTableItem from "@/business/common/tableItems/TestPlanCaseStatusTableItem";
|
||||||
import {
|
import {
|
||||||
|
fileDownloadPost,
|
||||||
generateColumnKey,
|
generateColumnKey,
|
||||||
getCustomFieldValueForTrack,
|
getCustomFieldValueForTrack,
|
||||||
getProjectMemberOption
|
getProjectMemberOption
|
||||||
|
@ -1052,43 +1053,24 @@ export default {
|
||||||
}
|
}
|
||||||
let param = buildBatchParam(this, this.$refs.table.selectIds);
|
let param = buildBatchParam(this, this.$refs.table.selectIds);
|
||||||
Object.assign(param, fieldParam);
|
Object.assign(param, fieldParam);
|
||||||
let config = {};
|
let fileNameSuffix;
|
||||||
let fileNameSuffix = "";
|
let url;
|
||||||
if (exportType === 'xmind') {
|
if (exportType === 'xmind') {
|
||||||
config = {
|
url = '/test/case/export/testcase/xmind';
|
||||||
url: '/test/case/export/testcase/xmind',
|
|
||||||
method: 'post',
|
|
||||||
responseType: 'blob',
|
|
||||||
data: param
|
|
||||||
};
|
|
||||||
fileNameSuffix = ".xmind";
|
fileNameSuffix = ".xmind";
|
||||||
} else {
|
} else {
|
||||||
config = {
|
url = '/test/case/export/testcase'
|
||||||
url: '/test/case/export/testcase',
|
|
||||||
method: 'post',
|
|
||||||
responseType: 'blob',
|
|
||||||
data: param
|
|
||||||
};
|
|
||||||
fileNameSuffix = ".xlsx";
|
fileNameSuffix = ".xlsx";
|
||||||
}
|
}
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
store.isTestCaseExporting = true;
|
store.isTestCaseExporting = true;
|
||||||
|
fileDownloadPost(url, param, "Metersphere_case_" + this.projectName + fileNameSuffix)
|
||||||
this.$request(config).then(response => {
|
.then(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
const filename = "Metersphere_case_" + this.projectName + fileNameSuffix;
|
|
||||||
const blob = new Blob([response.data]);
|
|
||||||
if ("download" in document.createElement("a")) {
|
|
||||||
let aTag = document.createElement('a');
|
|
||||||
aTag.download = filename;
|
|
||||||
aTag.href = URL.createObjectURL(blob);
|
|
||||||
aTag.click();
|
|
||||||
URL.revokeObjectURL(aTag.href);
|
|
||||||
this.$emit('closeExport');
|
this.$emit('closeExport');
|
||||||
} else {
|
store.isTestCaseExporting = false;
|
||||||
navigator.msSaveBlob(blob, filename);
|
}).catch(() => {
|
||||||
this.$emit('closeExport');
|
this.loading = false;
|
||||||
}
|
|
||||||
store.isTestCaseExporting = false;
|
store.isTestCaseExporting = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue