From 352d1171ae16b8ca40eb83df8d3deceb2db18887 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 9 Aug 2022 18:03:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E8=84=91=E5=9B=BE=E8=AF=84=E5=AE=A1=E7=94=A8=E4=BE=8B,?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E6=9C=AA=E5=8A=A0=E8=BD=BD=E6=97=B6=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E8=AF=84=E5=AE=A1=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1015674 --user=陈建星 【测试跟踪】github #16680,用例评审-脑图批量评审- 用例状态未改变 https://www.tapd.cn/55049933/s/1220923 --- .../track/common/minder/TestPlanMinder.vue | 6 +- .../track/common/minder/TestReviewMinder.vue | 7 +- .../track/common/minder/minderUtils.js | 128 ++++++++++-------- 3 files changed, 84 insertions(+), 57 deletions(-) diff --git a/frontend/src/business/components/track/common/minder/TestPlanMinder.vue b/frontend/src/business/components/track/common/minder/TestPlanMinder.vue index 7031ac4a07..b9025be3e5 100644 --- a/frontend/src/business/components/track/common/minder/TestPlanMinder.vue +++ b/frontend/src/business/components/track/common/minder/TestPlanMinder.vue @@ -140,7 +140,11 @@ name: "TestPlanMinder", } }); - tagBatch([...this.tags, this.$t('test_track.plan.plan_status_prepare')]); + tagBatch([...this.tags, this.$t('test_track.plan.plan_status_prepare')], { + param: this.getParam(), + getCaseFuc: getPlanCasesForMinder, + setParamCallback: this.setParamCallback + }); addIssueHotBox(this); }, diff --git a/frontend/src/business/components/track/common/minder/TestReviewMinder.vue b/frontend/src/business/components/track/common/minder/TestReviewMinder.vue index 718f99e68c..c44b46a5d3 100644 --- a/frontend/src/business/components/track/common/minder/TestReviewMinder.vue +++ b/frontend/src/business/components/track/common/minder/TestReviewMinder.vue @@ -93,8 +93,11 @@ name: "TestReviewMinder", this.setIsChange(true); } }); - - tagBatch([...this.tags, this.$t('test_track.plan.plan_status_prepare')]); + tagBatch([...this.tags, this.$t('test_track.plan.plan_status_prepare')], { + param: this.getParam(), + getCaseFuc: getReviewCasesForMinder, + setParamCallback: this.setParamCallback + }); }, getParam() { return { diff --git a/frontend/src/business/components/track/common/minder/minderUtils.js b/frontend/src/business/components/track/common/minder/minderUtils.js index ffbca5301f..789598336c 100644 --- a/frontend/src/business/components/track/common/minder/minderUtils.js +++ b/frontend/src/business/components/track/common/minder/minderUtils.js @@ -51,47 +51,59 @@ export function getSelectedNodes() { * @param result */ export function loadNode(node, param, getCaseFuc, setParamCallback, getExtraNodeFuc) { - let data = node.data; - if (!data.loaded && data.type === 'node') { - if (param.result) { - param.result.loading = true; + return new Promise((resolve) => { + let data = node.data; + if (!data.loaded && data.type === 'node') { + if (param.result) { + param.result.loading = true; + } + let request = param.request; + request.nodeId = data.id; + if (data.id === 'root') { + request.nodeId = ''; + } + if (getCaseFuc) { + // 加载用例 + getCaseFuc(request, (testCases) => { + initNodeCase(node, testCases, param, setParamCallback); + if (getExtraNodeFuc) { + param.result.loading = true; + // 加载临时节点 + getExtraNodeFuc(getCurrentProjectID(), data.id, (nodes) => { + appendExtraNodes(node, nodes); + param.result.loading = false; + resolve(); + }); + } else { + resolve(); + } + }); + } else { + resolve(); + } + } else if (data.type === 'nextPage') { + // 分页处理,如果某个模块下用例太多,则分步加载 + if (param.result) { + param.result.loading = true; + } + let request = param.request; + request.nodeId = data.nodeId; + let minderPageInfo = minderPageInfoMap.get(request.nodeId); + minderPageInfo.pageNum++; + if (getCaseFuc) { + getCaseFuc(request, (testCases) => { + appendNodeCases(node.parent, testCases, param, setParamCallback); + window.minder.removeNode(node); + resolve(); + }); + } else { + resolve(); + } + } else { + resolve(); } - let request = param.request; - request.nodeId = data.id; - if (data.id === 'root') { - request.nodeId = ''; - } - if (getCaseFuc) { - getCaseFuc(request, (testCases) => { - initNodeCase(node, testCases, param, setParamCallback); - - if (getExtraNodeFuc) { - param.result.loading = true; - getExtraNodeFuc(getCurrentProjectID(), data.id, (nodes) => { - appendExtraNodes(node, nodes); - param.result.loading = false; - }); - } - - }); - } - } else if (data.type === 'nextPage') { - // 分页处理,如果某个模块下用例太多,则分步加载 - if (param.result) { - param.result.loading = true; - } - let request = param.request; - request.nodeId = data.nodeId; - let minderPageInfo = minderPageInfoMap.get(request.nodeId); - minderPageInfo.pageNum++; - if (getCaseFuc) { - getCaseFuc(request, (testCases) => { - appendNodeCases(node.parent, testCases, param, setParamCallback); - window.minder.removeNode(node); - }); - } - } - data.loaded = true; + data.loaded = true; + }); } /** @@ -167,41 +179,50 @@ export function handTestCaeEdit(data) { }); } -export function tagChildren(node, resourceName, distinctTags) { +export async function tagChildren(node, resourceName, distinctTags, loadNodeParam) { + + // 先加载当前模块下的用例再打标签 + if (isModuleNode(node)) { + await loadNode(node, loadNodeParam.param, + loadNodeParam.getCaseFuc, loadNodeParam.setParamCallback); + } + let children = node.children; if (!children) { children = []; } - if (!resourceName || !/\S/.test(resourceName)) {return;} - children.forEach((item) => { + + if (!resourceName || !/\S/.test(resourceName)) { + return; + } + + for (const item of children) { let isCaseNode = item.data.resource && item.data.resource.indexOf(i18n.t('api_test.definition.request.case')) > -1; if (item.data.type === 'node' || isCaseNode) { let origin = item.data.resource; if (!origin) { origin = []; } - let index = origin.indexOf(resourceName); // 先删除排他的标签 if (distinctTags.indexOf(resourceName) > -1) { for (let i = 0; i < origin.length; i++) { - if (distinctTags.indexOf(origin[i]) > -1) { + if (distinctTags.indexOf(origin[i]) > -1 && origin[i] !== resourceName) { origin.splice(i, 1); i--; } } } - if (index !== -1) { - origin.splice(index, 1); - } else { + if (origin.indexOf(resourceName) < 0) { origin.push(resourceName); } item.data.resource = origin; if (isCaseNode) { item.data.changed = true; } - tagChildren(item, resourceName, distinctTags); + await tagChildren(item, resourceName, distinctTags, loadNodeParam); } - }); + } + return; } @@ -424,20 +445,19 @@ function expandNode(node) { * 测试计划和评审支持给模块批量打标签 * @param distinctTags */ -export function tagBatch(distinctTags) { +export function tagBatch(distinctTags, loadNodeParam) { listenBeforeExecCommand((even) => { let minder = window.minder; let selectNodes = window.minder.getSelectedNodes(); let args = even.commandArgs; if (selectNodes) { - selectNodes.forEach((node) => { + selectNodes.forEach(async (node) => { if (node.data.type === 'node' && even.commandName === 'resource') { - // let origin = minder.queryCommandValue('resource'); if (args && args.length > 0) { let origin = args[0]; if (origin && origin.length > 0) { let resourceName = origin[0]; - tagChildren(node, resourceName, distinctTags); + await tagChildren(node, resourceName, distinctTags, loadNodeParam); let modifyTopNode = modifyParentNodeTag(node, resourceName); if (modifyTopNode) { modifyTopNode.renderTree();