fix:【github】测试跟踪 新建用例关联接口测试

This commit is contained in:
wenyann 2021-07-13 14:41:42 +08:00 committed by 刘瑞斌
parent 3dc85b9d49
commit c743e3599b
7 changed files with 169 additions and 96 deletions

View File

@ -45,6 +45,13 @@ public class ApiAutomationController {
return PageUtils.setPageInfo(page, apiAutomationService.list(request)); return PageUtils.setPageInfo(page, apiAutomationService.list(request));
} }
@PostMapping("/list")
@RequiresPermissions("PROJECT_API_SCENARIO:READ")
public List<ApiScenarioDTO> listAll(@RequestBody ApiScenarioRequest request) {
return apiAutomationService.list(request);
}
@PostMapping("/list/all") @PostMapping("/list/all")
@RequiresPermissions("PROJECT_API_SCENARIO:READ") @RequiresPermissions("PROJECT_API_SCENARIO:READ")
public List<ApiScenarioWithBLOBs> listAll(@RequestBody ApiScenarioBatchRequest request) { public List<ApiScenarioWithBLOBs> listAll(@RequestBody ApiScenarioBatchRequest request) {

View File

@ -22,6 +22,7 @@ public class ApiTestCaseRequest extends BaseQueryRequest {
private String apiDefinitionId; private String apiDefinitionId;
private String status; private String status;
private String protocol; private String protocol;
private String moduleId;
private List<String> moduleIds; private List<String> moduleIds;
private List<OrderRequest> orders; private List<OrderRequest> orders;
private Map<String, List<String>> filters; private Map<String, List<String>> filters;

View File

@ -93,6 +93,11 @@ public class ApiTestCaseService {
public List<ApiTestCaseResult> list(ApiTestCaseRequest request) { public List<ApiTestCaseResult> list(ApiTestCaseRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
if (request.getModuleIds() == null) {
List<String> moduleIds = new ArrayList<>();
moduleIds.add(request.getModuleId());
request.setModuleIds(moduleIds);
}
List<ApiTestCaseResult> returnList = extApiTestCaseMapper.list(request); List<ApiTestCaseResult> returnList = extApiTestCaseMapper.list(request);
for (ApiTestCaseResult res : returnList) { for (ApiTestCaseResult res : returnList) {

View File

@ -24,7 +24,7 @@ public class IssuesJob {
@Resource @Resource
private TestPlanTestCaseService testPlanTestCaseService; private TestPlanTestCaseService testPlanTestCaseService;
@QuartzScheduled(fixedDelay = 3600 * 1000) //@QuartzScheduled(fixedDelay = 3600 * 1000)
// @Scheduled(fixedDelay = 120 * 1000) // @Scheduled(fixedDelay = 120 * 1000)
public void issuesCount() { public void issuesCount() {
LogUtil.info("测试计划-测试用例同步缺陷信息开始"); LogUtil.info("测试计划-测试用例同步缺陷信息开始");

View File

@ -96,6 +96,12 @@ export const TEST = [
{id: 'testcase', name: '接口用例', module: 'api'}, {id: 'testcase', name: '接口用例', module: 'api'},
{id: 'automation', name: '场景测试', module: 'api'} {id: 'automation', name: '场景测试', module: 'api'}
]; ];
export const TEST_CASE = [
{value: 'HTTP', label: 'HTTP', leaf: true},
{value: 'TCP', label: 'TCP', leaf: true},
{value: 'DUBBO', label: 'DUBBO', leaf: true},
{value: 'SQL', label: 'SQL', leaf: true}
];
export const API_METHOD_COLOUR = [ export const API_METHOD_COLOUR = [
['GET', "#61AFFE"], ['POST', '#49CC90'], ['PUT', '#fca130'], ['GET', "#61AFFE"], ['POST', '#49CC90'], ['PUT', '#fca130'],

View File

@ -81,7 +81,8 @@
<test-case-step-item :label-width="formLabelWidth" v-if="form.stepModel === 'STEP' || !form.stepModel" :form="form" :read-only="readOnly"/> <test-case-step-item :label-width="formLabelWidth" v-if="form.stepModel === 'STEP' || !form.stepModel" :form="form" :read-only="readOnly"/>
<test-case-edit-other-info :read-only="readOnly" :project-id="projectIds" :form="form" :label-width="formLabelWidth" :case-id="form.id" ref="otherInfo"/> <test-case-edit-other-info :sys-list="sysList" :read-only="readOnly" :project-id="projectIds" :form="form"
:label-width="formLabelWidth" :case-id="form.id" ref="otherInfo"/>
<el-row style="margin-top: 10px" v-if="type!='add'"> <el-row style="margin-top: 10px" v-if="type!='add'">
<el-col :span="20" :offset="1">{{ $t('test_track.review.comment') }}: <el-col :span="20" :offset="1">{{ $t('test_track.review.comment') }}:
@ -122,6 +123,7 @@
import {TokenKey, WORKSPACE_ID} from '@/common/js/constants'; import {TokenKey, WORKSPACE_ID} from '@/common/js/constants';
import MsDialogFooter from '../../../common/components/MsDialogFooter' import MsDialogFooter from '../../../common/components/MsDialogFooter'
import { import {
enableModules,
getCurrentProjectID, getCurrentProjectID,
getCurrentUser, getCurrentUser,
getNodePath, getNodePath,
@ -136,7 +138,7 @@
import {ELEMENTS} from "@/business/components/api/automation/scenario/Setting"; import {ELEMENTS} from "@/business/components/api/automation/scenario/Setting";
import TestCaseComment from "@/business/components/track/case/components/TestCaseComment"; import TestCaseComment from "@/business/components/track/case/components/TestCaseComment";
import ReviewCommentItem from "@/business/components/track/review/commom/ReviewCommentItem"; import ReviewCommentItem from "@/business/components/track/review/commom/ReviewCommentItem";
import {API_STATUS, REVIEW_STATUS, TEST} from "@/business/components/api/definition/model/JsonData"; import {API_STATUS, REVIEW_STATUS, TEST, TEST_CASE} from "@/business/components/api/definition/model/JsonData";
import MsTableButton from "@/business/components/common/components/MsTableButton"; import MsTableButton from "@/business/components/common/components/MsTableButton";
import MsSelectTree from "../../../common/select-tree/SelectTree"; import MsSelectTree from "../../../common/select-tree/SelectTree";
import MsTestCaseStepRichText from "./MsRichText"; import MsTestCaseStepRichText from "./MsRichText";
@ -174,9 +176,9 @@
}, },
data() { data() {
return { return {
sysList: [],//
path: "/test/case/add", path: "/test/case/add",
testCaseTemplate: {}, testCaseTemplate: {},
// sysList: [],//
options: REVIEW_STATUS, options: REVIEW_STATUS,
statuOptions: API_STATUS, statuOptions: API_STATUS,
comments: [], comments: [],
@ -335,9 +337,146 @@
this.form.module = this.treeNodes[0].id; this.form.module = this.treeNodes[0].id;
this.form.nodePath = this.treeNodes[0].path; this.form.nodePath = this.treeNodes[0].path;
} }
this.loadOptions();
}, },
methods: { methods: {
openHis(){ async loadOptions(sysLib) {
if (this.form.list) {
return;
}
sysLib = TEST
.filter(item => {
return enableModules([item.module]);
})//
.map(item => ({
value: item.id,
label: item.name,
}));
let array = [];
for (let i = 0; i < sysLib.length; i++) {
if (sysLib.length > 0) {
let res = await this.getTestOptions(sysLib[i].value);
sysLib[i].children = res;
}
array.push(sysLib[i]);
}
this.sysList = array;
},
getTestOptions(val) {
this.form.type = val;
this.testOptions = [];
let url = '';
if (this.form.type === 'performance') {
url = '/' + this.form.type + '/list/' + this.projectId;
if (!url) {
return;
}
this.result.loading = true;
return new Promise((resolve, reject) => {
this.$get(url).then(res => {
const data = res.data.data.map(item => ({
value: item.id,
label: item.name,
leaf: true
}));
this.result.loading = false;
resolve(data);
}).catch((err) => {
reject(err);
});
});
} else if (this.form.type === 'automation') {
url = '/api/automation/module/list/' + this.projectId;
if (!url) {
return;
}
this.result.loading = true;
return new Promise((resolve, reject) => {
this.$get("/api/automation/module/list/" + this.projectId, response => {
if (response.data != undefined && response.data != null) {
this.buildTreeValue(response.data);
}
this.result.loading = false;
resolve(response.data);
});
});
} else if (this.form.type === 'testcase') {
this.result.loading = true;
return new Promise((resolve, reject) => {
TEST_CASE.forEach(test => {
let url = "/api/module/list/" + this.projectId + "/" + test.value;
this.$get(url, response => {
if (response.data != undefined && response.data != null) {
this.buildTreeValueApiCase(response.data);
test.children = response.data;
}
});
});
this.result.loading = false;
resolve(TEST_CASE);
});
}
},
buildTreeValueApiCase(list) {
list.forEach(item => {
item.value = item.id,
item.label = item.name,
item.leaf = true;
if (item.children) {
this.buildTreeValueApiCase(item.children);
} else {
let url = "/api/testcase/list/";
let param = {};
param.moduleId = item.id;
param.projectId = this.projectId;
this.$post(url, param, response => {
if (response.data != undefined && response.data != null) {
item.children = response.data;
this.buildTreeValueApiCase(item.children);
}
});
}
});
},
buildTreeValue(list) {
let url = '/api/automation/list';
list.forEach(item => {
item.value = item.id,
item.label = item.name,
item.leaf = true;
if (item.children) {
this.buildTreeValue(item.children);
} else {
let param = {};
param.moduleId = item.id;
param.projectId = this.projectId;
this.$post(url, param, response => {
if (response.data != undefined && response.data != null) {
item.children = response.data;
this.buildTreeValue(item.children);
}
});
}
});
},
buildValue(url) {
return new Promise((resolve, reject) => {
this.$get(url).then(res => {
const data = res.data.data.map(item => ({
value: item.id,
label: item.name,
leaf: true
}));
this.result.loading = false;
resolve(data);
}).catch((err) => {
reject(err);
});
});
},
openHis() {
this.$refs.changeHistory.open(this.form.id); this.$refs.changeHistory.open(this.form.id);
}, },
setModule(id, data) { setModule(id, data) {
@ -394,7 +533,7 @@
if (!valid) { if (!valid) {
this.saveCase(); this.saveCase();
} else { } else {
this.saveCase(function(t) { this.saveCase(function (t) {
let tab = {}; let tab = {};
tab.name = 'add'; tab.name = 'add';
t.$emit('addTab', tab); t.$emit('addTab', tab);
@ -729,7 +868,7 @@
this.form.testId = ''; this.form.testId = '';
}, },
getMaintainerOptions() { getMaintainerOptions() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()},response => { this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.maintainerOptions = response.data; this.maintainerOptions = response.data;
}); });
}, },

View File

@ -99,7 +99,7 @@ import FormRichTextItem from "@/business/components/track/case/components/FormRi
export default { export default {
name: "TestCaseEditOtherInfo", name: "TestCaseEditOtherInfo",
components: {FormRichTextItem, TestCaseIssueRelate, TestCaseAttachment, MsRichText, TestCaseRichText}, components: {FormRichTextItem, TestCaseIssueRelate, TestCaseAttachment, MsRichText, TestCaseRichText},
props: ['form', 'labelWidth', 'caseId', 'readOnly', 'projectId', 'isTestPlan', 'planId'], props: ['form', 'labelWidth', 'caseId', 'readOnly', 'projectId', 'isTestPlan', 'planId', 'sysList'],
data() { data() {
return { return {
result: {}, result: {},
@ -108,7 +108,7 @@ export default {
fileList: [], fileList: [],
tableData: [], tableData: [],
demandOptions: [], demandOptions: [],
sysList: [],// //sysList:this.sysList,//
props: { props: {
multiple: true, multiple: true,
//lazy: true, //lazy: true,
@ -123,9 +123,7 @@ export default {
}, },
watch: { watch: {
tabActiveName() { tabActiveName() {
if (this.tabActiveName === 'relateTest') { if (this.tabActiveName === 'demand') {
this.loadOptions(this.sysList);
} else if (this.tabActiveName === 'demand') {
this.getDemandOptions(); this.getDemandOptions();
} else if (this.tabActiveName === 'bug') { } else if (this.tabActiveName === 'bug') {
this.$refs.issue.getIssues(); this.$refs.issue.getIssues();
@ -267,90 +265,7 @@ export default {
}); });
} }
}, },
async loadOptions(sysLib) {
if (this.form.list) {
return;
}
sysLib = TEST
.filter(item => {
return enableModules([item.module]);
})//
.map(item => ({
value: item.id,
label: item.name,
}));
let array = [];
for (let i = 0; i < sysLib.length; i++) {
if (sysLib.length > 0) {
let res = await this.getTestOptions(sysLib[i].value);
sysLib[i].children = res;
}
array.push(sysLib[i]);
}
this.sysList = array;
},
getTestOptions(val) {
this.form.type = val;
this.testOptions = [];
let url = '';
if (this.form.type === 'testcase') {
url = '/api/' + this.form.type + '/list/' + this.projectId;
if (!url) {
return;
}
this.buildValue(url);
} else if (this.form.type === 'performance' || this.form.type === 'api') {
url = '/' + this.form.type + '/list/' + this.projectId;
if (!url) {
return;
}
this.buildValue(url);
} else if (this.form.type === 'automation') {
//url = '/api/' + this.form.type + '/list/' + this.projectId;
url = '/api/automation/module/list/' + this.projectId;
if (!url) {
return;
}
this.result.loading = true;
return new Promise((resolve, reject) => {
this.$get("/api/automation/module/list/" + this.projectId, response => {
if (response.data != undefined && response.data != null) {
this.buildTreeValue(response.data);
}
this.result.loading = false;
resolve(response.data);
});
});
}
},
buildTreeValue(list) {
list.forEach(item => {
item.value = item.id,
item.label = item.name,
item.leaf = true;
if (item.children) {
this.buildTreeValue(item.children);
}
});
},
buildValue(url) {
this.result.loading = true;
return new Promise((resolve, reject) => {
this.$get(url).then(res => {
const data = res.data.data.map(item => ({
value: item.id,
label: item.name,
leaf: true
}));
this.result.loading = false;
resolve(data);
}).catch((err) => {
reject(err);
});
});
}
} }
}; };
</script> </script>
@ -371,6 +286,6 @@ export default {
.el-cascader >>> .el-input { .el-cascader >>> .el-input {
cursor: pointer; cursor: pointer;
width: 300px; width: 500px;
} }
</style> </style>