fix(接口测试): 修复接口测试报告全选删除时删除所有的场景和接口报告的问题
--bug=1015725 --user=宋天阳 【接口测试】接口测试报告-全选接口报告-批量删除,会把场景报告也都删掉,全选场景报告也是 https://www.tapd.cn/55049933/s/1221535
This commit is contained in:
parent
2562648a05
commit
5779930f56
|
@ -23,5 +23,10 @@ public class QueryAPIReportRequest {
|
||||||
private Map<String, List<String>> filters;
|
private Map<String, List<String>> filters;
|
||||||
private Map<String, Object> combine;
|
private Map<String, Object> combine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询哪种用例的报告 SCENARIO/API
|
||||||
|
*/
|
||||||
|
private String caseType;
|
||||||
|
|
||||||
private String limit;
|
private String limit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,12 @@ public class ApiScenarioReportService {
|
||||||
public List<String> idList(QueryAPIReportRequest request) {
|
public List<String> idList(QueryAPIReportRequest request) {
|
||||||
request = this.initRequest(request);
|
request = this.initRequest(request);
|
||||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||||
return extApiScenarioReportMapper.idList(request);
|
//检查必填参数caseType
|
||||||
|
if (StringUtils.equalsAny(request.getCaseType(), ReportTypeConstants.API.name(), ReportTypeConstants.SCENARIO.name())) {
|
||||||
|
return extApiScenarioReportMapper.idList(request);
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkNameExist(APIScenarioReportResult request) {
|
private void checkNameExist(APIScenarioReportResult request) {
|
||||||
|
@ -271,7 +276,7 @@ public class ApiScenarioReportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiScenarioReport updatePlanCase(ResultDTO dto) {
|
public ApiScenarioReport updatePlanCase(ResultDTO dto) {
|
||||||
String status = getStatus(dto);
|
String status = getStatus(dto);
|
||||||
ApiScenarioReport report = editReport(dto.getReportType(), dto.getReportId(), status, dto.getRunMode());
|
ApiScenarioReport report = editReport(dto.getReportType(), dto.getReportId(), status, dto.getRunMode());
|
||||||
TestPlanApiScenario testPlanApiScenario = testPlanApiScenarioMapper.selectByPrimaryKey(dto.getTestId());
|
TestPlanApiScenario testPlanApiScenario = testPlanApiScenarioMapper.selectByPrimaryKey(dto.getTestId());
|
||||||
if (testPlanApiScenario != null) {
|
if (testPlanApiScenario != null) {
|
||||||
|
@ -648,13 +653,19 @@ public class ApiScenarioReportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAPIReportBatch(APIReportBatchRequest reportRequest) {
|
public void deleteAPIReportBatch(APIReportBatchRequest reportRequest) {
|
||||||
List<String> ids = getIdsByDeleteBatchRequest(reportRequest);
|
if (reportRequest.getIsUi()) {
|
||||||
ids = batchDeleteReportResource(reportRequest, ids, true);
|
//ui报告对应的用例类型也是scenario
|
||||||
|
reportRequest.setCaseType(ReportTypeConstants.SCENARIO.name());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(reportRequest.getCaseType())) {
|
||||||
|
List<String> ids = getIdsByDeleteBatchRequest(reportRequest);
|
||||||
|
ids = batchDeleteReportResource(reportRequest, ids, true);
|
||||||
|
|
||||||
//处理最后剩余的数据
|
//处理报告关联数据
|
||||||
if (!ids.isEmpty()) {
|
if (!ids.isEmpty()) {
|
||||||
deleteScenarioReportByIds(ids);
|
deleteScenarioReportByIds(ids);
|
||||||
deleteApiDefinitionResultByIds(ids);
|
deleteApiDefinitionResultByIds(ids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -873,7 +884,6 @@ public class ApiScenarioReportService {
|
||||||
|
|
||||||
long errorReportResultSize = dto.getRequestResults().stream().filter(requestResult ->
|
long errorReportResultSize = dto.getRequestResults().stream().filter(requestResult ->
|
||||||
StringUtils.equalsIgnoreCase(requestResult.getStatus(), ExecuteResult.ERROR_REPORT_RESULT.toString())).count();
|
StringUtils.equalsIgnoreCase(requestResult.getStatus(), ExecuteResult.ERROR_REPORT_RESULT.toString())).count();
|
||||||
|
|
||||||
String status = dto.getRequestResults().isEmpty() ? ExecuteResult.UN_EXECUTE.toString() : ScenarioStatus.Success.name();
|
String status = dto.getRequestResults().isEmpty() ? ExecuteResult.UN_EXECUTE.toString() : ScenarioStatus.Success.name();
|
||||||
if (errorSize > 0) {
|
if (errorSize > 0) {
|
||||||
status = ScenarioStatus.Error.name();
|
status = ScenarioStatus.Error.name();
|
||||||
|
|
|
@ -241,6 +241,7 @@
|
||||||
|
|
||||||
<select id="idList" resultType="java.lang.String">
|
<select id="idList" resultType="java.lang.String">
|
||||||
select r.id from (
|
select r.id from (
|
||||||
|
<if test="request.caseType == 'SCENARIO'">
|
||||||
SELECT s_r.name AS test_name,
|
SELECT s_r.name AS test_name,
|
||||||
s_r.end_time,
|
s_r.end_time,
|
||||||
s_r.user_id,
|
s_r.user_id,
|
||||||
|
@ -253,9 +254,10 @@
|
||||||
s_r.trigger_mode,
|
s_r.trigger_mode,
|
||||||
s_r.execute_type,
|
s_r.execute_type,
|
||||||
s_r.report_type
|
s_r.report_type
|
||||||
FROM api_scenario_report s_r
|
FROM api_scenario_report s_r
|
||||||
union all
|
</if>
|
||||||
select a_r.name as test_name,
|
<if test="request.caseType == 'API'">
|
||||||
|
select a_r.name as test_name,
|
||||||
a_r.end_time,
|
a_r.end_time,
|
||||||
a_r.user_id,
|
a_r.user_id,
|
||||||
a_r.name,
|
a_r.name,
|
||||||
|
@ -267,8 +269,9 @@
|
||||||
a_r.trigger_mode,
|
a_r.trigger_mode,
|
||||||
'Saved' as execute_type,
|
'Saved' as execute_type,
|
||||||
'API_INDEPENDENT' as report_type
|
'API_INDEPENDENT' as report_type
|
||||||
from api_definition_exec_result a_r
|
from api_definition_exec_result a_r
|
||||||
where a_r.integrated_report_id is null or a_r.integrated_report_id = 'null'
|
where a_r.integrated_report_id is null or a_r.integrated_report_id = 'null'
|
||||||
|
</if>
|
||||||
) r
|
) r
|
||||||
<where>
|
<where>
|
||||||
<if test="request.combine != null">
|
<if test="request.combine != null">
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
package io.metersphere.commons.constants;
|
package io.metersphere.commons.constants;
|
||||||
|
|
||||||
public enum ReportTypeConstants {
|
public enum ReportTypeConstants {
|
||||||
|
/**
|
||||||
|
* 所有场景类型,包括接口场景、UI场景
|
||||||
|
*/
|
||||||
|
SCENARIO,
|
||||||
|
/**
|
||||||
|
* 所有接口类型,包括接口、接口用例
|
||||||
|
*/
|
||||||
|
API,
|
||||||
SCENARIO_INTEGRATED,
|
SCENARIO_INTEGRATED,
|
||||||
SCENARIO_INDEPENDENT,
|
SCENARIO_INDEPENDENT,
|
||||||
API_INTEGRATED,
|
API_INTEGRATED,
|
||||||
|
|
|
@ -373,6 +373,7 @@ export default {
|
||||||
sendParam.selectAllDate = this.isSelectAllDate;
|
sendParam.selectAllDate = this.isSelectAllDate;
|
||||||
sendParam.unSelectIds = this.unSelection;
|
sendParam.unSelectIds = this.unSelection;
|
||||||
sendParam = Object.assign(sendParam, this.condition);
|
sendParam = Object.assign(sendParam, this.condition);
|
||||||
|
sendParam.caseType = this.trashActiveDom === 'right' ? 'API' : 'SCENARIO';
|
||||||
this.$post('/api/scenario/report/batch/delete', sendParam, () => {
|
this.$post('/api/scenario/report/batch/delete', sendParam, () => {
|
||||||
this.selectRows.clear();
|
this.selectRows.clear();
|
||||||
this.$success(this.$t('commons.delete_success'));
|
this.$success(this.$t('commons.delete_success'));
|
||||||
|
|
Loading…
Reference in New Issue