fix: 测试用例支持在脑图中调整顺序
This commit is contained in:
parent
a96a6e93f8
commit
a3c7dbde7f
|
@ -11,5 +11,12 @@ import java.util.List;
|
|||
public class TestCaseMinderEditRequest {
|
||||
private String projectId;
|
||||
private List<String> ids;
|
||||
List<TestCaseWithBLOBs> data;
|
||||
List<TestCaseMinderEditItem> data;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class TestCaseMinderEditItem extends TestCaseWithBLOBs {
|
||||
private String targetId;
|
||||
private String moveMode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1427,7 +1427,7 @@ public class TestCaseService {
|
|||
}
|
||||
|
||||
public void minderEdit(TestCaseMinderEditRequest request) {
|
||||
List<TestCaseWithBLOBs> data = request.getData();
|
||||
List<TestCaseMinderEditRequest.TestCaseMinderEditItem> data = request.getData();
|
||||
if (CollectionUtils.isNotEmpty(data)) {
|
||||
List<String> editIds = data.stream()
|
||||
.filter(t -> StringUtils.isNotBlank(t.getId()) && t.getId().length() > 20)
|
||||
|
@ -1451,12 +1451,14 @@ public class TestCaseService {
|
|||
item.setId(UUID.randomUUID().toString());
|
||||
item.setMaintainer(SessionUtils.getUserId());
|
||||
addTestCase(item);
|
||||
changeOrder(item, request.getProjectId());
|
||||
} else {
|
||||
TestCaseWithBLOBs dbCase = finalTestCaseMap.get(item.getId());
|
||||
if (editCustomFieldsPriority(dbCase, item.getPriority())) {
|
||||
item.setCustomFields(dbCase.getCustomFields());
|
||||
}
|
||||
editTestCase(item);
|
||||
changeOrder(item, request.getProjectId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1468,6 +1470,17 @@ public class TestCaseService {
|
|||
}
|
||||
}
|
||||
|
||||
private void changeOrder(TestCaseMinderEditRequest.TestCaseMinderEditItem item, String projectId) {
|
||||
if (StringUtils.isNotBlank(item.getTargetId())) {
|
||||
ResetOrderRequest resetOrderRequest = new ResetOrderRequest();
|
||||
resetOrderRequest.setGroupId(projectId);
|
||||
resetOrderRequest.setMoveId(item.getId());
|
||||
resetOrderRequest.setTargetId(item.getTargetId());
|
||||
resetOrderRequest.setMoveMode(item.getMoveMode());
|
||||
updateOrder(resetOrderRequest);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 脑图编辑之后修改用例等级,同时修改自定义字段的用例等级
|
||||
*
|
||||
|
|
|
@ -131,7 +131,7 @@ name: "TestCaseMinder",
|
|||
let saveCases = [];
|
||||
let deleteCases = []; // 包含测试用例和临时节点
|
||||
let saveExtraNode = {};
|
||||
this.buildSaveCase(data.root, saveCases, deleteCases, saveExtraNode, undefined);
|
||||
this.buildSaveCase(data.root, saveCases, deleteCases, saveExtraNode);
|
||||
|
||||
let param = {
|
||||
projectId: this.projectId,
|
||||
|
@ -166,10 +166,10 @@ name: "TestCaseMinder",
|
|||
this.setIsChange(false);
|
||||
});
|
||||
},
|
||||
buildSaveCase(root, saveCases, deleteCases, saveExtraNode, parent) {
|
||||
buildSaveCase(root, saveCases, deleteCases, saveExtraNode, parent, preNode, nextNode) {
|
||||
let data = root.data;
|
||||
if (data.resource && data.resource.indexOf(this.$t('api_test.definition.request.case')) > -1) {
|
||||
this._buildSaveCase(root, saveCases, deleteCases, parent);
|
||||
this._buildSaveCase(root, saveCases, deleteCases, parent, preNode, nextNode);
|
||||
} else {
|
||||
let deleteChild = data.deleteChild;
|
||||
if (deleteChild && deleteChild.length > 0
|
||||
|
@ -194,13 +194,22 @@ name: "TestCaseMinder",
|
|||
throw new Error(tip);
|
||||
}
|
||||
if (root.children) {
|
||||
root.children.forEach((childNode) => {
|
||||
this.buildSaveCase(childNode, saveCases, deleteCases, saveExtraNode, root.data);
|
||||
});
|
||||
for (let i = 0; i < root.children.length; i++) {
|
||||
let childNode = root.children[i];
|
||||
let preNode = null;
|
||||
let nextNode = null;
|
||||
if (i != 0) {
|
||||
preNode = root.children[i - 1];
|
||||
}
|
||||
if (i + 1 < root.children.length) {
|
||||
nextNode = root.children[i + 1];
|
||||
}
|
||||
this.buildSaveCase(childNode, saveCases, deleteCases, saveExtraNode, root.data, preNode, nextNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
_buildSaveCase(node, saveCases, deleteCases, parent) {
|
||||
_buildSaveCase(node, saveCases, deleteCases, parent, preNode, nextNode) {
|
||||
let data = node.data;
|
||||
if (!data.text) {
|
||||
return;
|
||||
|
@ -264,7 +273,24 @@ name: "TestCaseMinder",
|
|||
})
|
||||
}
|
||||
testCase.steps = JSON.stringify(steps);
|
||||
|
||||
if (isChange) {
|
||||
|
||||
testCase.targetId = null; // 排序处理
|
||||
if (preNode) {
|
||||
let preId = preNode.data.id;
|
||||
if (preId && preId.length > 15) {
|
||||
testCase.targetId = preId;
|
||||
testCase.moveMode = 'AFTER';
|
||||
}
|
||||
} else if (nextNode) {
|
||||
let nextId = nextNode.data.id;
|
||||
if (nextId && nextId.length > 15) {
|
||||
testCase.targetId = nextId;
|
||||
testCase.moveMode = 'BEFORE';
|
||||
}
|
||||
}
|
||||
|
||||
saveCases.push(testCase);
|
||||
}
|
||||
if (testCase.nodeId !== 'root' && testCase.nodeId.length < 15) {
|
||||
|
|
Loading…
Reference in New Issue