refactor(测试计划&测试用例): 修改执行和评审脑图判断用例节点的方式

This commit is contained in:
teukkk 2024-09-10 18:23:59 +08:00 committed by Craftsman
parent 99221b0673
commit 85d098646e
2 changed files with 29 additions and 23 deletions

View File

@ -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) {

View File

@ -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) {