fix(接口测试): 国际化

This commit is contained in:
wxg0103 2022-03-17 14:23:39 +08:00 committed by xiaomeinvG
parent 4198029cc7
commit 15ca194d79
19 changed files with 92 additions and 29 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("未规划场景");
example.createCriteria().andProjectIdEqualTo(request).andNameEqualTo("UNPLANNED");
List<ApiScenarioModule> modules = apiScenarioModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) {
item.setApiScenarioModuleId(modules.get(0).getId());

View File

@ -1108,7 +1108,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("未规划接口");
example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo("UNPLANNED");
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) {
item.setModuleId(modules.get(0).getId());
@ -2025,7 +2025,7 @@ public class ApiDefinitionService {
public void initModulePathAndId(String projectId, ApiDefinitionWithBLOBs test) {
ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(test.getProtocol()).andNameEqualTo("未规划接口");
example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(test.getProtocol()).andNameEqualTo("UNPLANNED");
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("未规划接口").andParentIdIsNull();;
example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo("UNPLANNED").andParentIdIsNull();
List<ApiModule> list = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isEmpty(list)) {
ApiModule record = new ApiModule();
record.setId(UUID.randomUUID().toString());
record.setName("未规划接口");
record.setName("UNPLANNED");
record.setProtocol(protocol);
record.setPos(1.0);
record.setLevel(1);
@ -549,11 +549,11 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
public ApiModule getDefaultNodeUnCreateNew(String projectId,String protocol) {
ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo("未规划接口").andParentIdIsNull();;
example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo("UNPLANNED").andParentIdIsNull();
List<ApiModule> list = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isEmpty(list)) {
return null;
}else {
} else {
return list.get(0);
}
}

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("未规划场景").andParentIdIsNull();
example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo("UNPLANNED").andParentIdIsNull();
List<ApiScenarioModule> list = apiScenarioModuleMapper.selectByExample(example);
if (CollectionUtils.isEmpty(list)) {
ApiScenarioModule record = new ApiScenarioModule();
record.setId(UUID.randomUUID().toString());
record.setName("未规划场景");
record.setName("UNPLANNED");
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("未规划用例").andParentIdIsNull();;
example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo("UNPLANNED").andParentIdIsNull();
List<TestCaseNode> list = testCaseNodeMapper.selectByExample(example);
if(CollectionUtils.isEmpty(list)){
if (CollectionUtils.isEmpty(list)) {
NodeNumDTO record = new NodeNumDTO();
record.setId(UUID.randomUUID().toString());
record.setCreateUser(SessionUtils.getUserId());
record.setName("未规划用例");
record.setName("UNPLANNED");
record.setPos(1.0);
record.setLevel(1);
record.setCreateTime(System.currentTimeMillis());
@ -420,6 +420,7 @@ 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);
@ -427,14 +428,18 @@ 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, "/" + rootNodeName, nodeTree,
createNodeByPathIterator(itemIterator, path, nodeTree,
pathMap, projectId, 2);
}
;
}
}
if (!hasNode) {
@ -691,11 +696,14 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
TestCaseNode testCaseNode = testCaseNodeMapper.selectByPrimaryKey(moduleId);
LinkedList<TestCaseNode> returnList = new LinkedList<>();
while (testCaseNode != null){
if (StringUtils.equals(testCaseNode.getName(), "UNPLANNED")) {
testCaseNode.setName("未规划用例");
}
while (testCaseNode != null) {
returnList.addFirst(testCaseNode);
if(testCaseNode.getParentId() == null){
if (testCaseNode.getParentId() == null) {
testCaseNode = null;
}else {
} else {
testCaseNode = testCaseNodeMapper.selectByPrimaryKey(testCaseNode.getParentId());
}
}

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("未规划用例");
example.createCriteria().andProjectIdEqualTo(testCase.getProjectId()).andNameEqualTo("UNPLANNED");
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(), caseNode.getName());
TestCaseXmindData child = new TestCaseXmindData(caseNode.getId(), dataList.get(0).getNodePath());
child.setTestCaseList(dataList);
this.children.add(child);
}

View File

@ -659,11 +659,44 @@ where group_id = 'admin'
ALTER TABLE api_definition_exec_result
ADD report_type varchar(100) DEFAULT 'API_INDEPENDENT' NOT NULL COMMENT '报告类型';
insert into api_definition_exec_result(id, name,resource_id,create_time,status,user_id,trigger_mode,start_time,end_time,actuator,report_type,version_id,project_id)
select id, name, id ,create_time,status,user_id,trigger_mode,create_time,IF(end_time is null,update_time,end_time),actuator,report_type,version_id,project_id
from api_scenario_report where execute_type = 'Saved' and report_type = 'API_INTEGRATED' and end_time is not null ;
insert into api_definition_exec_result(id, name, resource_id, create_time, status, user_id, trigger_mode, start_time,
end_time, actuator, report_type, version_id, project_id)
select id,
name,
id,
create_time,
status,
user_id,
trigger_mode,
create_time,
IF(end_time is null, update_time, end_time),
actuator,
report_type,
version_id,
project_id
from api_scenario_report
where execute_type = 'Saved'
and report_type = 'API_INTEGRATED'
and end_time is not null;
delete from api_scenario_report where report_type = 'API_INTEGRATED';
delete
from api_scenario_report
where report_type = 'API_INTEGRATED';
ALTER TABLE api_definition MODIFY COLUMN path varchar(1000);
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

@ -308,3 +308,5 @@ 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

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

View File

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

View File

@ -7,12 +7,12 @@
:is-display="getIsRelevance"
v-loading="result.loading"
:tree-nodes="data"
:allLabel="$t('全部场景')"
:allLabel="$t('api_test.automation.all_scenario')"
:type="isReadOnly ? 'view' : 'edit'"
:delete-permission="['PROJECT_API_SCENARIO:READ+DELETE']"
:add-permission="['PROJECT_API_SCENARIO:READ+CREATE']"
:update-permission="['PROJECT_API_SCENARIO:READ+EDIT']"
:default-label="'未规划场景'"
:default-label="$t('api_test.automation.unplanned_scenario')"
@add="add"
@edit="edit"
@drag="drag"
@ -186,6 +186,7 @@
if (response.data != undefined && response.data != null) {
this.data = response.data;
this.data.forEach(node => {
node.name === 'UNPLANNED' ? node.name = this.$t('api_test.automation.unplanned_scenario') : node.name
buildTree(node, {path: ''});
});
this.$emit('setModuleOptions', this.data);

View File

@ -179,6 +179,7 @@ export default {
if (response.data != undefined && response.data != null) {
this.data = response.data;
this.data.forEach(node => {
node.name === 'UNPLANNED' ? node.name = this.$t('api_test.definition.unplanned_api') : node.name
buildTree(node, {path: ''});
});
this.$emit('setModuleOptions', this.data);

View File

@ -755,6 +755,9 @@ 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,6 +775,7 @@ 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="'未规划用例'"
:default-label="$t('test_track.unplanned_case')"
@add="add"
@edit="edit"
@drag="drag"
@ -175,6 +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
buildTree(node, {path: ''});
});
this.setModuleOptions();

View File

@ -327,8 +327,8 @@ export default {
},
monitor: "Monitor",
all_label: {
case: "all",
review: "all"
case: "All Case",
review: "All Review"
},
image: 'Image',
tag: 'Tag',
@ -1350,6 +1350,8 @@ 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",
scenario_name: "Scenario Name",
case_level: "Case Level",
@ -1937,6 +1939,7 @@ 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

@ -1355,6 +1355,8 @@ export default {
reference_info: "请选择接口或用例",
scenario_test: "场景",
scenario_list: "场景列表",
unplanned_scenario: '未规划场景',
all_scenario: '全部场景',
add_scenario: "创建场景",
scenario_name: "场景名称",
case_level: "用例等级",
@ -1942,6 +1944,7 @@ export default {
date: "日期"
},
test_track: {
unplanned_case: '未规划用例',
sync_add_api_load: '同步添加关联的接口和性能测试',
next: '下一条',
total_size: '共 {0} 条',

View File

@ -1355,6 +1355,8 @@ export default {
reference_info: "請選擇接口或用例",
scenario_test: "場景",
scenario_list: "場景列表",
all_scenario: '全部場景',
unplanned_scenario: '未規劃場景',
add_scenario: "創建場景",
scenario_name: "場景名稱",
case_level: "用例等級",
@ -1942,6 +1944,7 @@ export default {
date: "日期"
},
test_track: {
unplanned_case: '未規劃用例',
sync_add_api_load: '同步添加關聯的接口和性能測試',
next: '下一條',
total_size: '共 {0} 條',