feat(测试跟踪): 功能用例回收站关联版本的改动
This commit is contained in:
parent
0d05cd92d9
commit
27a30ab61b
|
@ -1,7 +1,5 @@
|
|||
package io.metersphere.api.dto.automation;
|
||||
|
||||
import org.junit.internal.runners.statements.Fail;
|
||||
|
||||
public enum ScenarioStatus {
|
||||
Saved, Success, Error, Timeout, Fail, Trash, Underway
|
||||
}
|
||||
|
|
|
@ -134,4 +134,6 @@ public interface ExtTestCaseMapper {
|
|||
String getLastExecStatusById(String id);
|
||||
|
||||
int countByWorkSpaceId(String workSpaceId);
|
||||
|
||||
long trashCount(@Param("projectId") String projectId);
|
||||
}
|
||||
|
|
|
@ -865,7 +865,7 @@
|
|||
status = original_status,
|
||||
delete_user_id = null,
|
||||
delete_time = null
|
||||
where id in
|
||||
where ref_id in
|
||||
<foreach collection="ids" item="v" separator="," open="(" close=")">
|
||||
#{v}
|
||||
</foreach>
|
||||
|
@ -898,4 +898,14 @@
|
|||
and status != 'Trash'
|
||||
</select>
|
||||
|
||||
<select id="trashCount" resultType="java.lang.Long">
|
||||
SELECT
|
||||
count(DISTINCT ref_id)
|
||||
FROM
|
||||
test_case
|
||||
WHERE
|
||||
project_id = #{projectId}
|
||||
AND STATUS = 'Trash'
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -244,7 +244,7 @@ public class TestCaseController {
|
|||
@MsAuditLog(module = "track_test_case", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#testCaseId)", msClass = TestCaseService.class)
|
||||
public int deleteTestCase(@PathVariable String testCaseId) {
|
||||
checkPermissionService.checkTestCaseOwner(testCaseId);
|
||||
return testCaseService.deleteTestCase(testCaseId);
|
||||
return testCaseService.deleteTestCaseBySameVersion(testCaseId);
|
||||
}
|
||||
|
||||
@PostMapping("/deleteToGc/{testCaseId}")
|
||||
|
|
|
@ -774,9 +774,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
|||
}
|
||||
|
||||
public long trashCount(String projectId) {
|
||||
TestCaseExample testCaseExample = new TestCaseExample();
|
||||
testCaseExample.createCriteria().andProjectIdEqualTo(projectId).andStatusEqualTo("Trash");
|
||||
return testCaseMapper.countByExample(testCaseExample);
|
||||
return extTestCaseMapper.trashCount(projectId);
|
||||
}
|
||||
|
||||
public void minderEdit(TestCaseMinderEditRequest request) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.github.pagehelper.Page;
|
|||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.api.dto.automation.ApiScenarioDTO;
|
||||
import io.metersphere.api.dto.automation.ApiScenarioRequest;
|
||||
import io.metersphere.api.dto.automation.ScenarioStatus;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseDTO;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
|
||||
import io.metersphere.api.service.ApiAutomationService;
|
||||
|
@ -491,6 +492,24 @@ public class TestCaseService {
|
|||
return testCaseMapper.deleteByPrimaryKey(testCaseId);
|
||||
}
|
||||
|
||||
public int deleteTestCaseBySameVersion(String testCaseId) {
|
||||
TestCase testCase = testCaseMapper.selectByPrimaryKey(testCaseId);
|
||||
if (testCase == null) {
|
||||
return 0;
|
||||
}
|
||||
if (StringUtils.isNotBlank(testCase.getRefId())) {
|
||||
TestCaseExample testCaseExample = new TestCaseExample();
|
||||
testCaseExample.createCriteria().andRefIdEqualTo(testCase.getRefId());
|
||||
// 因为删除
|
||||
List<String> sameVersionIds = testCaseMapper.selectByExample(testCaseExample).stream().map(TestCase::getId).collect(Collectors.toList());
|
||||
AtomicInteger integer = new AtomicInteger(0);
|
||||
sameVersionIds.forEach(id -> integer.getAndAdd(deleteTestCase(id)));
|
||||
return integer.get();
|
||||
} else {
|
||||
return deleteTestCase(testCaseId);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteFollows(String testCaseId) {
|
||||
TestCaseFollowExample example = new TestCaseFollowExample();
|
||||
example.createCriteria().andCaseIdEqualTo(testCaseId);
|
||||
|
@ -2082,8 +2101,14 @@ public class TestCaseService {
|
|||
|
||||
//检查原来模块是否还在
|
||||
example = new TestCaseExample();
|
||||
// 关联版本之后,必须查询每一个数据的所有版本,依次还原
|
||||
example.createCriteria().andIdIn(request.getIds());
|
||||
List<TestCase> reductionCaseList = testCaseMapper.selectByExample(example);
|
||||
List<String> refIds = reductionCaseList.stream().map(TestCase::getRefId).collect(Collectors.toList());
|
||||
example.clear();
|
||||
example.createCriteria().andRefIdIn(refIds);
|
||||
reductionCaseList = testCaseMapper.selectByExample(example);
|
||||
request.setIds(reductionCaseList.stream().map(TestCase::getId).collect(Collectors.toList()));
|
||||
Map<String, List<TestCase>> nodeMap = reductionCaseList.stream().collect(Collectors.groupingBy(TestCase::getNodeId));
|
||||
for (Map.Entry<String, List<TestCase>> entry : nodeMap.entrySet()) {
|
||||
String nodeId = entry.getKey();
|
||||
|
@ -2383,6 +2408,13 @@ public class TestCaseService {
|
|||
}
|
||||
QueryTestCaseRequest request = new QueryTestCaseRequest();
|
||||
request.setRefId(testCase.getRefId());
|
||||
if (ScenarioStatus.Trash.name().equalsIgnoreCase(testCase.getStatus())) {
|
||||
request.setFilters(new HashMap<String, List<String>>() {{
|
||||
put("status", new ArrayList() {{
|
||||
add(ScenarioStatus.Trash.name());
|
||||
}});
|
||||
}});
|
||||
}
|
||||
return this.listTestCase(request);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,11 +24,17 @@
|
|||
<ms-main-container>
|
||||
<el-tabs v-model="activeName" @tab-click="addTab" @tab-remove="closeConfirm">
|
||||
<el-tab-pane name="trash" v-if="trashEnable" :label="$t('commons.trash')">
|
||||
<ms-tab-button
|
||||
:isShowChangeButton="false">
|
||||
<template v-slot:version>
|
||||
<version-select v-xpack :project-id="projectId" @changeVersion="changeTrashVersion" margin-left="-10"/>
|
||||
</template>
|
||||
<test-case-list
|
||||
:checkRedirectID="checkRedirectID"
|
||||
:isRedirectEdit="isRedirectEdit"
|
||||
:tree-nodes="treeNodes"
|
||||
:trash-enable="true"
|
||||
:current-version="currentTrashVersion"
|
||||
@refreshTable="refresh"
|
||||
@testCaseEdit="editTestCase"
|
||||
@testCaseCopy="copyTestCase"
|
||||
|
@ -40,6 +46,7 @@
|
|||
@setCondition="setCondition"
|
||||
ref="testCaseTrashList">
|
||||
</test-case-list>
|
||||
</ms-tab-button>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane name="public" v-if="publicEnable" :label="$t('project.case_public')">
|
||||
<test-case-list
|
||||
|
@ -230,6 +237,7 @@ export default {
|
|||
publicTotal: 0,
|
||||
tmpPath: null,
|
||||
currentVersion: null,
|
||||
currentTrashVersion: null,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
|
@ -635,6 +643,9 @@ export default {
|
|||
changeVersion(currentVersion) {
|
||||
this.currentVersion = currentVersion || null;
|
||||
},
|
||||
changeTrashVersion(currentVersion) {
|
||||
this.currentTrashVersion = currentVersion || null;
|
||||
},
|
||||
checkout(testCase, item) {
|
||||
Object.assign(item.testCaseInfo, testCase)
|
||||
//子组件先变更 copy 状态,再执行初始化操作
|
||||
|
|
|
@ -540,6 +540,7 @@ export default {
|
|||
this.$emit('testCaseEdit', testCase);
|
||||
});
|
||||
}
|
||||
this.getVersionOptions();
|
||||
},
|
||||
activated() {
|
||||
this.getTemplateField();
|
||||
|
@ -728,7 +729,12 @@ export default {
|
|||
this.condition.filters.priority = this.condition.filters['用例等级'];
|
||||
this.condition.filters.status = this.condition.filters['用例状态'];
|
||||
if (this.trashEnable) {
|
||||
//支持回收站查询版本
|
||||
let versionIds = this.condition.filters.version_id;
|
||||
this.condition.filters = {status: ["Trash"]};
|
||||
if (versionIds) {
|
||||
this.condition.filters.version_id = versionIds;
|
||||
}
|
||||
}
|
||||
if (this.projectId) {
|
||||
this.condition.projectId = this.projectId;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 07b1946ae7473daf4f116deafd7af9d1a90aa199
|
||||
Subproject commit 964acf775191a3243b1da5225352da8c1d998235
|
Loading…
Reference in New Issue