refactor(测试计划&测试用例): 修改执行和评审脑图判断用例节点的方式
This commit is contained in:
parent
99221b0673
commit
85d098646e
|
@ -182,7 +182,6 @@
|
|||
UNDER_REVIEWED: t('caseManagement.caseReview.reviewing'),
|
||||
RE_REVIEWED: t('caseManagement.caseReview.reReview'),
|
||||
};
|
||||
const caseTag = t('common.case');
|
||||
const moduleTag = t('common.module');
|
||||
const importJson = ref<MinderJson>({
|
||||
root: {} as MinderJsonNode,
|
||||
|
@ -262,6 +261,9 @@
|
|||
initCaseTree();
|
||||
});
|
||||
|
||||
function isCaseTag(data?: MinderJsonNodeData) {
|
||||
return data?.caseId?.length;
|
||||
}
|
||||
/**
|
||||
* 加载模块节点下的用例节点
|
||||
* @param node 选中节点
|
||||
|
@ -437,7 +439,7 @@
|
|||
extraVisible.value = val !== undefined ? val : !extraVisible.value;
|
||||
const node: MinderJsonNode = window.minder.getSelectedNode();
|
||||
const { data } = node;
|
||||
if (extraVisible.value && data?.resource?.includes(caseTag)) {
|
||||
if (extraVisible.value && data && isCaseTag(data)) {
|
||||
activeExtraKey.value = 'history';
|
||||
initCaseDetail(data);
|
||||
initReviewHistoryList(data);
|
||||
|
@ -490,8 +492,8 @@
|
|||
function handleReviewDone(status: StartReviewStatus | ReviewResult) {
|
||||
const node = window.minder.getSelectedNode();
|
||||
reviewVisible.value = false;
|
||||
if (status !== 'UN_REVIEWED' && node.data?.resource?.includes(caseTag)) {
|
||||
window.minder.execCommand('resource', [statusTagMap[status], caseTag]);
|
||||
if (status !== 'UN_REVIEWED' && isCaseTag(node.data)) {
|
||||
window.minder.execCommand('resource', [statusTagMap[status]]);
|
||||
} else if (status !== StartReviewStatus.UNDER_REVIEWED && node.data?.resource?.includes(moduleTag)) {
|
||||
// 先清空子节点,从后向前遍历时,删除节点不会影响到尚未遍历的节点
|
||||
for (let i = node.children.length - 1; i >= 0; i--) {
|
||||
|
@ -506,8 +508,8 @@
|
|||
// 递归更新子节点的用例标签
|
||||
function updateChildResources(status: string, node?: MinderJsonNode) {
|
||||
node?.children?.forEach((child: MinderJsonNode) => {
|
||||
if (child.data?.resource?.includes(caseTag)) {
|
||||
child.setData('resource', [statusTagMap[status], caseTag]).render();
|
||||
if (isCaseTag(child.data)) {
|
||||
child.setData('resource', [statusTagMap[status]]).render();
|
||||
} else if (child.data?.resource?.includes(moduleTag)) {
|
||||
updateChildResources(status, child);
|
||||
}
|
||||
|
@ -518,8 +520,8 @@
|
|||
function updateResource(status: string) {
|
||||
if (selectNode.value.data?.resource?.includes(moduleTag)) {
|
||||
updateChildResources(status, selectNode.value);
|
||||
} else if (selectNode.value.data?.resource?.includes(caseTag)) {
|
||||
window.minder.execCommand('resource', [statusTagMap[status], caseTag]);
|
||||
} else if (isCaseTag(selectNode.value.data)) {
|
||||
window.minder.execCommand('resource', [statusTagMap[status]]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -549,7 +551,7 @@
|
|||
|
||||
// 展示浮动菜单: 模块节点且有子节点且不是没权限的根结点、用例节点
|
||||
if (
|
||||
node.data?.resource?.includes(caseTag) ||
|
||||
isCaseTag(node.data) ||
|
||||
(node.data?.resource?.includes(moduleTag) &&
|
||||
(node.children || []).length > 0 &&
|
||||
!(!hasOperationPermission && node.type === 'root'))
|
||||
|
@ -563,7 +565,7 @@
|
|||
reviewVisible.value = false;
|
||||
|
||||
// 不展示更多:没操作权限的用例
|
||||
if (node.data?.resource?.includes(caseTag) && !hasOperationPermission) {
|
||||
if (isCaseTag(node.data) && !hasOperationPermission) {
|
||||
canShowMoreMenu.value = false;
|
||||
} else {
|
||||
canShowMoreMenu.value = true;
|
||||
|
@ -582,7 +584,7 @@
|
|||
isReviewer.value = false;
|
||||
}
|
||||
|
||||
if (data?.resource?.includes(caseTag)) {
|
||||
if (isCaseTag(data)) {
|
||||
canShowDetail.value = true;
|
||||
setIsReviewer(node.data);
|
||||
if (extraVisible.value) {
|
||||
|
|
|
@ -287,7 +287,7 @@
|
|||
const minderStore = useMinderStore();
|
||||
const testPlanFeatureCaseStore = useTestPlanFeatureCaseStore();
|
||||
|
||||
const { caseTag, moduleTag, stepTag, stepExpectTag } = useMinderBaseApi({});
|
||||
const { moduleTag, stepTag, stepExpectTag } = useMinderBaseApi({});
|
||||
const actualResultTag = t('system.orgTemplate.actualResult');
|
||||
const importJson = ref<MinderJson>({
|
||||
root: {} as MinderJsonNode,
|
||||
|
@ -371,6 +371,10 @@
|
|||
}
|
||||
);
|
||||
|
||||
function isCaseTag(data?: MinderJsonNodeData) {
|
||||
return data?.caseId?.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载模块节点下的用例节点
|
||||
* @param node 选中节点
|
||||
|
@ -554,7 +558,7 @@
|
|||
extraVisible.value = val !== undefined ? val : !extraVisible.value;
|
||||
const node: MinderJsonNode = window.minder.getSelectedNode();
|
||||
const { data } = node;
|
||||
if (extraVisible.value && data?.resource?.includes(caseTag)) {
|
||||
if (extraVisible.value && data && isCaseTag(data)) {
|
||||
activeExtraKey.value = 'history';
|
||||
initExecuteHistory(data);
|
||||
initCaseDetail(data);
|
||||
|
@ -642,7 +646,7 @@
|
|||
}
|
||||
|
||||
function isActualResultNode(node: MinderJsonNode) {
|
||||
return node.data?.resource?.includes(actualResultTag) && node.parent?.data?.resource?.includes(caseTag);
|
||||
return node.data?.resource?.includes(actualResultTag) && isCaseTag(node.parent?.data);
|
||||
}
|
||||
|
||||
// 点击模块/用例/用例的实际结果执行
|
||||
|
@ -651,9 +655,9 @@
|
|||
const node = isActualResultNode(curSelectNode) ? curSelectNode.parent : curSelectNode;
|
||||
executeVisible.value = false;
|
||||
const resource = node.data?.resource;
|
||||
if (resource?.includes(caseTag)) {
|
||||
if (isCaseTag(node.data)) {
|
||||
// 用例添加标签
|
||||
node.setData('resource', [executionResultMap[status].statusText, caseTag]).render();
|
||||
node.setData('resource', [executionResultMap[status].statusText]).render();
|
||||
// 更新用例的实际结果节点
|
||||
updateCaseActualResultNode(node, content);
|
||||
// 更新执行历史
|
||||
|
@ -673,7 +677,7 @@
|
|||
|
||||
async function handleShortCutExecute(status: LastExecuteResults) {
|
||||
const selectedNodes: MinderJsonNode = window.minder.getSelectedNode();
|
||||
if (!selectedNodes?.data?.resource?.includes(caseTag)) return;
|
||||
if (!isCaseTag(selectedNodes?.data)) return;
|
||||
try {
|
||||
await batchExecuteCase({
|
||||
projectId: appStore.currentProjectId,
|
||||
|
@ -748,7 +752,7 @@
|
|||
*/
|
||||
function submitStepExecuteDone(status: string, content: string) {
|
||||
// 用例更新标签
|
||||
caseNodeAboveSelectStep.value.setData('resource', [executionResultMap[status].statusText, caseTag]).render();
|
||||
caseNodeAboveSelectStep.value.setData('resource', [executionResultMap[status].statusText]).render();
|
||||
// 更新用例的实际结果节点
|
||||
updateCaseActualResultNode(caseNodeAboveSelectStep.value, content);
|
||||
// 更新步骤数据:标签和实际结果
|
||||
|
@ -844,7 +848,7 @@
|
|||
if (node?.data?.resource?.includes(resource)) {
|
||||
return node.parent;
|
||||
}
|
||||
if (node.data?.resource?.includes(caseTag)) {
|
||||
if (isCaseTag(node.data)) {
|
||||
return null;
|
||||
}
|
||||
node = node.parent;
|
||||
|
@ -860,7 +864,7 @@
|
|||
};
|
||||
const selectedNodes: MinderJsonNode[] = window.minder.getSelectedNodes();
|
||||
selectedNodes.forEach((node) => {
|
||||
if (node.data?.resource?.includes(caseTag)) {
|
||||
if (isCaseTag(node?.data)) {
|
||||
batchMinderParams.value.minderCaseIds.push(node.data?.id || '');
|
||||
} else if (node.data?.type === 'PROJECT') {
|
||||
batchMinderParams.value.minderProjectIds.push(node.data?.id || '');
|
||||
|
@ -890,7 +894,7 @@
|
|||
|
||||
// 展示浮动菜单: 模块节点且有子节点且不是没权限的根结点、用例节点、用例节点下的实际结果
|
||||
if (
|
||||
node.data?.resource?.includes(caseTag) ||
|
||||
isCaseTag(node?.data) ||
|
||||
(node.data?.resource?.includes(moduleTag) &&
|
||||
(node.children || []).length > 0 &&
|
||||
!(!hasOperationPermission.value && node.type === 'root'))
|
||||
|
@ -918,7 +922,7 @@
|
|||
}
|
||||
|
||||
// 不展示更多:没操作权限的用例、用例节点下的实际结果
|
||||
if ((node.data?.resource?.includes(caseTag) && !hasOperationPermission.value) || isActualResultNode(node)) {
|
||||
if ((isCaseTag(node?.data) && !hasOperationPermission.value) || isActualResultNode(node)) {
|
||||
canShowMoreMenu.value = false;
|
||||
} else {
|
||||
canShowMoreMenu.value = true;
|
||||
|
@ -933,7 +937,7 @@
|
|||
|
||||
executeVisible.value = false;
|
||||
|
||||
if (data?.resource?.includes(caseTag)) {
|
||||
if (isCaseTag(data)) {
|
||||
canShowDetail.value = true;
|
||||
showAssociateBugMenu.value = true;
|
||||
if (extraVisible.value) {
|
||||
|
|
Loading…
Reference in New Issue