fix(测试跟踪): 修复测试计划 导出的场景用例报告显示的不正确的问题
--bug=1012071 --user=宋天阳 【测试跟踪】-测试计划 导出的场景用例报告显示的不正确 https://www.tapd.cn/55049933/s/1132333
This commit is contained in:
parent
9c222f0aea
commit
6d145a49c5
|
@ -31,7 +31,7 @@ public class APIScenarioReportController {
|
||||||
|
|
||||||
@GetMapping("/get/{reportId}")
|
@GetMapping("/get/{reportId}")
|
||||||
public APIScenarioReportResult get(@PathVariable String reportId) {
|
public APIScenarioReportResult get(@PathVariable String reportId) {
|
||||||
return apiReportService.get(reportId);
|
return apiReportService.get(reportId,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/list/{goPage}/{pageSize}")
|
@PostMapping("/list/{goPage}/{pageSize}")
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class ApiScenarioReportService {
|
||||||
return scenarioReport;
|
return scenarioReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public APIScenarioReportResult get(String reportId) {
|
public APIScenarioReportResult get(String reportId,boolean selectReportContent) {
|
||||||
ApiDefinitionExecResult result = definitionExecResultMapper.selectByPrimaryKey(reportId);
|
ApiDefinitionExecResult result = definitionExecResultMapper.selectByPrimaryKey(reportId);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
APIScenarioReportResult reportResult = new APIScenarioReportResult();
|
APIScenarioReportResult reportResult = new APIScenarioReportResult();
|
||||||
|
@ -140,7 +140,7 @@ public class ApiScenarioReportService {
|
||||||
APIScenarioReportResult reportResult = extApiScenarioReportMapper.get(reportId);
|
APIScenarioReportResult reportResult = extApiScenarioReportMapper.get(reportId);
|
||||||
if (reportResult != null) {
|
if (reportResult != null) {
|
||||||
if (reportResult.getReportVersion() != null && reportResult.getReportVersion() > 1) {
|
if (reportResult.getReportVersion() != null && reportResult.getReportVersion() > 1) {
|
||||||
reportResult.setContent(JSON.toJSONString(apiScenarioReportStructureService.assembleReport(reportId)));
|
reportResult.setContent(JSON.toJSONString(apiScenarioReportStructureService.assembleReport(reportId,selectReportContent)));
|
||||||
} else {
|
} else {
|
||||||
ApiScenarioReportDetail detail = apiScenarioReportDetailMapper.selectByPrimaryKey(reportId);
|
ApiScenarioReportDetail detail = apiScenarioReportDetailMapper.selectByPrimaryKey(reportId);
|
||||||
if (detail != null && reportResult != null) {
|
if (detail != null && reportResult != null) {
|
||||||
|
|
|
@ -286,27 +286,46 @@ public class ApiScenarioReportStructureService {
|
||||||
if (reportResults.size() > 1) {
|
if (reportResults.size() > 1) {
|
||||||
for (int i = 0; i < reportResults.size(); i++) {
|
for (int i = 0; i < reportResults.size(); i++) {
|
||||||
ApiScenarioReportResultWithBLOBs reportResult = reportResults.get(i);
|
ApiScenarioReportResultWithBLOBs reportResult = reportResults.get(i);
|
||||||
reportResult = apiScenarioReportResultService.formatScenarioResult(reportResult);
|
if(reportResult.getContent() != null){
|
||||||
if (i == 0) {
|
//来自报告导出的数据
|
||||||
RequestResultExpandDTO requestResultExpandDTO = new RequestResultExpandDTO(reportResult);
|
if (i == 0) {
|
||||||
dto.setStepId(reportResults.get(i).getId());
|
dto.setValue(JSON.parseObject(new String(reportResults.get(i).getContent(), StandardCharsets.UTF_8), RequestResult.class));
|
||||||
dto.setValue(requestResultExpandDTO);
|
dto.setErrorCode(reportResults.get(0).getErrorCode());
|
||||||
dto.setErrorCode(reportResults.get(0).getErrorCode());
|
} else {
|
||||||
} else {
|
StepTreeDTO step = new StepTreeDTO(dto.getLabel(), UUID.randomUUID().toString(), dto.getType(), reportResults.get(i).getId(), (i + 1));
|
||||||
StepTreeDTO step = new StepTreeDTO(dto.getLabel(), UUID.randomUUID().toString(), dto.getType(), reportResults.get(i).getId(), (i + 1));
|
step.setValue(JSON.parseObject(new String(reportResults.get(i).getContent(), StandardCharsets.UTF_8), RequestResult.class));
|
||||||
RequestResultExpandDTO requestResultExpandDTO = new RequestResultExpandDTO(reportResult);
|
step.setErrorCode(reportResults.get(i).getErrorCode());
|
||||||
step.setValue(requestResultExpandDTO);
|
dtoList.add(step);
|
||||||
step.setErrorCode(reportResults.get(i).getErrorCode());
|
}
|
||||||
dtoList.add(step);
|
}else {
|
||||||
|
reportResult = apiScenarioReportResultService.formatScenarioResult(reportResult);
|
||||||
|
if (i == 0) {
|
||||||
|
RequestResultExpandDTO requestResultExpandDTO = new RequestResultExpandDTO(reportResult);
|
||||||
|
dto.setStepId(reportResults.get(i).getId());
|
||||||
|
dto.setValue(requestResultExpandDTO);
|
||||||
|
dto.setErrorCode(reportResults.get(0).getErrorCode());
|
||||||
|
} else {
|
||||||
|
StepTreeDTO step = new StepTreeDTO(dto.getLabel(), UUID.randomUUID().toString(), dto.getType(), reportResults.get(i).getId(), (i + 1));
|
||||||
|
RequestResultExpandDTO requestResultExpandDTO = new RequestResultExpandDTO(reportResult);
|
||||||
|
step.setValue(requestResultExpandDTO);
|
||||||
|
step.setErrorCode(reportResults.get(i).getErrorCode());
|
||||||
|
dtoList.add(step);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ApiScenarioReportResultWithBLOBs reportResult = reportResults.get(0);
|
ApiScenarioReportResultWithBLOBs reportResult = reportResults.get(0);
|
||||||
reportResult = apiScenarioReportResultService.formatScenarioResult(reportResult);
|
if(reportResult.getContent() != null){
|
||||||
RequestResultExpandDTO requestResultExpandDTO = new RequestResultExpandDTO(reportResult);
|
String content = new String(reportResults.get(0).getContent(), StandardCharsets.UTF_8);
|
||||||
dto.setStepId(reportResults.get(0).getId());
|
dto.setValue(JSON.parseObject(content, RequestResult.class));
|
||||||
dto.setValue(requestResultExpandDTO);
|
dto.setErrorCode(reportResults.get(0).getErrorCode());
|
||||||
dto.setErrorCode(reportResults.get(0).getErrorCode());
|
}else {
|
||||||
|
reportResult = apiScenarioReportResultService.formatScenarioResult(reportResult);
|
||||||
|
RequestResultExpandDTO requestResultExpandDTO = new RequestResultExpandDTO(reportResult);
|
||||||
|
dto.setStepId(reportResults.get(0).getId());
|
||||||
|
dto.setValue(requestResultExpandDTO);
|
||||||
|
dto.setErrorCode(reportResults.get(0).getErrorCode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(dto.getType()) && requests.contains(dto.getType()) && dto.getValue() == null || isUiUnExecuteCommand(dto)) {
|
if (StringUtils.isNotEmpty(dto.getType()) && requests.contains(dto.getType()) && dto.getValue() == null || isUiUnExecuteCommand(dto)) {
|
||||||
|
@ -517,16 +536,16 @@ public class ApiScenarioReportStructureService {
|
||||||
return reportDTO;
|
return reportDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiScenarioReportDTO assembleReport(String reportId) {
|
public ApiScenarioReportDTO assembleReport(String reportId,boolean selectReportContent) {
|
||||||
ApiScenarioReport report = scenarioReportMapper.selectByPrimaryKey(reportId);
|
ApiScenarioReport report = scenarioReportMapper.selectByPrimaryKey(reportId);
|
||||||
if (report != null && report.getReportType().equals(ReportTypeConstants.API_INTEGRATED.name())) {
|
if (report != null && report.getReportType().equals(ReportTypeConstants.API_INTEGRATED.name())) {
|
||||||
return this.apiIntegratedReport(reportId);
|
return this.apiIntegratedReport(reportId);
|
||||||
} else {
|
} else {
|
||||||
return this.getReport(reportId);
|
return this.getReport(reportId,selectReportContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiScenarioReportDTO getReport(String reportId) {
|
private ApiScenarioReportDTO getReport(String reportId,boolean selectContent) {
|
||||||
List<ApiScenarioReportResultWithBLOBs> reportResults = null;
|
List<ApiScenarioReportResultWithBLOBs> reportResults = null;
|
||||||
ApiScenarioReport report = scenarioReportMapper.selectByPrimaryKey(reportId);
|
ApiScenarioReport report = scenarioReportMapper.selectByPrimaryKey(reportId);
|
||||||
if (report.getReportType() != null && report.getReportType().startsWith("UI")) {
|
if (report.getReportType() != null && report.getReportType().startsWith("UI")) {
|
||||||
|
@ -534,6 +553,10 @@ public class ApiScenarioReportStructureService {
|
||||||
example.createCriteria().andReportIdEqualTo(reportId);
|
example.createCriteria().andReportIdEqualTo(reportId);
|
||||||
reportResults = reportResultMapper.selectByExampleWithBLOBs(example);
|
reportResults = reportResultMapper.selectByExampleWithBLOBs(example);
|
||||||
removeUiResultIfNotStep(reportResults);
|
removeUiResultIfNotStep(reportResults);
|
||||||
|
}else if(selectContent){
|
||||||
|
ApiScenarioReportResultExample example = new ApiScenarioReportResultExample();
|
||||||
|
example.createCriteria().andReportIdEqualTo(reportId);
|
||||||
|
reportResults = reportResultMapper.selectByExampleWithBLOBs(example);
|
||||||
}else {
|
}else {
|
||||||
reportResults = this.selectBaseInfoResultByReportId(reportId);
|
reportResults = this.selectBaseInfoResultByReportId(reportId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,7 @@ public class ShareController {
|
||||||
@GetMapping("/api/scenario/report/get/{shareId}/{reportId}")
|
@GetMapping("/api/scenario/report/get/{shareId}/{reportId}")
|
||||||
public APIScenarioReportResult get(@PathVariable String shareId, @PathVariable String reportId) {
|
public APIScenarioReportResult get(@PathVariable String shareId, @PathVariable String reportId) {
|
||||||
shareInfoService.validateExpired(shareId); // 测试计划,和接口都会用这个
|
shareInfoService.validateExpired(shareId); // 测试计划,和接口都会用这个
|
||||||
return apiScenarioReportService.get(reportId);
|
return apiScenarioReportService.get(reportId,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/performance/report/{shareId}/{reportId}")
|
@GetMapping("/performance/report/{shareId}/{reportId}")
|
||||||
|
|
|
@ -496,7 +496,7 @@ public class TestPlanScenarioCaseService {
|
||||||
private void calculateScenarioResultDTO(PlanReportCaseDTO item,
|
private void calculateScenarioResultDTO(PlanReportCaseDTO item,
|
||||||
TestPlanScenarioStepCountDTO stepCount) {
|
TestPlanScenarioStepCountDTO stepCount) {
|
||||||
if (StringUtils.isNotBlank(item.getReportId())) {
|
if (StringUtils.isNotBlank(item.getReportId())) {
|
||||||
APIScenarioReportResult apiScenarioReportResult = apiScenarioReportService.get(item.getReportId());
|
APIScenarioReportResult apiScenarioReportResult = apiScenarioReportService.get(item.getReportId(),false);
|
||||||
if (apiScenarioReportResult != null) {
|
if (apiScenarioReportResult != null) {
|
||||||
String content = apiScenarioReportResult.getContent();
|
String content = apiScenarioReportResult.getContent();
|
||||||
if (StringUtils.isNotBlank(content)) {
|
if (StringUtils.isNotBlank(content)) {
|
||||||
|
|
|
@ -1462,7 +1462,7 @@ public class TestPlanService {
|
||||||
public void buildScenarioResponse(List<TestPlanFailureScenarioDTO> cases) {
|
public void buildScenarioResponse(List<TestPlanFailureScenarioDTO> cases) {
|
||||||
if (!CollectionUtils.isEmpty(cases)) {
|
if (!CollectionUtils.isEmpty(cases)) {
|
||||||
cases.forEach((item) -> {
|
cases.forEach((item) -> {
|
||||||
item.setResponse(apiScenarioReportService.get(item.getReportId()));
|
item.setResponse(apiScenarioReportService.get(item.getReportId(),true));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,8 +343,12 @@ export default {
|
||||||
this.init();
|
this.init();
|
||||||
if (this.isTemplate) {
|
if (this.isTemplate) {
|
||||||
// 测试计划报告导出
|
// 测试计划报告导出
|
||||||
this.report = this.templateReport;
|
if(this.templateReport){
|
||||||
this.buildReport();
|
this.handleGetScenarioReport(this.templateReport);
|
||||||
|
}else {
|
||||||
|
this.report = this.templateReport;
|
||||||
|
this.buildReport();
|
||||||
|
}
|
||||||
} else if (this.isShare) {
|
} else if (this.isShare) {
|
||||||
getShareScenarioReport(this.shareId, this.reportId, (data) => {
|
getShareScenarioReport(this.shareId, this.reportId, (data) => {
|
||||||
this.checkReport(data);
|
this.checkReport(data);
|
||||||
|
|
|
@ -164,16 +164,25 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadRequestInfoExpand() {
|
loadRequestInfoExpand() {
|
||||||
this.$get("/api/scenario/report/selectReportContent/" + this.stepId, response => {
|
if(!this.requestInfo.hasData){
|
||||||
let requestResult = response.data;
|
if(this.request.responseResult && this.request.responseResult.body){
|
||||||
if (requestResult) {
|
this.requestInfo = this.request;
|
||||||
this.requestInfo = requestResult;
|
|
||||||
}
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.requestInfo.loading = false;
|
|
||||||
this.requestInfo.hasData = true;
|
this.requestInfo.hasData = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!this.requestInfo.hasData){
|
||||||
|
this.$get("/api/scenario/report/selectReportContent/" + this.stepId, response => {
|
||||||
|
let requestResult = response.data;
|
||||||
|
if (requestResult) {
|
||||||
|
this.requestInfo = requestResult;
|
||||||
|
}
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.requestInfo.loading = false;
|
||||||
|
this.requestInfo.hasData = true;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
active() {
|
active() {
|
||||||
if (this.request.unexecute) {
|
if (this.request.unexecute) {
|
||||||
|
@ -182,11 +191,7 @@ export default {
|
||||||
this.showActive = !this.showActive;
|
this.showActive = !this.showActive;
|
||||||
}
|
}
|
||||||
if (this.showActive) {
|
if (this.showActive) {
|
||||||
if (this.requestInfo.hasData) {
|
this.loadRequestInfoExpand();
|
||||||
this.requestInfo.loading = false;
|
|
||||||
} else {
|
|
||||||
this.loadRequestInfoExpand();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getName(name) {
|
getName(name) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue