fix(测试跟踪): 功能用例列表,模块用例数显示有误
--bug=1025675 --user=陈建星 【测试跟踪】功能用例-新建用例保存后前置tab页的用例数量统计闪现数据不对 https://www.tapd.cn/55049933/s/1365416
This commit is contained in:
parent
e342f4fc61
commit
d69f01be2a
|
@ -292,10 +292,7 @@ export default {
|
|||
return hasPermissions(permission[0]);
|
||||
},
|
||||
init() {
|
||||
let num = 0;
|
||||
this.treeNodes.forEach(t => {
|
||||
num += t.caseNum;
|
||||
});
|
||||
let num = this.getTotalCount();
|
||||
this.extendTreeNodes = [];
|
||||
this.extendTreeNodes.unshift({
|
||||
"id": "root",
|
||||
|
@ -308,6 +305,31 @@ export default {
|
|||
this.expandedNode.push("root");
|
||||
}
|
||||
},
|
||||
getTotalCount() {
|
||||
let num = 0;
|
||||
this.treeNodes.forEach(t => {
|
||||
num += t.caseNum;
|
||||
});
|
||||
return num;
|
||||
},
|
||||
updateNodeCount(countMap) {
|
||||
// countMap 是对应模块下的用例数,这里根据模块的层级结构,计算模块及其子模块的用例数
|
||||
this.doUpdateNodeCount(this.treeNodes, countMap);
|
||||
// 更新 root 节点,用例数量
|
||||
this.$refs.tree.root.childNodes[0].data.caseNum = this.getTotalCount();
|
||||
},
|
||||
doUpdateNodeCount(treeNodes, countMap) {
|
||||
treeNodes.forEach(item => {
|
||||
let children = item.children;
|
||||
if (children && children.length > 0) {
|
||||
this.doUpdateNodeCount(children, countMap);
|
||||
item.caseNum = countMap[item.id] + children.map(i => i.caseNum)
|
||||
.reduce((pre, curr) => pre + curr, 0);
|
||||
} else {
|
||||
item.caseNum = countMap[item.id];
|
||||
}
|
||||
});
|
||||
},
|
||||
handleNodeSelect(node) {
|
||||
let nodeIds = [];
|
||||
let pNodes = [];
|
||||
|
|
|
@ -44,7 +44,15 @@ public class TestCaseNodeController {
|
|||
projectId = request.getProjectId();
|
||||
}
|
||||
baseCheckPermissionService.checkProjectOwner(projectId);
|
||||
return testCaseNodeService.getNodeTreeByProjectId(projectId, Optional.ofNullable(request).orElse(new QueryTestCaseRequest()));
|
||||
return testCaseNodeService.getNodeTreeByProjectId(projectId,
|
||||
Optional.ofNullable(request).orElse(new QueryTestCaseRequest()));
|
||||
}
|
||||
|
||||
@PostMapping("/count/{projectId}")
|
||||
public Map<String, Integer> getNodeCountMapByProjectId(@PathVariable String projectId, @RequestBody(required = false) QueryTestCaseRequest request) {
|
||||
baseCheckPermissionService.checkProjectOwner(projectId);
|
||||
return testCaseNodeService.getNodeCountMapByProjectId(projectId,
|
||||
Optional.ofNullable(request).orElse(new QueryTestCaseRequest()));
|
||||
}
|
||||
|
||||
@PostMapping("/minder/extraNode/count")
|
||||
|
|
|
@ -18,7 +18,6 @@ import io.metersphere.commons.utils.CommonBeanFactory;
|
|||
import io.metersphere.commons.utils.JSON;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.dto.NodeNumDTO;
|
||||
import io.metersphere.dto.TestCaseDTO;
|
||||
import io.metersphere.dto.TestCaseNodeDTO;
|
||||
import io.metersphere.dto.TestPlanCaseDTO;
|
||||
import io.metersphere.exception.ExcelException;
|
||||
|
@ -225,11 +224,27 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
|||
request.setProjectId(projectId);
|
||||
request.setUserId(SessionUtils.getUserId());
|
||||
request.setNodeIds(null);
|
||||
request.setOrders(null);
|
||||
ServiceUtils.buildCombineTagsToSupportMultiple(request);
|
||||
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||
List<TestCaseNodeDTO> countMNodes = extTestCaseMapper.getCountNodes(request);
|
||||
List<TestCaseNodeDTO> countNodes = extTestCaseMapper.getCountNodes(request);
|
||||
List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(projectId);
|
||||
return getNodeTrees(testCaseNodes, getCountMap(countMNodes));
|
||||
return getNodeTrees(testCaseNodes, getCountMap(countNodes));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Map<String, Integer> getNodeCountMapByProjectId(String projectId, QueryTestCaseRequest request) {
|
||||
request.setProjectId(projectId);
|
||||
request.setUserId(SessionUtils.getUserId());
|
||||
request.setNodeIds(null);
|
||||
request.setOrders(null);
|
||||
ServiceUtils.buildCombineTagsToSupportMultiple(request);
|
||||
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||
List<TestCaseNodeDTO> countNodes = extTestCaseMapper.getCountNodes(request);
|
||||
Map<String, Integer> countMap = getCountMap(countNodes);
|
||||
countMap.remove(null); // 脏数据,没有模块 ID 的会有 null 的清空
|
||||
return countMap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -193,6 +193,10 @@ export function getTestCaseNodesByCaseFilter(projectId, param) {
|
|||
return post('/case/node/list/' + projectId, param);
|
||||
}
|
||||
|
||||
export function getTestCaseNodesCountMap(projectId, param) {
|
||||
return post('/case/node/count/' + projectId, param);
|
||||
}
|
||||
|
||||
export function getTestPlanCaseNodesByCaseFilter(planId, param) {
|
||||
return post('/case/node/list/plan/' + planId, param);
|
||||
}
|
||||
|
|
|
@ -840,29 +840,11 @@ export default {
|
|||
item.customFields = JSON.parse(item.customFields);
|
||||
}
|
||||
});
|
||||
this.updateTestCaseNodeCount();
|
||||
});
|
||||
this.$emit("getTrashList");
|
||||
this.$emit("getPublicList")
|
||||
}
|
||||
},
|
||||
// 如果在其他tab页创建用例,会导致模块数量显示和列表不一致,这里重新更新下模块的用例数
|
||||
updateTestCaseNodeCount() {
|
||||
if (this.selectNode && this.treeNodes && this.selectNode.data
|
||||
&& this.selectNode.data.caseNum !== this.page.total) {
|
||||
|
||||
let updateCount = this.page.total - this.selectNode.data.caseNum;
|
||||
let node = this.selectNode;
|
||||
this.selectNode.data.caseNum = this.page.total;
|
||||
while (node) {
|
||||
node = node.parent;
|
||||
if (node && node.data) {
|
||||
node.data.caseNum += updateCount;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
search() {
|
||||
this.refreshBySearch = true;
|
||||
// 添加搜索条件时,当前页设置成第一页
|
||||
|
|
|
@ -50,7 +50,7 @@ import MsSearchBar from "metersphere-frontend/src/components/new-ui/MsSearchBar"
|
|||
import {buildTree, buildNodePath} from "metersphere-frontend/src/model/NodeTree";
|
||||
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
|
||||
import ModuleTrashButton from "metersphere-frontend/src/components/ModuleTrashButton";
|
||||
import {getTestCaseNodesByCaseFilter} from "@/api/testCase";
|
||||
import {getTestCaseNodesByCaseFilter, getTestCaseNodesCountMap} from "@/api/testCase";
|
||||
import IsChangeConfirm from "metersphere-frontend/src/components/IsChangeConfirm";
|
||||
import ModulePublicButton from "metersphere-frontend/src/components/module/ModulePublicButton";
|
||||
import {useStore} from "@/store";
|
||||
|
@ -296,8 +296,16 @@ export default {
|
|||
this.currentNode = node;
|
||||
|
||||
this.$emit("nodeSelectEvent", node, node.data.id === 'root' ? [] : nodeIds, pNodes);
|
||||
// 只在TAB页切换时才刷新树
|
||||
// this.nohupReloadTree(node.data.id);
|
||||
// 刷新模块用例数
|
||||
this.updateNodeCount();
|
||||
},
|
||||
updateNodeCount() {
|
||||
getTestCaseNodesCountMap(this.projectId, this.caseCondition)
|
||||
.then((r) => {
|
||||
if (this.$refs.nodeTree) {
|
||||
this.$refs.nodeTree.updateNodeCount(r.data);
|
||||
}
|
||||
});
|
||||
},
|
||||
nohupReloadTree(selectNodeId) {
|
||||
if (this.projectId) {
|
||||
|
|
Loading…
Reference in New Issue