fix: 测试计划编辑用例时因为用例关联的测试不存在而产生的bug

This commit is contained in:
shiziyuan9527 2020-07-17 13:54:28 +08:00
parent 5d0e802041
commit 95abc82d44
7 changed files with 26 additions and 7 deletions

View File

@ -118,11 +118,15 @@ public class APITestService {
public APITestResult get(String id) { public APITestResult get(String id) {
APITestResult apiTest = new APITestResult(); APITestResult apiTest = new APITestResult();
BeanUtils.copyBean(apiTest, apiTestMapper.selectByPrimaryKey(id)); ApiTest test = apiTestMapper.selectByPrimaryKey(id);
if (test != null) {
BeanUtils.copyBean(apiTest, test);
Schedule schedule = scheduleService.getScheduleByResource(id, ScheduleGroup.API_TEST.name()); Schedule schedule = scheduleService.getScheduleByResource(id, ScheduleGroup.API_TEST.name());
apiTest.setSchedule(schedule); apiTest.setSchedule(schedule);
return apiTest; return apiTest;
} }
return null;
}
public ApiTest getApiTestByTestId(String testId) { public ApiTest getApiTestByTestId(String testId) {
return apiTestMapper.selectByPrimaryKey(testId); return apiTestMapper.selectByPrimaryKey(testId);

View File

@ -380,7 +380,13 @@
getRelatedTest() { getRelatedTest() {
if (this.testCase.method == 'auto' && this.testCase.testId) { if (this.testCase.method == 'auto' && this.testCase.testId) {
this.$get('/' + this.testCase.type + '/get/' + this.testCase.testId, response => { this.$get('/' + this.testCase.type + '/get/' + this.testCase.testId, response => {
this.test = response.data; let data = response.data;
if (data) {
this.test = data;
} else {
this.test = {};
this.$warning(this.$t("test_track.case.relate_test_not_find"));
}
}); });
} }
}, },

View File

@ -70,6 +70,8 @@
}); });
this.getProject(item.projectId); this.getProject(item.projectId);
this.$refs.config.reset(); this.$refs.config.reset();
} else {
this.test = new Test();
} }
}); });
}, },

View File

@ -93,8 +93,12 @@
getTest() { getTest() {
if (this.id) { if (this.id) {
this.result = this.$get('/performance/get/' + this.id, response => { this.result = this.$get('/performance/get/' + this.id, response => {
if (response.data) {
this.test = response.data; this.test = response.data;
this.getProject(this.test.projectId); this.getProject(this.test.projectId);
} else {
this.test = {};
}
}); });
} }
}, },

View File

@ -497,6 +497,7 @@ export default {
please_create_project: "No project available, please create the project first", please_create_project: "No project available, please create the project first",
create_module_first: "Please create module first", create_module_first: "Please create module first",
relate_test: "Relate test", relate_test: "Relate test",
relate_test_not_find: 'The associated test does not exist, please check the test case',
import: { import: {
import: "Import test case", import: "Import test case",
case_import: "Import test case", case_import: "Import test case",

View File

@ -496,6 +496,7 @@ export default {
please_create_project: "暂无项目,请先创建项目", please_create_project: "暂无项目,请先创建项目",
create_module_first: "请先新建模块", create_module_first: "请先新建模块",
relate_test: "关联测试", relate_test: "关联测试",
relate_test_not_find: '关联的测试不存在,请检查用例',
import: { import: {
import: "导入用例", import: "导入用例",
case_import: "导入测试用例", case_import: "导入测试用例",

View File

@ -496,6 +496,7 @@ export default {
please_create_project: "暫無項目,請先創建項目", please_create_project: "暫無項目,請先創建項目",
create_module_first: "請先新建模塊", create_module_first: "請先新建模塊",
relate_test: "關聯測試", relate_test: "關聯測試",
relate_test_not_find: '關聯的測試不存在,請檢查用例',
import: { import: {
import: "導入用例", import: "導入用例",
case_import: "導入測試用例", case_import: "導入測試用例",