From bceade43a9ac503d2a964c7bb5b884b6f070989a Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 28 May 2020 09:47:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=94=A8=E4=BE=8B=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/APITestController.java | 7 ++ .../api/service/APITestService.java | 3 + .../io/metersphere/base/domain/TestCase.java | 2 + .../base/domain/TestCaseExample.java | 70 +++++++++++ .../base/domain/TestPlanTestCase.java | 2 + .../base/domain/TestPlanTestCaseExample.java | 70 +++++++++++ .../base/mapper/TestCaseMapper.xml | 29 ++++- .../base/mapper/TestPlanTestCaseMapper.xml | 31 +++-- .../base/mapper/ext/ExtApiTestMapper.java | 3 + .../base/mapper/ext/ExtApiTestMapper.xml | 9 +- .../base/mapper/ext/ExtLoadTestMapper.java | 3 + .../base/mapper/ext/ExtLoadTestMapper.xml | 5 + .../controller/PerformanceTestController.java | 6 + .../service/PerformanceTestService.java | 3 + .../db/migration/V2__metersphere_ddl.sql | 2 + .../src/main/resources/generatorConfig.xml | 4 +- .../track/case/components/TestCaseEdit.vue | 118 ++++++++++++------ 17 files changed, 313 insertions(+), 54 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/APITestController.java b/backend/src/main/java/io/metersphere/api/controller/APITestController.java index 92360d6e14..d63c6c947a 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APITestController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APITestController.java @@ -7,7 +7,9 @@ import io.metersphere.api.dto.DeleteAPITestRequest; import io.metersphere.api.dto.QueryAPITestRequest; import io.metersphere.api.dto.SaveAPITestRequest; import io.metersphere.api.service.APITestService; +import io.metersphere.base.domain.ApiTest; import io.metersphere.base.domain.ApiTestWithBLOBs; +import io.metersphere.base.domain.LoadTest; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; @@ -44,6 +46,11 @@ public class APITestController { return PageUtils.setPageInfo(page, apiTestService.list(request)); } + @GetMapping("/list/{projectId}") + public List list(@PathVariable String projectId) { + return apiTestService.getApiTestByProjectId(projectId); + } + @PostMapping(value = "/create", consumes = {"multipart/form-data"}) public void create(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "files") List files) { apiTestService.create(request, files); diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index ce3c6ba6a1..4bf05fea26 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -167,4 +167,7 @@ public class APITestService { } } + public List getApiTestByProjectId(String projectId) { + return extApiTestMapper.getApiTestByProjectId(projectId); + } } diff --git a/backend/src/main/java/io/metersphere/base/domain/TestCase.java b/backend/src/main/java/io/metersphere/base/domain/TestCase.java index d9954b8ad4..2585f68787 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestCase.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestCase.java @@ -29,5 +29,7 @@ public class TestCase implements Serializable { private Long updateTime; + private String testId; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/TestCaseExample.java b/backend/src/main/java/io/metersphere/base/domain/TestCaseExample.java index 0cf4adc790..1196b8477b 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestCaseExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestCaseExample.java @@ -923,6 +923,76 @@ public class TestCaseExample { addCriterion("update_time not between", value1, value2, "updateTime"); return (Criteria) this; } + + public Criteria andTestIdIsNull() { + addCriterion("test_id is null"); + return (Criteria) this; + } + + public Criteria andTestIdIsNotNull() { + addCriterion("test_id is not null"); + return (Criteria) this; + } + + public Criteria andTestIdEqualTo(String value) { + addCriterion("test_id =", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdNotEqualTo(String value) { + addCriterion("test_id <>", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdGreaterThan(String value) { + addCriterion("test_id >", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdGreaterThanOrEqualTo(String value) { + addCriterion("test_id >=", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdLessThan(String value) { + addCriterion("test_id <", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdLessThanOrEqualTo(String value) { + addCriterion("test_id <=", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdLike(String value) { + addCriterion("test_id like", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdNotLike(String value) { + addCriterion("test_id not like", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdIn(List values) { + addCriterion("test_id in", values, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdNotIn(List values) { + addCriterion("test_id not in", values, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdBetween(String value1, String value2) { + addCriterion("test_id between", value1, value2, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdNotBetween(String value1, String value2) { + addCriterion("test_id not between", value1, value2, "testId"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCase.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCase.java index 94354c533a..09307e26a6 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCase.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCase.java @@ -21,5 +21,7 @@ public class TestPlanTestCase implements Serializable { private Long updateTime; + private String reportId; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCaseExample.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCaseExample.java index a5136f7f26..b15f9f3f1e 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCaseExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCaseExample.java @@ -643,6 +643,76 @@ public class TestPlanTestCaseExample { addCriterion("update_time not between", value1, value2, "updateTime"); return (Criteria) this; } + + public Criteria andReportIdIsNull() { + addCriterion("report_id is null"); + return (Criteria) this; + } + + public Criteria andReportIdIsNotNull() { + addCriterion("report_id is not null"); + return (Criteria) this; + } + + public Criteria andReportIdEqualTo(String value) { + addCriterion("report_id =", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdNotEqualTo(String value) { + addCriterion("report_id <>", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdGreaterThan(String value) { + addCriterion("report_id >", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdGreaterThanOrEqualTo(String value) { + addCriterion("report_id >=", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdLessThan(String value) { + addCriterion("report_id <", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdLessThanOrEqualTo(String value) { + addCriterion("report_id <=", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdLike(String value) { + addCriterion("report_id like", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdNotLike(String value) { + addCriterion("report_id not like", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdIn(List values) { + addCriterion("report_id in", values, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdNotIn(List values) { + addCriterion("report_id not in", values, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdBetween(String value1, String value2) { + addCriterion("report_id between", value1, value2, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdNotBetween(String value1, String value2) { + addCriterion("report_id not between", value1, value2, "reportId"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestCaseMapper.xml index 6fb8197aa4..6c2936ce2c 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestCaseMapper.xml @@ -14,6 +14,7 @@ + @@ -79,7 +80,7 @@ id, node_id, node_path, project_id, name, type, maintainer, priority, method, prerequisite, - create_time, update_time + create_time, update_time, test_id remark, steps @@ -137,12 +138,14 @@ project_id, name, type, maintainer, priority, method, prerequisite, create_time, update_time, - remark, steps) + test_id, remark, steps + ) values (#{id,jdbcType=VARCHAR}, #{nodeId,jdbcType=VARCHAR}, #{nodePath,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{maintainer,jdbcType=VARCHAR}, #{priority,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR}, #{prerequisite,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, - #{remark,jdbcType=LONGVARCHAR}, #{steps,jdbcType=LONGVARCHAR}) + #{testId,jdbcType=VARCHAR}, #{remark,jdbcType=LONGVARCHAR}, #{steps,jdbcType=LONGVARCHAR} + ) insert into test_case @@ -183,6 +186,9 @@ update_time, + + test_id, + remark, @@ -227,6 +233,9 @@ #{updateTime,jdbcType=BIGINT}, + + #{testId,jdbcType=VARCHAR}, + #{remark,jdbcType=LONGVARCHAR}, @@ -280,6 +289,9 @@ update_time = #{record.updateTime,jdbcType=BIGINT}, + + test_id = #{record.testId,jdbcType=VARCHAR}, + remark = #{record.remark,jdbcType=LONGVARCHAR}, @@ -305,6 +317,7 @@ prerequisite = #{record.prerequisite,jdbcType=VARCHAR}, create_time = #{record.createTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT}, + test_id = #{record.testId,jdbcType=VARCHAR}, remark = #{record.remark,jdbcType=LONGVARCHAR}, steps = #{record.steps,jdbcType=LONGVARCHAR} @@ -324,7 +337,8 @@ method = #{record.method,jdbcType=VARCHAR}, prerequisite = #{record.prerequisite,jdbcType=VARCHAR}, create_time = #{record.createTime,jdbcType=BIGINT}, - update_time = #{record.updateTime,jdbcType=BIGINT} + update_time = #{record.updateTime,jdbcType=BIGINT}, + test_id = #{record.testId,jdbcType=VARCHAR} @@ -365,6 +379,9 @@ update_time = #{updateTime,jdbcType=BIGINT}, + + test_id = #{testId,jdbcType=VARCHAR}, + remark = #{remark,jdbcType=LONGVARCHAR}, @@ -387,6 +404,7 @@ prerequisite = #{prerequisite,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT}, + test_id = #{testId,jdbcType=VARCHAR}, remark = #{remark,jdbcType=LONGVARCHAR}, steps = #{steps,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -403,7 +421,8 @@ method = #{method,jdbcType=VARCHAR}, prerequisite = #{prerequisite,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=BIGINT}, - update_time = #{updateTime,jdbcType=BIGINT} + update_time = #{updateTime,jdbcType=BIGINT}, + test_id = #{testId,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestPlanTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestPlanTestCaseMapper.xml index 35e1ab4640..02b6d92178 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestPlanTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestPlanTestCaseMapper.xml @@ -10,6 +10,7 @@ + @@ -74,7 +75,7 @@ - id, plan_id, case_id, executor, status, remark, create_time, update_time + id, plan_id, case_id, executor, status, remark, create_time, update_time, report_id results, issues @@ -130,12 +131,12 @@ insert into test_plan_test_case (id, plan_id, case_id, executor, status, remark, - create_time, update_time, results, - issues) + create_time, update_time, report_id, + results, issues) values (#{id,jdbcType=VARCHAR}, #{planId,jdbcType=VARCHAR}, #{caseId,jdbcType=VARCHAR}, #{executor,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, - #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{results,jdbcType=LONGVARCHAR}, - #{issues,jdbcType=LONGVARCHAR}) + #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{reportId,jdbcType=VARCHAR}, + #{results,jdbcType=LONGVARCHAR}, #{issues,jdbcType=LONGVARCHAR}) insert into test_plan_test_case @@ -164,6 +165,9 @@ update_time, + + report_id, + results, @@ -196,6 +200,9 @@ #{updateTime,jdbcType=BIGINT}, + + #{reportId,jdbcType=VARCHAR}, + #{results,jdbcType=LONGVARCHAR}, @@ -237,6 +244,9 @@ update_time = #{record.updateTime,jdbcType=BIGINT}, + + report_id = #{record.reportId,jdbcType=VARCHAR}, + results = #{record.results,jdbcType=LONGVARCHAR}, @@ -258,6 +268,7 @@ remark = #{record.remark,jdbcType=VARCHAR}, create_time = #{record.createTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT}, + report_id = #{record.reportId,jdbcType=VARCHAR}, results = #{record.results,jdbcType=LONGVARCHAR}, issues = #{record.issues,jdbcType=LONGVARCHAR} @@ -273,7 +284,8 @@ status = #{record.status,jdbcType=VARCHAR}, remark = #{record.remark,jdbcType=VARCHAR}, create_time = #{record.createTime,jdbcType=BIGINT}, - update_time = #{record.updateTime,jdbcType=BIGINT} + update_time = #{record.updateTime,jdbcType=BIGINT}, + report_id = #{record.reportId,jdbcType=VARCHAR} @@ -302,6 +314,9 @@ update_time = #{updateTime,jdbcType=BIGINT}, + + report_id = #{reportId,jdbcType=VARCHAR}, + results = #{results,jdbcType=LONGVARCHAR}, @@ -320,6 +335,7 @@ remark = #{remark,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT}, + report_id = #{reportId,jdbcType=VARCHAR}, results = #{results,jdbcType=LONGVARCHAR}, issues = #{issues,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -332,7 +348,8 @@ status = #{status,jdbcType=VARCHAR}, remark = #{remark,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=BIGINT}, - update_time = #{updateTime,jdbcType=BIGINT} + update_time = #{updateTime,jdbcType=BIGINT}, + report_id = #{reportId,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.java index a6bc7a0920..7e1bbe438a 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.java @@ -2,6 +2,7 @@ package io.metersphere.base.mapper.ext; import io.metersphere.api.dto.APITestResult; import io.metersphere.api.dto.QueryAPITestRequest; +import io.metersphere.base.domain.ApiTest; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -10,4 +11,6 @@ public interface ExtApiTestMapper { List list(@Param("request") QueryAPITestRequest request); Long countByProjectId(String projectId); + + List getApiTestByProjectId(String projectId); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.xml index 7a50475391..895d082944 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.xml @@ -30,8 +30,13 @@ order by api_test.update_time desc + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.java index d1405a6b3f..ecb49d5523 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.java @@ -1,5 +1,6 @@ package io.metersphere.base.mapper.ext; +import io.metersphere.base.domain.LoadTest; import io.metersphere.track.request.testplan.QueryTestPlanRequest; import io.metersphere.dto.LoadTestDTO; import org.apache.ibatis.annotations.Param; @@ -10,4 +11,6 @@ public interface ExtLoadTestMapper { List list(@Param("request") QueryTestPlanRequest params); Long countByProjectId(String projectId); + + List getLoadTestByProjectId(String projectId); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml index f3d685abef..953d9641f1 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml @@ -31,5 +31,10 @@ select count(id) from load_test where project_id = #{projectId}; + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java b/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java index 3d5ba80c63..60b65ff5d0 100644 --- a/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java +++ b/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java @@ -3,6 +3,7 @@ package io.metersphere.performance.controller; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.FileMetadata; +import io.metersphere.base.domain.LoadTest; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; @@ -48,6 +49,11 @@ public class PerformanceTestController { return PageUtils.setPageInfo(page, performanceTestService.list(request)); } + @GetMapping("/list/{projectId}") + public List list(@PathVariable String projectId) { + return performanceTestService.getLoadTestByProjectId(projectId); + } + @PostMapping(value = "/save", consumes = {"multipart/form-data"}) public String save( @RequestPart("request") SaveTestPlanRequest request, diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index bba35f816f..a997e441e8 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -280,4 +280,7 @@ public class PerformanceTestService { return extLoadTestReportMapper.selectDashboardTests(workspaceId, startTimestamp); } + public List getLoadTestByProjectId(String projectId) { + return extLoadTestMapper.getLoadTestByProjectId(projectId); + } } diff --git a/backend/src/main/resources/db/migration/V2__metersphere_ddl.sql b/backend/src/main/resources/db/migration/V2__metersphere_ddl.sql index c4771e9f6d..b48a4655c0 100644 --- a/backend/src/main/resources/db/migration/V2__metersphere_ddl.sql +++ b/backend/src/main/resources/db/migration/V2__metersphere_ddl.sql @@ -286,6 +286,7 @@ CREATE TABLE IF NOT EXISTS `test_case_node` ( CREATE TABLE IF NOT EXISTS `test_case` ( `id` varchar(50) NOT NULL COMMENT 'Test case ID', `node_id` varchar(50) NOT NULL COMMENT 'Node ID this case belongs to', + `test_id` varchar(50) DEFAULT NULL COMMENT 'Test ID relation to', `node_path` varchar(50) NOT NULL COMMENT 'Node path this case belongs to', `project_id` varchar(50) NOT NULL COMMENT 'Project ID this test belongs to', `name` varchar(64) NOT NULL COMMENT 'Case name', @@ -309,6 +310,7 @@ CREATE TABLE IF NOT EXISTS `test_plan_test_case` ( `id` varchar(50) NOT NULL COMMENT 'ID', `plan_id` varchar(50) NOT NULL COMMENT 'Plan ID relation to', `case_id` varchar(50) NOT NULL COMMENT 'Case ID relation to', + `report_id` varchar(50) DEFAULT NULL COMMENT 'Test report ID relation to', `executor` varchar(64) NOT NULL COMMENT 'Test case executor', `status` varchar(15) NULL COMMENT 'Test case status', `results` longtext COMMENT 'Test case result', diff --git a/backend/src/main/resources/generatorConfig.xml b/backend/src/main/resources/generatorConfig.xml index f8a43e0b52..2acdb9acbc 100644 --- a/backend/src/main/resources/generatorConfig.xml +++ b/backend/src/main/resources/generatorConfig.xml @@ -59,8 +59,8 @@ - -
+
+
\ No newline at end of file diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index 88bbae2d3e..f494adacc5 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -64,7 +64,7 @@ - + @@ -81,6 +81,21 @@ + + + + + + + + + + + {{$t('test_track.case.prerequisite')}}: @@ -213,6 +228,7 @@ type: '', method: '', prerequisite: '', + testId: '', steps: [{ num: 1 , desc: '', @@ -222,6 +238,7 @@ }, moduleOptions: [], maintainerOptions: [], + testOptions: [], workspaceId: '', rules:{ name :[ @@ -232,6 +249,7 @@ maintainer :[{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}], priority :[{required: true, message: this.$t('test_track.case.input_priority'), trigger: 'change'}], type :[{required: true, message: this.$t('test_track.case.input_type'), trigger: 'change'}], + testId :[{required: true, message: '请选择测试', trigger: 'change'}], method :[{required: true, message: this.$t('test_track.case.input_method'), trigger: 'change'}], prerequisite :[{ max: 300, message: this.$t('test_track.length_less_than') + '300', trigger: 'blur'}], remark :[{ max: 300, message: this.$t('test_track.length_less_than') + '300', trigger: 'blur'}] @@ -258,6 +276,9 @@ }, mounted() { this.getSelectOptions(); + }, + watch: { + }, methods: { open(testCase) { @@ -315,49 +336,61 @@ saveCase(){ this.$refs['caseFrom'].validate((valid) => { if (valid) { - let param = {}; - Object.assign(param, this.form); - - for (let i = 0; i < param.steps.length; i++){ - if ((param.steps[i].desc && param.steps[i].desc.length > 300) || - (param.steps[i].result && param.steps[i].result.length > 300)) { - this.$warning(this.$t('test_track.case.step_desc') + "," - + this.$t('test_track.case.expected_results') + this.$t('test_track.length_less_than') + '300'); - return; - } + let param = this.buildParam(); + if (this.validate(param)) { + this.result = this.$post('/test/case/' + this.operationType, param, () => { + this.$success(this.$t('commons.save_success')); + if (this.operationType == 'add' && this.isCreateContinue) { + this.form.name = ''; + return; + } + this.dialogFormVisible = false; + this.$emit("refresh"); + }); } - - param.steps = JSON.stringify(this.form.steps); - param.nodeId = this.form.module; - this.moduleOptions.forEach(item => { - if(this.form.module === item.id){ - param.nodePath = item.path; - } - }); - - if (this.currentProject) { - param.projectId = this.currentProject.id; - } - - param.name = param.name.trim(); - if (param.name == '') { - this.$warning(this.$t('test_track.case.input_name')); - return; - } - this.result = this.$post('/test/case/' + this.operationType, param, () => { - this.$success(this.$t('commons.save_success')); - if (this.operationType == 'add' && this.isCreateContinue) { - this.form.name = ''; - return; - } - this.dialogFormVisible = false; - this.$emit("refresh"); - }); } else { return false; } }); }, + buildParam() { + let param = {}; + Object.assign(param, this.form); + param.steps = JSON.stringify(this.form.steps); + param.nodeId = this.form.module; + this.moduleOptions.forEach(item => { + if(this.form.module === item.id){ + param.nodePath = item.path; + } + }); + if (this.currentProject) { + param.projectId = this.currentProject.id; + } + param.name = param.name.trim(); + if (param.method != 'auto') { + param.testId = null; + } + return param; + }, + validate(param) { + for (let i = 0; i < param.steps.length; i++){ + if ((param.steps[i].desc && param.steps[i].desc.length > 300) || + (param.steps[i].result && param.steps[i].result.length > 300)) { + this.$warning(this.$t('test_track.case.step_desc') + "," + + this.$t('test_track.case.expected_results') + this.$t('test_track.length_less_than') + '300'); + return false; + } + } + if (param.name == '') { + this.$warning(this.$t('test_track.case.input_name')); + return false; + } + return true; + }, + typeChange() { + this.form.testId = ''; + this.getTestOptions() + }, getModuleOptions() { let moduleOptions = []; this.treeNodes.forEach(node => { @@ -371,9 +404,18 @@ this.maintainerOptions = response.data; }); }, + getTestOptions() { + this.testOptions = []; + if (this.currentProject && this.form.type != '' && this.form.type != 'functional') { + this.$get('/' + this.form.type + '/list/' + this.currentProject.id, response => { + this.testOptions = response.data; + }); + } + }, getSelectOptions() { this.getModuleOptions(); this.getMaintainerOptions(); + this.getTestOptions(); }, buildNodePath(node, option, moduleOptions) { //递归构建节点路径