fix(测试跟踪): 功能用例缺陷与测试计划缺陷分离

This commit is contained in:
chenjianxing 2022-02-16 19:53:04 +08:00 committed by john1298308460
parent 85c47f165c
commit 7f9a7af0f5
13 changed files with 91 additions and 28 deletions

View File

@ -27,4 +27,6 @@ public interface ExtIssuesMapper {
List<IssuesDao>getCountByStatus(@Param("request") IssuesRequest issuesRequest);
List<String> selectIdNotInUuIds(@Param("projectId") String projectId, @Param("platform") String platform, @Param("platformIds") List<String> platformIds);
List<IssuesDao> getPlanIssues(@Param("request") IssuesRequest issueRequest);
}

View File

@ -8,7 +8,6 @@
inner join test_case_issues
on test_case_issues.issues_id = issues.id
<include refid="queryWhereCondition"/>
and (issues.platform_status != 'delete' or issues.platform_status is NULL)
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select>
@ -37,20 +36,38 @@
order by num asc
</select>
<sql id="Issue_List_Column">
issues.id, issues.platform_id, issues.num, ifnull(issues.title, '') as title, issues.project_id, issues.create_time, issues.update_time,
ifnull(issues.description, '') as description, issues.status, issues.platform, issues.custom_fields, issues.reporter,
issues.creator,issues.resource_id,issues.platform_status,
issues.lastmodify
</sql>
<select id="getIssues" resultType="io.metersphere.base.domain.IssuesDao">
select issues.id, issues.platform_id, issues.num, ifnull(issues.title, '') as title, issues.project_id, issues.create_time, issues.update_time,
ifnull(issues.description, '') as description, issues.status, issues.platform, issues.custom_fields, issues.reporter,
issues.creator,issues.resource_id,issues.platform_status,
issues.lastmodify
select
<include refid="Issue_List_Column"/>
from issues
<if test="request.projectId != null||request.workspaceId != null">
left join
project on issues.project_id = project.id
</if>
<include refid="queryWhereCondition"/>
and (issues.platform_status != 'delete' or issues.platform_status is NULL)
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select>
<select id="getPlanIssues" resultType="io.metersphere.base.domain.IssuesDao">
select
<include refid="Issue_List_Column"/>
from issues
inner join test_case_issues
on issues.id = test_case_issues.issues_id and test_case_issues.ref_type = 'PLAN_FUNCTIONAL'
and test_case_issues.resource_id in (
select id from test_plan_test_case tptc where plan_id = #{request.planId}
)
<include refid="queryWhereCondition"/>
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select>
<select id="getNextNum" resultType="io.metersphere.base.domain.Issues">
SELECT * FROM issues WHERE issues.project_id = #{projectId} ORDER BY num DESC LIMIT 1;
</select>
@ -66,10 +83,8 @@
issues.lastmodify
from issues
left join
test_case_issues on issues.id = test_case_issues.issues_id
test_case_issues on issues.id = test_case_issues.issues_id and issues.project_id = #{request.projectId}
<include refid="queryWhereCondition"/>
and (test_case_issues.resource_id is null or test_case_issues.resource_id != #{request.caseResourceId})
and (issues.platform_status != 'delete' or issues.platform_status is NULL)
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
group by issues.id
</select>
@ -130,6 +145,12 @@
<if test="request.id != null and request.id != ''">
and issues.id = #{request.id}
</if>
<if test="request.notInIds != null and request.notInIds.size() > 0">
and issues.id not in
<foreach collection="request.notInIds" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
@ -157,7 +178,7 @@
</if>
</foreach>
</if>
and (issues.platform_status != 'delete' or issues.platform_status is NULL)
</where>
</sql>
<sql id="combine">

View File

@ -249,8 +249,8 @@
<select id="getProjectPlanBugSize" resultType="java.lang.Integer">
select count(distinct (tci.issues_id))
from test_plan_test_case tptc
join test_case_issues tci on tptc.case_id = tci.resource_id
right join test_case on test_case.id = tci.resource_id
join test_case_issues tci on tptc.id = tci.resource_id
right join test_case on test_case.id = tci.ref_id
join issues on tci.issues_id = issues.id
join test_plan on tptc.plan_id = test_plan.id
where test_plan.project_id = #{projectId}

View File

@ -724,9 +724,9 @@
<select id="getTestPlanBug" resultType="int">
select count(distinct (tci.issues_id))
from test_plan_test_case tptc
join test_case_issues tci on tptc.case_id = tci.resource_id
join test_case_issues tci on tptc.id = tci.resource_id
right join test_case
on test_case.id = tci.resource_id
on test_case.id = tci.ref_id
join issues
on tci.issues_id = issues.id
where tptc.plan_id = #{planId}

View File

@ -74,7 +74,7 @@ public class ShareController {
@GetMapping("/issues/plan/get/{shareId}/{planId}")
public List<IssuesDao> getIssuesByPlanoId(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId);
return issuesService.getIssuesByPlanoId(planId);
return issuesService.getIssuesByPlanId(planId);
}
@GetMapping("/test/plan/report/{shareId}/{planId}")

View File

@ -82,7 +82,7 @@ public class IssuesController {
@GetMapping("/plan/get/{planId}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_ISSUE_READ)
public List<IssuesDao> getIssuesByPlanId(@PathVariable String planId) {
return issuesService.getIssuesByPlanoId(planId);
return issuesService.getIssuesByPlanId(planId);
}
@GetMapping("/auth/{workspaceId}/{platform}")

View File

@ -43,9 +43,11 @@ public class IssuesRequest extends BaseQueryRequest {
private String platform;
private String customFields;
private List<String> testCaseIds;
private List<String> notInIds;
private String requestType;
private String status;
private String defaultCustomFields;
private Boolean isPlanEdit = false;
private String planId;
}

View File

@ -272,7 +272,7 @@ public class IssuesService {
example.createCriteria().andIssuesIdEqualTo(id);
List<TestCaseIssues> testCaseIssues = testCaseIssuesMapper.selectByExample(example);
testCaseIssues.forEach(i -> {
if (i.getRefType().equals(IssueRefType.PLAN_FUNCTIONAL)) {
if (i.getRefType().equals(IssueRefType.PLAN_FUNCTIONAL.name())) {
testCaseIssueService.updateIssuesCount(i.getResourceId());
}
});
@ -335,14 +335,21 @@ public class IssuesService {
if (planMap.get(item.getResourceId()) != null) {
item.setResourceName(planMap.get(item.getResourceId()));
}
TestCaseIssuesExample example = new TestCaseIssuesExample();
example.createCriteria().andIssuesIdEqualTo(item.getId());
List<TestCaseIssues> testCaseIssues = testCaseIssuesMapper.selectByExample(example);
List<String> caseIds = testCaseIssues.stream()
.map(TestCaseIssues::getResourceId)
.collect(Collectors.toList());
item.setCaseIds(caseIds);
item.setCaseCount(testCaseIssues.size());
Set<String> caseIdSet = new HashSet<>();
testCaseIssues.forEach(i -> {
if (i.getRefType().equals(IssueRefType.PLAN_FUNCTIONAL.name())) {
caseIdSet.add(i.getRefId());
} else {
caseIdSet.add(i.getResourceId());
}
});
item.setCaseIds(new ArrayList<>(caseIdSet));
item.setCaseCount(caseIdSet.size());
try {
if (StringUtils.equals(item.getPlatform(), IssuesManagePlatform.Tapd.name())) {
TapdPlatform platform = (TapdPlatform) IssueFactory.createPlatform(item.getPlatform(), request);
@ -540,7 +547,7 @@ public class IssuesService {
}
public List<IssuesDao> relateList(IssuesRequest request) {
return extIssuesMapper.getRelateIssues(request);
return extIssuesMapper.getIssues(request);
}
public void userAuth(AuthUserIssueRequest authUserIssueRequest) {
@ -577,10 +584,20 @@ public class IssuesService {
functionResult.setIssueData(statusResult);
}
public List<IssuesDao> getIssuesByPlanoId(String planId) {
public List<IssuesDao> getIssuesByPlanId(String planId) {
IssuesRequest issueRequest = new IssuesRequest();
issueRequest.setResourceId(planId);
return extIssuesMapper.getIssues(issueRequest);
issueRequest.setPlanId(planId);
List<IssuesDao> planIssues = extIssuesMapper.getPlanIssues(issueRequest);
Set<String> ids = new HashSet<>(planIssues.size());
Iterator<IssuesDao> iterator = planIssues.iterator();
while (iterator.hasNext()) {
IssuesDao next = iterator.next();
if (ids.contains(next.getId())) {
iterator.remove();
}
ids.add(next.getId());
}
return planIssues;
}
public void changeStatus(IssuesRequest request) {

View File

@ -1397,7 +1397,7 @@ public class TestPlanService {
report.setFunctionFailureCases(failureCases);
}
if (checkReportConfig(config, "functional", "issue")) {
List<IssuesDao> issueList = issuesService.getIssuesByPlanoId(planId);
List<IssuesDao> issueList = issuesService.getIssuesByPlanId(planId);
report.setIssueList(issueList);
}
}

View File

@ -93,6 +93,7 @@ export default {
props: {
caseId: String,
planCaseId: String,
notInIds: Array,
},
created() {
isThirdPartEnable((data) => {
@ -106,7 +107,7 @@ export default {
},
getIssues() {
this.page.condition.projectId = this.projectId;
this.page.condition.caseResourceId = this.getCaseResourceId();
this.page.condition.notInIds = this.notInIds;
this.page.result = getRelateIssues(this.page);
},
getCaseResourceId() {

View File

@ -95,6 +95,7 @@
<IssueRelateList
:plan-case-id="planCaseId"
:case-id="caseId"
:not-in-ids="notInIds"
@refresh="getIssues"
ref="issueRelate"/>
</div>
@ -145,6 +146,9 @@ export default {
issueStatusMap() {
return ISSUE_STATUS_MAP;
},
notInIds() {
return this.page.data ? this.page.data.map(i => i.id) : [];
}
},
created() {
getIssuePartTemplateWithProject((template, project) => {

View File

@ -50,6 +50,7 @@
</ms-table>
<test-case-relate-list
:test-case-contain-ids="testCaseContainIds"
@refresh="initTableData"
@save="handleRelate"
ref="testCaseRelevance"/>
@ -72,6 +73,7 @@ export default {
tableData: [],
deleteIds: new Set(),
addIds: new Set(),
testCaseContainIds: new Set(),
operators: [
{
tip: this.$t('commons.delete'), icon: "el-icon-delete", type: "danger",
@ -85,6 +87,7 @@ export default {
},
methods: {
handleDelete(item, index) {
this.testCaseContainIds.delete(item.id);
this.tableData.splice(index, 1);
this.deleteIds.add(item.id);
},
@ -96,6 +99,9 @@ export default {
if (this.issuesId) {
this.result = this.$post('test/case/issues/list', condition, response => {
this.tableData = response.data;
this.tableData.forEach(item => {
this.testCaseContainIds.add(item.id);
});
this.$refs.table.reloadTable();
});
}
@ -106,6 +112,9 @@ export default {
handleRelate(selectRows) {
let selectData = Array.from(selectRows);
selectRows.forEach(i => {
if (i.id) {
this.testCaseContainIds.add(i.id);
}
this.deleteIds.delete(i.id);
this.addIds.add(i.id);
});

View File

@ -107,6 +107,12 @@ export default {
selectNodeIds: [],
};
},
props: {
testCaseContainIds: {
type: Set,
default: new Set()
}
},
watch: {
selectNodeIds() {
this.initTableData();
@ -132,6 +138,7 @@ export default {
if (this.projectId) {
this.getProjectNode();
this.condition.projectId = this.projectId;
this.condition.testCaseContainIds = Array.from(this.testCaseContainIds)
this.result = this.$post('/test/case/relate/issue/' + +this.currentPage + '/' + this.pageSize, this.condition, response => {
let data = response.data;
this.total = data.itemCount;