From 13960fc9fb967c06bdea9e1a57a14b81680d7861 Mon Sep 17 00:00:00 2001 From: wenyann Date: Tue, 13 Jul 2021 14:41:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E3=80=90github=E3=80=91=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=B7=9F=E8=B8=AA=20=E6=96=B0=E5=BB=BA=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E5=85=B3=E8=81=94=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ApiAutomationController.java | 7 + .../dto/definition/ApiTestCaseRequest.java | 1 + .../api/service/ApiTestCaseService.java | 5 + .../metersphere/job/sechedule/IssuesJob.java | 2 +- .../api/definition/model/JsonData.js | 6 + .../track/case/components/TestCaseEdit.vue | 151 +++++++++++++++++- .../case/components/TestCaseEditOtherInfo.vue | 93 +---------- 7 files changed, 169 insertions(+), 96 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java index a3aaca55c8..aa30a75425 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java @@ -44,6 +44,13 @@ public class ApiAutomationController { return PageUtils.setPageInfo(page, apiAutomationService.list(request)); } + @PostMapping("/list") + @RequiresPermissions("PROJECT_API_SCENARIO:READ") + public List listAll(@RequestBody ApiScenarioRequest request) { + + return apiAutomationService.list(request); + } + @PostMapping("/list/all") @RequiresPermissions("PROJECT_API_SCENARIO:READ") public List listAll(@RequestBody ApiScenarioBatchRequest request) { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseRequest.java b/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseRequest.java index 7b148baef3..d7e8a39d41 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseRequest.java @@ -22,6 +22,7 @@ public class ApiTestCaseRequest extends BaseQueryRequest { private String apiDefinitionId; private String status; private String protocol; + private String moduleId; private List moduleIds; private List orders; private Map> filters; diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index 4aff9375ea..c3515bddac 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -93,6 +93,11 @@ public class ApiTestCaseService { public List list(ApiTestCaseRequest request) { request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); + if (request.getModuleIds() == null) { + List moduleIds = new ArrayList<>(); + moduleIds.add(request.getModuleId()); + request.setModuleIds(moduleIds); + } List returnList = extApiTestCaseMapper.list(request); for (ApiTestCaseResult res : returnList) { diff --git a/backend/src/main/java/io/metersphere/job/sechedule/IssuesJob.java b/backend/src/main/java/io/metersphere/job/sechedule/IssuesJob.java index 6619097524..997628f972 100644 --- a/backend/src/main/java/io/metersphere/job/sechedule/IssuesJob.java +++ b/backend/src/main/java/io/metersphere/job/sechedule/IssuesJob.java @@ -24,7 +24,7 @@ public class IssuesJob { @Resource private TestPlanTestCaseService testPlanTestCaseService; - @QuartzScheduled(fixedDelay = 3600 * 1000) + //@QuartzScheduled(fixedDelay = 3600 * 1000) // @Scheduled(fixedDelay = 120 * 1000) public void issuesCount() { LogUtil.info("测试计划-测试用例同步缺陷信息开始"); diff --git a/frontend/src/business/components/api/definition/model/JsonData.js b/frontend/src/business/components/api/definition/model/JsonData.js index 1ed6e30285..aed121416d 100644 --- a/frontend/src/business/components/api/definition/model/JsonData.js +++ b/frontend/src/business/components/api/definition/model/JsonData.js @@ -96,6 +96,12 @@ export const TEST = [ {id: 'testcase', 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 = [ ['GET', "#61AFFE"], ['POST', '#49CC90'], ['PUT', '#fca130'], diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index 349d5c9b78..c95ec7812b 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -81,7 +81,8 @@ - + {{ $t('test_track.review.comment') }}: @@ -122,6 +123,7 @@ import {TokenKey, WORKSPACE_ID} from '@/common/js/constants'; import MsDialogFooter from '../../../common/components/MsDialogFooter' import { + enableModules, getCurrentProjectID, getCurrentUser, getNodePath, @@ -136,7 +138,7 @@ import {ELEMENTS} from "@/business/components/api/automation/scenario/Setting"; import TestCaseComment from "@/business/components/track/case/components/TestCaseComment"; 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 MsSelectTree from "../../../common/select-tree/SelectTree"; import MsTestCaseStepRichText from "./MsRichText"; @@ -174,9 +176,9 @@ }, data() { return { + sysList: [],//一级选择框的数据 path: "/test/case/add", testCaseTemplate: {}, - // sysList: [],//一级选择框的数据 options: REVIEW_STATUS, statuOptions: API_STATUS, comments: [], @@ -335,9 +337,146 @@ this.form.module = this.treeNodes[0].id; this.form.nodePath = this.treeNodes[0].path; } + this.loadOptions(); }, 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); }, setModule(id, data) { @@ -394,7 +533,7 @@ if (!valid) { this.saveCase(); } else { - this.saveCase(function(t) { + this.saveCase(function (t) { let tab = {}; tab.name = 'add'; t.$emit('addTab', tab); @@ -729,7 +868,7 @@ this.form.testId = ''; }, 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; }); }, diff --git a/frontend/src/business/components/track/case/components/TestCaseEditOtherInfo.vue b/frontend/src/business/components/track/case/components/TestCaseEditOtherInfo.vue index f39edadcd9..6c487e9fe7 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEditOtherInfo.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEditOtherInfo.vue @@ -99,7 +99,7 @@ import FormRichTextItem from "@/business/components/track/case/components/FormRi export default { name: "TestCaseEditOtherInfo", components: {FormRichTextItem, TestCaseIssueRelate, TestCaseAttachment, MsRichText, TestCaseRichText}, - props: ['form', 'labelWidth', 'caseId', 'readOnly', 'projectId', 'isTestPlan', 'planId'], + props: ['form', 'labelWidth', 'caseId', 'readOnly', 'projectId', 'isTestPlan', 'planId', 'sysList'], data() { return { result: {}, @@ -108,7 +108,7 @@ export default { fileList: [], tableData: [], demandOptions: [], - sysList: [],//一级选择框的数据 + //sysList:this.sysList,//一级选择框的数据 props: { multiple: true, //lazy: true, @@ -123,9 +123,7 @@ export default { }, watch: { tabActiveName() { - if (this.tabActiveName === 'relateTest') { - this.loadOptions(this.sysList); - } else if (this.tabActiveName === 'demand') { + if (this.tabActiveName === 'demand') { this.getDemandOptions(); } else if (this.tabActiveName === 'bug') { 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); - }); - }); - } } }; @@ -371,6 +286,6 @@ export default { .el-cascader >>> .el-input { cursor: pointer; - width: 300px; + width: 500px; }