fix(接口测试): 修复接口定义左侧树不展示统计数的缺陷

--bug=1011526 --user=王孝刚
【接口测试】-接口定义中-导入的接口模块默认全部为空了+左侧更多操作中创建接口后默认模块是空,以上两种情况导致左侧树不统计接口数量
https://www.tapd.cn/55049933/s/1123106
This commit is contained in:
wxg0103 2022-03-22 11:08:38 +08:00 committed by fit2-zhao
parent 7e60bbfeba
commit 0e1e9db48f
26 changed files with 28 additions and 113 deletions

View File

@ -1314,7 +1314,7 @@ public class ApiAutomationService {
private void replenishScenarioModuleIdPath(String request, ApiScenarioModuleMapper apiScenarioModuleMapper, ApiScenarioWithBLOBs item) {
ApiScenarioModuleExample example = new ApiScenarioModuleExample();
example.createCriteria().andProjectIdEqualTo(request).andNameEqualTo("UNPLANNED");
example.createCriteria().andProjectIdEqualTo(request).andNameEqualTo("未规划场景");
List<ApiScenarioModule> modules = apiScenarioModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) {
item.setApiScenarioModuleId(modules.get(0).getId());

View File

@ -1114,7 +1114,7 @@ public class ApiDefinitionService {
private void setModule(ApiDefinitionWithBLOBs item) {
if (item != null && StringUtils.isEmpty(item.getModuleId()) || "default-module".equals(item.getModuleId())) {
ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo("UNPLANNED");
example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo("未规划接口");
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) {
item.setModuleId(modules.get(0).getId());
@ -2031,7 +2031,7 @@ public class ApiDefinitionService {
public void initModulePathAndId(String projectId, ApiDefinitionWithBLOBs test) {
ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(test.getProtocol()).andNameEqualTo("UNPLANNED");
example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(test.getProtocol()).andNameEqualTo("未规划接口");
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) {
test.setModuleId(modules.get(0).getId());

View File

@ -527,12 +527,12 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
public ApiModule getDefaultNode(String projectId,String protocol) {
ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo("UNPLANNED").andParentIdIsNull();
example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo("未规划接口").andParentIdIsNull();
List<ApiModule> list = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isEmpty(list)) {
ApiModule record = new ApiModule();
record.setId(UUID.randomUUID().toString());
record.setName("UNPLANNED");
record.setName("未规划接口");
record.setProtocol(protocol);
record.setPos(1.0);
record.setLevel(1);
@ -549,7 +549,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
public ApiModule getDefaultNodeUnCreateNew(String projectId,String protocol) {
ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo("UNPLANNED").andParentIdIsNull();
example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo("未规划接口").andParentIdIsNull();
List<ApiModule> list = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isEmpty(list)) {
return null;

View File

@ -454,12 +454,12 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
public ApiScenarioModule getDefaultNode(String projectId) {
ApiScenarioModuleExample example = new ApiScenarioModuleExample();
example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo("UNPLANNED").andParentIdIsNull();
example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo("未规划场景").andParentIdIsNull();
List<ApiScenarioModule> list = apiScenarioModuleMapper.selectByExample(example);
if (CollectionUtils.isEmpty(list)) {
ApiScenarioModule record = new ApiScenarioModule();
record.setId(UUID.randomUUID().toString());
record.setName("UNPLANNED");
record.setName("未规划场景");
record.setPos(1.0);
record.setLevel(1);
record.setCreateTime(System.currentTimeMillis());

View File

@ -121,13 +121,13 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
public TestCaseNode getDefaultNode(String projectId) {
TestCaseNodeExample example = new TestCaseNodeExample();
example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo("UNPLANNED").andParentIdIsNull();
example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo("未规划用例").andParentIdIsNull();
List<TestCaseNode> list = testCaseNodeMapper.selectByExample(example);
if (CollectionUtils.isEmpty(list)) {
NodeNumDTO record = new NodeNumDTO();
record.setId(UUID.randomUUID().toString());
record.setCreateUser(SessionUtils.getUserId());
record.setName("UNPLANNED");
record.setName("未规划用例");
record.setPos(1.0);
record.setLevel(1);
record.setCreateTime(System.currentTimeMillis());
@ -420,7 +420,6 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
Iterator<String> itemIterator = nodeNameList.iterator();
Boolean hasNode = false;
String rootNodeName;
String path;
if (nodeNameList.size() <= 1) {
throw new ExcelException(Translator.get("test_case_create_module_fail") + ":" + item);
@ -428,16 +427,11 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
itemIterator.next();
itemIterator.remove();
rootNodeName = itemIterator.next().trim();
path = "/" + rootNodeName;
if (StringUtils.equals(rootNodeName, Translator.get("unplanned_case"))) {
rootNodeName = "UNPLANNED";
path = "/未规划用例";
}
//原来没有新建的树nodeTrees也不包含
for (TestCaseNodeDTO nodeTree : nodeTrees) {
if (StringUtils.equals(rootNodeName, nodeTree.getName())) {
hasNode = true;
createNodeByPathIterator(itemIterator, path, nodeTree,
createNodeByPathIterator(itemIterator, "/" + rootNodeName, nodeTree,
pathMap, projectId, 2);
}
}
@ -696,9 +690,6 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
TestCaseNode testCaseNode = testCaseNodeMapper.selectByPrimaryKey(moduleId);
LinkedList<TestCaseNode> returnList = new LinkedList<>();
if (StringUtils.equals(testCaseNode.getName(), "UNPLANNED")) {
testCaseNode.setName("未规划用例");
}
while (testCaseNode != null) {
returnList.addFirst(testCaseNode);
if (testCaseNode.getParentId() == null) {

View File

@ -168,7 +168,7 @@ public class TestCaseService {
private void setNode(TestCaseWithBLOBs testCase) {
if (StringUtils.isEmpty(testCase.getNodeId()) || "default-module".equals(testCase.getNodeId())) {
TestCaseNodeExample example = new TestCaseNodeExample();
example.createCriteria().andProjectIdEqualTo(testCase.getProjectId()).andNameEqualTo("UNPLANNED");
example.createCriteria().andProjectIdEqualTo(testCase.getProjectId()).andNameEqualTo("未规划用例");
List<TestCaseNode> nodes = testCaseNodeMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(nodes)) {
testCase.setNodeId(nodes.get(0).getId());

View File

@ -65,7 +65,7 @@ public class TestCaseXmindData {
}
}
if (!matching) {
TestCaseXmindData child = new TestCaseXmindData(caseNode.getId(), dataList.get(0).getNodePath());
TestCaseXmindData child = new TestCaseXmindData(caseNode.getId(), caseNode.getName());
child.setTestCaseList(dataList);
this.children.add(child);
}

View File

@ -685,18 +685,3 @@ from api_scenario_report
where report_type = 'API_INTEGRATED';
ALTER TABLE api_definition MODIFY COLUMN path varchar (1000);
update api_scenario_module
set name = 'UNPLANNED'
where name = '未规划场景'
and `level` = 1;
update api_module
set name = 'UNPLANNED'
where name = '未规划接口'
and `level` = 1;
update test_case_node
set name = 'UNPLANNED'
where name = '未规划用例'
and `level` = 1;

View File

@ -309,5 +309,3 @@ error_code_is_unique=Error code is not unique
no_version_exists=version not exists
jira_auth_error=Account name or password (Token) is wrong
unplanned_case=Unplanned Case

View File

@ -307,5 +307,3 @@ issue_jira_info_error=请检查服务集成信息或Jira项目ID
error_code_is_unique=错误代码不可重复
no_version_exists=不存在版本!请先创建项目的版本
jira_auth_error=账号名或密码(Token)错误
unplanned_case=未规划用例

View File

@ -308,5 +308,3 @@ error_code_is_unique=錯誤代碼不可重複
no_version_exists=不存在版本!請先創建項目的版本
jira_auth_error=賬號名或密碼(Token)錯誤
unplanned_case=未規劃用例

View File

@ -186,14 +186,8 @@
if (response.data != undefined && response.data != null) {
this.data = response.data;
this.data.forEach(node => {
node.name = node.name === 'UNPLANNED' ? this.$t('api_test.automation.unplanned_scenario') : node.name
node.label = node.label === 'UNPLANNED' ? this.$t('api_test.automation.unplanned_scenario') : node.label
node.name = node.name === '未规划场景' ? this.$t('api_test.automation.unplanned_scenario') : node.name
buildTree(node, {path: ''});
if (node.children && node.children.length > 0) {
node.children.forEach(node => {
node.name = node.name === 'UNPLANNED' ? this.$t('api_test.automation.unplanned_scenario') : node.name
})
}
});
this.$emit('setModuleOptions', this.data);
this.$emit('setNodeTree', this.data);

View File

@ -179,14 +179,8 @@ export default {
if (response.data != undefined && response.data != null) {
this.data = response.data;
this.data.forEach(node => {
node.name = node.name === 'UNPLANNED' ? this.$t('api_test.definition.unplanned_api') : node.name;
node.label = node.label === 'UNPLANNED' ? this.$t('api_test.definition.unplanned_api') : node.label
node.name = node.name === '未规划接口' ? this.$t('api_test.definition.unplanned_api') : node.name
buildTree(node, {path: ''});
if (node.children && node.children.length > 0) {
node.children.forEach(node => {
node.name = node.name === 'UNPLANNED' ? this.$t('api_test.definition.unplanned_api') : node.name
})
}
});
this.$emit('setModuleOptions', this.data);
this.$emit('setNodeTree', this.data);

View File

@ -755,9 +755,6 @@ export default {
param.nodeId = this.form.module;
if (!this.publicEnable) {
param.nodePath = getNodePath(this.form.module, this.moduleOptions);
if (param.nodePath === '/未规划用例' || param.nodePath === '/Unplanned Case' || param.nodePath === '/未規劃用例') {
param.nodePath = '/未规划用例';
}
if (this.projectId) {
param.projectId = this.projectId;
}

View File

@ -775,7 +775,6 @@ export default {
this.page.total = data.itemCount;
this.page.data = data.listObject;
this.page.data.forEach(item => {
(item.nodePath === '/未规划用例' || item.nodePath === '/Unplanned Case' || item.nodePath === '/未規劃用例') ? item.nodePath = "/" + this.$t('test_track.unplanned_case') : item.nodePath
if (item.customFields) {
item.customFields = JSON.parse(item.customFields);
}

View File

@ -9,7 +9,7 @@
:delete-permission="['PROJECT_TRACK_CASE:READ+DELETE']"
:add-permission="['PROJECT_TRACK_CASE:READ+CREATE']"
:update-permission="['PROJECT_TRACK_CASE:READ+EDIT']"
:default-label="$t('test_track.unplanned_case')"
:default-label="$t('api_test.unplanned_case')"
@add="add"
@edit="edit"
@drag="drag"
@ -175,8 +175,7 @@ export default {
this.result = getTestCaseNodes(this.projectId, data => {
this.treeNodes = data;
this.treeNodes.forEach(node => {
node.name === 'UNPLANNED' ? node.name = this.$t('test_track.unplanned_case') : node.name;
node.label === 'UNPLANNED' ? node.label = this.$t('test_track.unplanned_case') : node.label;
node.name = node.name === '未规划用例' ? this.$t('api_test.unplanned_case') : node.name
buildTree(node, {path: ''});
});
this.setModuleOptions();
@ -253,7 +252,6 @@ export default {
setModuleOptions() {
let moduleOptions = [];
this.treeNodes.forEach(node => {
node.name === 'UNPLANNED' ? node.name = this.$t('test_track.unplanned_case') : node.name
buildNodePath(node, {path: ''}, moduleOptions);
});
this.$store.commit('setTestCaseModuleOptions', moduleOptions);

View File

@ -147,13 +147,6 @@ export default {
}
this.result = this.$get(url, response => {
this.treeNodes = response.data;
this.treeNodes.forEach(nodes => {
if (nodes.children && nodes.children.length > 0) {
nodes.children.forEach(node => {
node.name = node.name === 'UNPLANNED' ? this.$t('test_track.unplanned_case') : node.name
})
}
});
});
}
},

View File

@ -87,9 +87,6 @@ export default {
vueObj.$refs.nodeTree.result = this.$post("/case/node/list/all/plan",
{testPlanId: this.planId, projectId: vueObj.projectId}, response => {
vueObj.treeNodes = response.data;
vueObj.treeNodes.forEach(node => {
node.name = node.name === 'UNPLANNED' ? this.$t('test_track.unplanned_case') : node.name
});
});
vueObj.selectNodeIds = [];
}

View File

@ -282,9 +282,6 @@ export default {
};
this.result = this.$post("/case/node/list/all/plan", param, response => {
this.treeNodes = response.data;
this.treeNodes.forEach(node => {
node.name = node.name === 'UNPLANNED' ? this.$t('test_track.unplanned_case') : node.name
});
});
}
},

View File

@ -156,13 +156,6 @@ export default {
if (this.reviewId) {
this.result = this.$get("/case/node/list/review/" + this.reviewId, response => {
this.treeNodes = response.data;
this.treeNodes.forEach(nodes => {
if (nodes.children && nodes.children.length > 0) {
nodes.children.forEach(node => {
node.name = node.name === 'UNPLANNED' ? this.$t('test_track.unplanned_case') : node.name
})
}
});
});
}
},

View File

@ -134,13 +134,6 @@ export default {
if (this.reviewId) {
this.result = this.$get("/case/node/list/review/" + this.reviewId, response => {
this.treeNodes = response.data;
this.treeNodes.forEach(nodes => {
if (nodes.children && nodes.children.length > 0) {
nodes.children.forEach(node => {
node.name = node.name === 'UNPLANNED' ? this.$t('test_track.unplanned_case') : node.name
})
}
});
});
}
},

View File

@ -92,13 +92,6 @@ export default {
if (this.planId) {
this.result = this.$get("/case/node/list/plan/" + this.planId, response => {
this.treeNodes = response.data;
this.treeNodes.forEach(nodes => {
if (nodes.children && nodes.children.length > 0) {
nodes.children.forEach(node => {
node.name = node.name === 'UNPLANNED' ? this.$t('test_track.unplanned_case') : node.name
})
}
});
//
this.treeNodes.map(node => node.children = null);
});

View File

@ -364,9 +364,6 @@ export default {
this.result = this.$post("/case/node/list/all/review",
{reviewId: this.reviewId, projectId: this.projectId}, response => {
this.treeNodes = response.data;
this.treeNodes.forEach(node => {
node.name = node.name === 'UNPLANNED' ? this.$t('test_track.unplanned_case') : node.name
});
});
this.selectNodeIds = [];
},

View File

@ -328,7 +328,7 @@ export default {
monitor: "Monitor",
all_label: {
case: "All Case",
review: "All Review"
review: "all"
},
image: 'Image',
tag: 'Tag',
@ -1114,6 +1114,7 @@ export default {
copied: "copied",
key: "Key",
value: "Value",
unplanned_case: "Unplanned Case",
create_performance_test: "Create Performance Test",
create_performance_test_batch: "Batch Create Performance Test",
batch_copy: "Batch Copy",
@ -1350,9 +1351,9 @@ export default {
reference_info: "Reference info",
scenario_test: "Scenario test",
scenario_list: "Scenario List",
all_scenario: 'All Scenario',
unplanned_scenario: 'Unplanned Scenario',
add_scenario: "Add scenario",
all_scenario: "All scenario",
unplanned_scenario: "Unplanned Scenario",
scenario_name: "Scenario Name",
case_level: "Case Level",
tag: "Tag",
@ -1939,7 +1940,6 @@ export default {
date: "Date"
},
test_track: {
unplanned_case: 'Unplanned Case',
sync_add_api_load: 'Synchronously add associated api and load tests',
next: 'Next',
total_size: 'Total {0}',

View File

@ -1124,6 +1124,7 @@ export default {
create_performance_test_batch: "批量创建性能测试",
batch_copy: "批量复制",
export_config: "导出",
unplanned_case: "未规划用例",
enable_validate_tip: "没有可用请求",
copy: "复制测试",
please_select_case: "请选择用例",
@ -1355,9 +1356,9 @@ export default {
reference_info: "请选择接口或用例",
scenario_test: "场景",
scenario_list: "场景列表",
unplanned_scenario: '未规划场景',
all_scenario: '全部场景',
add_scenario: "创建场景",
all_scenario: "全部场景",
unplanned_scenario: "未规划场景",
scenario_name: "场景名称",
case_level: "用例等级",
tag: "标签",
@ -1944,7 +1945,6 @@ export default {
date: "日期"
},
test_track: {
unplanned_case: '未规划用例',
sync_add_api_load: '同步添加关联的接口和性能测试',
next: '下一条',
total_size: '共 {0} 条',

View File

@ -1125,6 +1125,7 @@ export default {
batch_copy: "批量復製",
export_config: "導出",
enable_validate_tip: "沒有可用請求",
unplanned_case: "未規劃用例",
copy: "復製測試",
please_select_case: "請選擇用例",
fail_to_stop: "失敗停止",
@ -1355,9 +1356,9 @@ export default {
reference_info: "請選擇接口或用例",
scenario_test: "場景",
scenario_list: "場景列表",
all_scenario: '全部場景',
unplanned_scenario: '未規劃場景',
add_scenario: "創建場景",
all_scenario: "全部場景",
unplanned_scenario: "未規劃場景",
scenario_name: "場景名稱",
case_level: "用例等級",
tag: "標簽",
@ -1944,7 +1945,6 @@ export default {
date: "日期"
},
test_track: {
unplanned_case: '未規劃用例',
sync_add_api_load: '同步添加關聯的接口和性能測試',
next: '下一條',
total_size: '共 {0} 條',