From c021bb56473711bde078170d232d1b67ce162da8 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 9 Dec 2020 17:26:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E5=AE=8C=E6=88=90=E5=9C=BA=E6=99=AF=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=88=B0=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=87=A0?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=BC=95=E7=94=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ApiAutomationController.java | 12 +- .../controller/ApiDefinitionController.java | 1 - .../api/dto/automation/ReferenceDTO.java | 16 + .../dto/automation/SaveApiPlanRequest.java | 14 + .../api/service/ApiAutomationService.java | 67 +++- .../io/metersphere/base/domain/TestPlan.java | 7 +- .../base/domain/TestPlanExample.java | 140 ++++++++ .../base/mapper/TestPlanMapper.xml | 48 ++- .../base/mapper/ext/ExtTestPlanMapper.java | 9 +- .../base/mapper/ext/ExtTestPlanMapper.xml | 34 ++ .../testcase/QueryTestPlanRequest.java | 4 + .../automation/scenario/ApiScenarioList.vue | 54 +--- .../api/automation/scenario/DebugRun.vue | 1 - .../automation/scenario/ImportApiScenario.vue | 1 - .../api/automation/scenario/ReferenceView.vue | 3 +- .../scenario/testplan/TestPlanList.vue | 302 ++++++++++++++++++ frontend/src/i18n/en-US.js | 1 + frontend/src/i18n/zh-CN.js | 1 + frontend/src/i18n/zh-TW.js | 1 + 19 files changed, 653 insertions(+), 63 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/api/dto/automation/ReferenceDTO.java create mode 100644 backend/src/main/java/io/metersphere/api/dto/automation/SaveApiPlanRequest.java create mode 100644 frontend/src/business/components/api/automation/scenario/testplan/TestPlanList.vue 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 6d46f0e708..f4452ed120 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java @@ -2,10 +2,7 @@ package io.metersphere.api.controller; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; -import io.metersphere.api.dto.automation.ApiScenarioDTO; -import io.metersphere.api.dto.automation.ApiScenarioRequest; -import io.metersphere.api.dto.automation.RunScenarioRequest; -import io.metersphere.api.dto.automation.SaveApiScenarioRequest; +import io.metersphere.api.dto.automation.*; import io.metersphere.api.dto.definition.RunDefinitionRequest; import io.metersphere.api.service.ApiAutomationService; import io.metersphere.base.domain.ApiScenario; @@ -82,9 +79,14 @@ public class ApiAutomationController { } @PostMapping("/getReference") - public List getReference(@RequestBody ApiScenarioRequest request) { + public ReferenceDTO getReference(@RequestBody ApiScenarioRequest request) { return apiAutomationService.getReference(request); } + @PostMapping("/scenario/plan") + public String addScenarioToPlan(@RequestBody SaveApiPlanRequest request) { + return apiAutomationService.addScenarioToPlan(request); + } + } diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java index f37221cf82..b3b06d6c39 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java @@ -62,7 +62,6 @@ public class ApiDefinitionController { apiDefinitionService.removeToGc(ids); } - @GetMapping("/get/{id}") public ApiDefinition get(@PathVariable String id) { return apiDefinitionService.get(id); diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/ReferenceDTO.java b/backend/src/main/java/io/metersphere/api/dto/automation/ReferenceDTO.java new file mode 100644 index 0000000000..a210ebdfe3 --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/automation/ReferenceDTO.java @@ -0,0 +1,16 @@ +package io.metersphere.api.dto.automation; + +import io.metersphere.base.domain.ApiScenario; +import io.metersphere.track.dto.TestPlanDTO; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Getter +@Setter +public class ReferenceDTO { + List scenarioList; + + List testPlanList; +} diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiPlanRequest.java b/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiPlanRequest.java new file mode 100644 index 0000000000..9072732598 --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiPlanRequest.java @@ -0,0 +1,14 @@ +package io.metersphere.api.dto.automation; + +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Getter +@Setter +public class SaveApiPlanRequest { + private List planIds; + private List apiIds; + private List scenarioIds; +} diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index d52b7cdebd..006fbee84f 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -17,6 +17,7 @@ import io.metersphere.base.domain.*; import io.metersphere.base.mapper.ApiScenarioMapper; import io.metersphere.base.mapper.ApiTagMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioMapper; +import io.metersphere.base.mapper.ext.ExtTestPlanMapper; import io.metersphere.commons.constants.APITestStatus; import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.ReportTriggerMode; @@ -24,8 +25,13 @@ import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.i18n.Translator; +import io.metersphere.track.dto.TestPlanDTO; +import io.metersphere.track.request.testcase.QueryTestPlanRequest; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.session.ExecutorType; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; import org.apache.jorphan.collections.HashTree; import org.apache.jorphan.collections.ListedHashTree; import org.aspectj.util.FileUtil; @@ -35,11 +41,9 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.io.*; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; @Service @Transactional(rollbackFor = Exception.class) @@ -56,6 +60,10 @@ public class ApiAutomationService { private ApiTestEnvironmentService environmentService; @Resource private ApiScenarioReportService apiReportService; + @Resource + private ExtTestPlanMapper extTestPlanMapper; + @Resource + SqlSessionFactory sqlSessionFactory; private static final String BODY_FILE_DIR = "/opt/metersphere/data/body"; @@ -306,7 +314,54 @@ public class ApiAutomationService { return request.getId(); } - public List getReference(ApiScenarioRequest request) { - return extApiScenarioMapper.selectReference(request); + public ReferenceDTO getReference(ApiScenarioRequest request) { + ReferenceDTO dto = new ReferenceDTO(); + dto.setScenarioList(extApiScenarioMapper.selectReference(request)); + QueryTestPlanRequest planRequest = new QueryTestPlanRequest(); + planRequest.setScenarioId(request.getId()); + planRequest.setProjectId(request.getProjectId()); + dto.setTestPlanList(extTestPlanMapper.selectReference(planRequest)); + return dto; } + + public String addScenarioToPlan(SaveApiPlanRequest request) { + if (CollectionUtils.isEmpty(request.getPlanIds())) { + MSException.throwException(Translator.get("plan id is null ")); + } + List list = extTestPlanMapper.selectByIds(request.getPlanIds()); + SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); + ExtTestPlanMapper mapper = sqlSession.getMapper(ExtTestPlanMapper.class); + list.forEach(item -> { + if (CollectionUtils.isNotEmpty(request.getApiIds())) { + if (CollectionUtils.isNotEmpty(request.getApiIds())) { + if (StringUtils.isEmpty(item.getApiIds())) { + item.setApiIds(JSON.toJSONString(request.getApiIds())); + } else { + // 合并api + List dbApiIDs = JSON.parseArray(item.getApiIds(), String.class); + List result = Stream.of(request.getApiIds(), dbApiIDs) + .flatMap(Collection::stream).distinct().collect(Collectors.toList()); + item.setApiIds(JSON.toJSONString(result)); + } + } + } + if (CollectionUtils.isNotEmpty(request.getScenarioIds())) { + if (CollectionUtils.isNotEmpty(request.getScenarioIds())) { + if (StringUtils.isEmpty(item.getScenarioIds())) { + item.setScenarioIds(JSON.toJSONString(request.getScenarioIds())); + } else { + // 合并场景ID + List dbScenarioIDs = JSON.parseArray(item.getScenarioIds(), String.class); + List result = Stream.of(request.getScenarioIds(), dbScenarioIDs) + .flatMap(Collection::stream).distinct().collect(Collectors.toList()); + item.setScenarioIds(JSON.toJSONString(result)); + } + } + } + mapper.updatePlan(item); + }); + sqlSession.flushStatements(); + return "success"; + } + } diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlan.java b/backend/src/main/java/io/metersphere/base/domain/TestPlan.java index 2d5ebe3aed..bf6a2a2503 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlan.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlan.java @@ -1,8 +1,9 @@ package io.metersphere.base.domain; -import java.io.Serializable; import lombok.Data; +import java.io.Serializable; + @Data public class TestPlan implements Serializable { private String id; @@ -39,6 +40,10 @@ public class TestPlan implements Serializable { private String creator; + private String apiIds; + + private String scenarioIds; + private String tags; private static final long serialVersionUID = 1L; diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanExample.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanExample.java index 4512f8f5d2..c8a2e528b8 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanExample.java @@ -1233,6 +1233,146 @@ public class TestPlanExample { addCriterion("creator not between", value1, value2, "creator"); return (Criteria) this; } + + public Criteria andApiIdsIsNull() { + addCriterion("api_ids is null"); + return (Criteria) this; + } + + public Criteria andApiIdsIsNotNull() { + addCriterion("api_ids is not null"); + return (Criteria) this; + } + + public Criteria andApiIdsEqualTo(String value) { + addCriterion("api_ids =", value, "apiIds"); + return (Criteria) this; + } + + public Criteria andApiIdsNotEqualTo(String value) { + addCriterion("api_ids <>", value, "apiIds"); + return (Criteria) this; + } + + public Criteria andApiIdsGreaterThan(String value) { + addCriterion("api_ids >", value, "apiIds"); + return (Criteria) this; + } + + public Criteria andApiIdsGreaterThanOrEqualTo(String value) { + addCriterion("api_ids >=", value, "apiIds"); + return (Criteria) this; + } + + public Criteria andApiIdsLessThan(String value) { + addCriterion("api_ids <", value, "apiIds"); + return (Criteria) this; + } + + public Criteria andApiIdsLessThanOrEqualTo(String value) { + addCriterion("api_ids <=", value, "apiIds"); + return (Criteria) this; + } + + public Criteria andApiIdsLike(String value) { + addCriterion("api_ids like", value, "apiIds"); + return (Criteria) this; + } + + public Criteria andApiIdsNotLike(String value) { + addCriterion("api_ids not like", value, "apiIds"); + return (Criteria) this; + } + + public Criteria andApiIdsIn(List values) { + addCriterion("api_ids in", values, "apiIds"); + return (Criteria) this; + } + + public Criteria andApiIdsNotIn(List values) { + addCriterion("api_ids not in", values, "apiIds"); + return (Criteria) this; + } + + public Criteria andApiIdsBetween(String value1, String value2) { + addCriterion("api_ids between", value1, value2, "apiIds"); + return (Criteria) this; + } + + public Criteria andApiIdsNotBetween(String value1, String value2) { + addCriterion("api_ids not between", value1, value2, "apiIds"); + return (Criteria) this; + } + + public Criteria andScenarioIdsIsNull() { + addCriterion("scenario_ids is null"); + return (Criteria) this; + } + + public Criteria andScenarioIdsIsNotNull() { + addCriterion("scenario_ids is not null"); + return (Criteria) this; + } + + public Criteria andScenarioIdsEqualTo(String value) { + addCriterion("scenario_ids =", value, "scenarioIds"); + return (Criteria) this; + } + + public Criteria andScenarioIdsNotEqualTo(String value) { + addCriterion("scenario_ids <>", value, "scenarioIds"); + return (Criteria) this; + } + + public Criteria andScenarioIdsGreaterThan(String value) { + addCriterion("scenario_ids >", value, "scenarioIds"); + return (Criteria) this; + } + + public Criteria andScenarioIdsGreaterThanOrEqualTo(String value) { + addCriterion("scenario_ids >=", value, "scenarioIds"); + return (Criteria) this; + } + + public Criteria andScenarioIdsLessThan(String value) { + addCriterion("scenario_ids <", value, "scenarioIds"); + return (Criteria) this; + } + + public Criteria andScenarioIdsLessThanOrEqualTo(String value) { + addCriterion("scenario_ids <=", value, "scenarioIds"); + return (Criteria) this; + } + + public Criteria andScenarioIdsLike(String value) { + addCriterion("scenario_ids like", value, "scenarioIds"); + return (Criteria) this; + } + + public Criteria andScenarioIdsNotLike(String value) { + addCriterion("scenario_ids not like", value, "scenarioIds"); + return (Criteria) this; + } + + public Criteria andScenarioIdsIn(List values) { + addCriterion("scenario_ids in", values, "scenarioIds"); + return (Criteria) this; + } + + public Criteria andScenarioIdsNotIn(List values) { + addCriterion("scenario_ids not in", values, "scenarioIds"); + return (Criteria) this; + } + + public Criteria andScenarioIdsBetween(String value1, String value2) { + addCriterion("scenario_ids between", value1, value2, "scenarioIds"); + return (Criteria) this; + } + + public Criteria andScenarioIdsNotBetween(String value1, String value2) { + addCriterion("scenario_ids not between", value1, value2, "scenarioIds"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestPlanMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestPlanMapper.xml index d423f2d073..9914deba41 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestPlanMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestPlanMapper.xml @@ -19,6 +19,8 @@ + + @@ -84,7 +86,7 @@ id, workspace_id, report_id, `name`, description, `status`, stage, principal, test_case_match_rule, executor_match_rule, create_time, update_time, actual_end_time, planned_start_time, - planned_end_time, actual_start_time, creator + planned_end_time, actual_start_time, creator, api_ids, scenario_ids tags @@ -143,15 +145,15 @@ stage, principal, test_case_match_rule, executor_match_rule, create_time, update_time, actual_end_time, planned_start_time, planned_end_time, - actual_start_time, creator, tags - ) + actual_start_time, creator, api_ids, + scenario_ids, tags) values (#{id,jdbcType=VARCHAR}, #{workspaceId,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{stage,jdbcType=VARCHAR}, #{principal,jdbcType=VARCHAR}, #{testCaseMatchRule,jdbcType=VARCHAR}, #{executorMatchRule,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{actualEndTime,jdbcType=BIGINT}, #{plannedStartTime,jdbcType=BIGINT}, #{plannedEndTime,jdbcType=BIGINT}, - #{actualStartTime,jdbcType=BIGINT}, #{creator,jdbcType=VARCHAR}, #{tags,jdbcType=LONGVARCHAR} - ) + #{actualStartTime,jdbcType=BIGINT}, #{creator,jdbcType=VARCHAR}, #{apiIds,jdbcType=VARCHAR}, + #{scenarioIds,jdbcType=VARCHAR}, #{tags,jdbcType=LONGVARCHAR}) insert into test_plan @@ -207,6 +209,12 @@ creator, + + api_ids, + + + scenario_ids, + tags, @@ -263,6 +271,12 @@ #{creator,jdbcType=VARCHAR}, + + #{apiIds,jdbcType=VARCHAR}, + + + #{scenarioIds,jdbcType=VARCHAR}, + #{tags,jdbcType=LONGVARCHAR}, @@ -328,6 +342,12 @@ creator = #{record.creator,jdbcType=VARCHAR}, + + api_ids = #{record.apiIds,jdbcType=VARCHAR}, + + + scenario_ids = #{record.scenarioIds,jdbcType=VARCHAR}, + tags = #{record.tags,jdbcType=LONGVARCHAR}, @@ -355,6 +375,8 @@ planned_end_time = #{record.plannedEndTime,jdbcType=BIGINT}, actual_start_time = #{record.actualStartTime,jdbcType=BIGINT}, creator = #{record.creator,jdbcType=VARCHAR}, + api_ids = #{record.apiIds,jdbcType=VARCHAR}, + scenario_ids = #{record.scenarioIds,jdbcType=VARCHAR}, tags = #{record.tags,jdbcType=LONGVARCHAR} @@ -378,7 +400,9 @@ planned_start_time = #{record.plannedStartTime,jdbcType=BIGINT}, planned_end_time = #{record.plannedEndTime,jdbcType=BIGINT}, actual_start_time = #{record.actualStartTime,jdbcType=BIGINT}, - creator = #{record.creator,jdbcType=VARCHAR} + creator = #{record.creator,jdbcType=VARCHAR}, + api_ids = #{record.apiIds,jdbcType=VARCHAR}, + scenario_ids = #{record.scenarioIds,jdbcType=VARCHAR} @@ -434,6 +458,12 @@ creator = #{creator,jdbcType=VARCHAR}, + + api_ids = #{apiIds,jdbcType=VARCHAR}, + + + scenario_ids = #{scenarioIds,jdbcType=VARCHAR}, + tags = #{tags,jdbcType=LONGVARCHAR}, @@ -458,6 +488,8 @@ planned_end_time = #{plannedEndTime,jdbcType=BIGINT}, actual_start_time = #{actualStartTime,jdbcType=BIGINT}, creator = #{creator,jdbcType=VARCHAR}, + api_ids = #{apiIds,jdbcType=VARCHAR}, + scenario_ids = #{scenarioIds,jdbcType=VARCHAR}, tags = #{tags,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -478,7 +510,9 @@ planned_start_time = #{plannedStartTime,jdbcType=BIGINT}, planned_end_time = #{plannedEndTime,jdbcType=BIGINT}, actual_start_time = #{actualStartTime,jdbcType=BIGINT}, - creator = #{creator,jdbcType=VARCHAR} + creator = #{creator,jdbcType=VARCHAR}, + api_ids = #{apiIds,jdbcType=VARCHAR}, + scenario_ids = #{scenarioIds,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/ExtTestPlanMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.java index a851758cb4..c6773c32cb 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.java @@ -1,8 +1,8 @@ package io.metersphere.base.mapper.ext; +import io.metersphere.track.dto.TestPlanDTO; import io.metersphere.track.dto.TestPlanDTOWithMetric; import io.metersphere.track.request.testcase.QueryTestPlanRequest; -import io.metersphere.track.dto.TestPlanDTO; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -13,4 +13,11 @@ public interface ExtTestPlanMapper { List listRelate(@Param("request") QueryTestPlanRequest params); List planList(@Param("request") QueryTestPlanRequest params); + + List selectByIds(@Param("list") List ids); + + int updatePlan(@Param("plan") TestPlanDTO plan); + + List selectReference(@Param("request") QueryTestPlanRequest params); + } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml index febab2f9f7..7bfe1039c9 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml @@ -172,4 +172,38 @@ ) order by test_plan.update_time desc + + + update test_plan + + + api_ids = #{plan.apiIds,jdbcType=VARCHAR} + + + scenario_ids = #{plan.scenarioIds,jdbcType=VARCHAR} + + + + id = #{plan.id} + + + + + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/track/request/testcase/QueryTestPlanRequest.java b/backend/src/main/java/io/metersphere/track/request/testcase/QueryTestPlanRequest.java index 6997e42691..cd521a5436 100644 --- a/backend/src/main/java/io/metersphere/track/request/testcase/QueryTestPlanRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/testcase/QueryTestPlanRequest.java @@ -16,6 +16,10 @@ public class QueryTestPlanRequest extends TestPlan { private List planIds; + private String scenarioId; + + private String apiId; + private List orders; private Map> filters; diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index cbf6fcdbe3..78bd291342 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -62,6 +62,10 @@ + + + + @@ -77,11 +81,11 @@ import MsApiReportDetail from "../report/ApiReportDetail"; import MsTableMoreBtn from "./TableMoreBtn"; import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns"; - + import MsTestPlanList from "./testplan/TestPlanList"; export default { name: "MsApiScenarioList", - components: {MsTablePagination, MsTableMoreBtn, ShowMoreBtn, MsTableHeader, MsTag, MsApiReportDetail, MsScenarioExtendButtons}, + components: {MsTablePagination, MsTableMoreBtn, ShowMoreBtn, MsTableHeader, MsTag, MsApiReportDetail, MsScenarioExtendButtons, MsTestPlanList}, props: { currentProject: Object, currentModule: Object, @@ -105,6 +109,7 @@ reportId: "", infoDb: false, runVisible: false, + planVisible: false, runData: [], buttons: [ { @@ -162,7 +167,14 @@ } }, handleBatchAddCase() { - + this.planVisible = true; + }, + addTestPlan(plans) { + let obj = {planIds: plans, scenarioIds: this.selection}; + this.planVisible = false; + this.$post("/api/automation/scenario/plan", obj, response => { + this.$success(this.$t("commons.save_success")); + }); }, handleBatchExecute() { this.infoDb = false; @@ -213,42 +225,6 @@ this.infoDb = true; this.reportId = row.reportId; }, - handleQuote() { - - }, - handleSchedule(row) { - this.currentScenario = row; - if (row.schedule) { - if (Object.prototype.toString.call(row.schedule).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') { - this.schedule = row.schedule; - } else { - this.schedule = JSON.parse(row.schedule); - } - } - this.$refs.scheduleEdit.open(); - }, - saveCronExpression(cronExpression) { - this.schedule.enable = true; - this.schedule.value = cronExpression; - this.saveSchedule(); - }, - saveSchedule() { - this.checkScheduleEdit(); - let param = {}; - param = this.schedule; - param.resourceId = this.currentScenario.id; - let url = '/api/automation/schedule/create'; - if (param.id) { - url = '/api/automation/schedule/update'; - } - this.$post(url, param, () => { - this.$success(this.$t('commons.save_success')); - this.search(); - }); - }, - checkScheduleEdit() { - return true; - }, remove(row) { if (this.currentModule !== undefined && this.currentModule != null && this.currentModule.id === "gc") { this.$get('/api/automation/delete/' + row.id, () => { diff --git a/frontend/src/business/components/api/automation/scenario/DebugRun.vue b/frontend/src/business/components/api/automation/scenario/DebugRun.vue index 6d153cce8f..e24015b171 100644 --- a/frontend/src/business/components/api/automation/scenario/DebugRun.vue +++ b/frontend/src/business/components/api/automation/scenario/DebugRun.vue @@ -93,7 +93,6 @@ testPlan.hashTree.push(threadGroup); let reqObj = {id: this.reportId, reportId: this.reportId, environmentId: this.environment, testElement: testPlan}; let bodyFiles = this.getBodyUploadFiles(reqObj); - console.log(bodyFiles) let url = "/api/automation/run/debug"; this.$fileUpload(url, null, bodyFiles, reqObj, response => { this.runId = response.data; diff --git a/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue b/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue index 8f03f1a610..6ea4043675 100644 --- a/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue @@ -57,7 +57,6 @@ importApiScenario() { let scenarios = []; if (this.currentScenario) { - console.log(this.currentScenario) this.currentScenario.forEach(item => { let obj = {id: item.id, name: item.name, type: "scenario", referenced: 'REF', resourceId: getUUID()}; scenarios.push(obj); diff --git a/frontend/src/business/components/api/automation/scenario/ReferenceView.vue b/frontend/src/business/components/api/automation/scenario/ReferenceView.vue index a57c532467..715c9dc552 100644 --- a/frontend/src/business/components/api/automation/scenario/ReferenceView.vue +++ b/frontend/src/business/components/api/automation/scenario/ReferenceView.vue @@ -39,7 +39,8 @@ export default { this.scenarioLoading = true; this.scenarioRefs = []; this.$post("/api/automation/getReference/", row, response => { - this.scenarioRefs = response.data; + this.scenarioRefs = response.data.scenarioList; + this.planRefs = response.data.testPlanList; this.scenarioLoading = false; }) }, diff --git a/frontend/src/business/components/api/automation/scenario/testplan/TestPlanList.vue b/frontend/src/business/components/api/automation/scenario/testplan/TestPlanList.vue new file mode 100644 index 0000000000..1799650db1 --- /dev/null +++ b/frontend/src/business/components/api/automation/scenario/testplan/TestPlanList.vue @@ -0,0 +1,302 @@ + + + + + diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 79fdf48885..145a571bdd 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -530,6 +530,7 @@ export default { extract_param: "Extract parameters", add_module: "Add module", edit_api: "Edit Api", + test_plan_select: "Please select test plan", } }, automation: { diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 7b6b8feea0..baa664be89 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -529,6 +529,7 @@ export default { extract_param: "提取参数", add_module: "创建模块", edit_api: "编辑接口", + test_plan_select: "请选择测试计划", } }, automation: { diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 9abb8c7558..7d152b14a2 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -529,6 +529,7 @@ export default { extract_param: "提取參數", add_module: "創建模塊", edit_api: "编辑接口", + test_plan_select: "請選擇測試計劃", } }, automation: {