fix(UI 自动化): 导出测试报告,UI用例测试结果看不了

--bug=1016327 --user=张大海 【测试跟踪】导出测试报告,UI用例测试结果看不了 https://www.tapd.cn/55049933/s/1236268
--bug=1016143 --user=张大海 【测试跟踪】分享测试计划报告链接 / 导出测试计划报告,查看ui步骤结果,一直在转圈 https://www.tapd.cn/55049933/s/1236266
This commit is contained in:
zhangdahai112 2022-08-31 01:00:06 +08:00 committed by zhangdahai112
parent e5168577cd
commit d52084793a
3 changed files with 22 additions and 1 deletions

View File

@ -22,9 +22,11 @@ import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.constants.RunModeConstants;
import io.metersphere.constants.SystemConstants;
import io.metersphere.dto.RequestResult;
import io.metersphere.service.ProjectService;
import io.metersphere.utils.LoggerUtil;
import io.metersphere.xpack.ui.dto.UiCommandResult;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.BooleanUtils;
@ -295,7 +297,12 @@ public class ApiScenarioReportStructureService {
step.setStepId(reportResults.get(i).getId());
RequestResult result = new RequestResultExpandDTO(reportResult);
if (reportResult.getContent() != null) {
result = JSON.parseObject(new String(reportResults.get(i).getContent(), StandardCharsets.UTF_8), RequestResult.class);
if (reportType.startsWith(SystemConstants.TestTypeEnum.UI.name())) {
result = JSON.parseObject(new String(reportResults.get(i).getContent(), StandardCharsets.UTF_8), UiCommandResult.class);
((UiCommandResult)result).calTime();
} else {
result = JSON.parseObject(new String(reportResults.get(i).getContent(), StandardCharsets.UTF_8), RequestResult.class);
}
}
step.setValue(result);
step.setTotalStatus(reportResult.getStatus());

View File

@ -0,0 +1,13 @@
package io.metersphere.constants;
/**
* 系统级别通用的常量和枚举
*/
public final class SystemConstants {
public enum TestTypeEnum {
API,
UI,
PERFORMANCE;
}
}

View File

@ -1979,6 +1979,7 @@ public class TestPlanService {
buildScenarioResponse(report.getScenarioFailureCases());
buildLoadResponse(report.getLoadAllCases());
buildUiScenarioResponse(report.getUiAllCases());
buildUiScenarioResponse(report.getUiFailureCases());
report.setLang(lang);
render(report, response);
}