From 0f88a8168b0118f563759de9740cb8204ddff8e5 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Wed, 23 Dec 2020 17:00:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E5=8F=AA=E8=AF=BB=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8=E8=8A=B1?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/controller/ApiAutomationController.java | 1 + 1 file changed, 1 insertion(+) 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 70cb742f59..fd7e1e3b1b 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java @@ -31,6 +31,7 @@ public class ApiAutomationController { @PostMapping("/list/{goPage}/{pageSize}") + @RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR) public Pager> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiScenarioRequest request) { Page page = PageHelper.startPage(goPage, pageSize, true); request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); From 8238ee323b8eedd28e3cbbe88c634148ce6c89df Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 23 Dec 2020 17:17:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E5=9B=9E=E6=94=B6=E7=AB=99=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=E9=97=AE=E9=A2=98=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E5=85=A8=E9=80=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/scenario/ApiScenarioList.vue | 1 + .../automation/scenario/EditApiScenario.vue | 4 +- .../automation/scenario/api/ApiCaseList.vue | 353 +++++------------- 3 files changed, 102 insertions(+), 256 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index bf94769711..34fc1f7703 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -226,6 +226,7 @@ }, reductionApi(row) { row.scenarioDefinition = null; + row.tags = null; let rows = [row]; this.$post("/api/automation/reduction", rows, response => { this.$success(this.$t('commons.save_success')); diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index e215b76665..ee872a5f32 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -224,7 +224,7 @@ - + {{$t('api_test.scenario.reference')}} {{ $t('commons.copy') }} @@ -839,7 +839,7 @@ } .ms-col-one { - margin-top: 6px; + margin-top: 5px; } .ms-right-buttion { diff --git a/frontend/src/business/components/api/automation/scenario/api/ApiCaseList.vue b/frontend/src/business/components/api/automation/scenario/api/ApiCaseList.vue index d9edb209bd..85bca98545 100644 --- a/frontend/src/business/components/api/automation/scenario/api/ApiCaseList.vue +++ b/frontend/src/business/components/api/automation/scenario/api/ApiCaseList.vue @@ -4,21 +4,24 @@ - + + 全选 + +
{{api.name}}
- + {{ api.method}} - +
{{api.path ===null ? " " : api.path}}
- +
{{$t('test_track.plan_view.case_count')}}:{{apiCaseList.length}}
- +
@@ -26,28 +29,7 @@
- -
- - - - {{ $t('api_test.environment.environment_config') }} - - - -
-
- +
@@ -61,76 +43,67 @@ - - - - -
- - - - - - -
-
{{index+1}}
-
- - - - - -
- - - - - {{item.type!= 'create' ? item.name:''}} - - -
- - {{item.createTime | timestampFormatDate }} - {{item.createUser}} {{$t('api_test.definition.request.create_info')}} + + +
+ + + + + + + + + + + + + + {{item.name}} - - {{item.updateTime | timestampFormatDate }} - {{item.updateUser}} {{$t('api_test.definition.request.update_info')}} - -
- +
+ + {{item.createTime | timestampFormatDate }} + {{item.createUser}} {{$t('api_test.definition.request.create_info')}} + + + {{item.updateTime | timestampFormatDate }} + {{item.updateUser}} {{$t('api_test.definition.request.update_info')}} + +
+ - -
{{getResult(item.execResult)}}
-
- {{item.updateTime | timestampFormatDate }} - {{item.updateUser}} -
-
- - - -
-

{{$t('api_test.definition.request.req_param')}}

+ +
{{getResult(item.execResult)}}
+
+ {{item.updateTime | timestampFormatDate }} + {{item.updateUser}} +
+
+ + + +
+

{{$t('api_test.definition.request.req_param')}}

+ + + + + + + + {{$t('commons.save')}} + +
+
+ +
+
- - - - - - - {{$t('commons.save')}} - -
- -
-
@@ -143,8 +116,6 @@ import MsTipButton from "../../../../common/components/MsTipButton"; import MsApiRequestForm from "../../../definition/components/request/http/ApiRequestForm"; import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils"; - import {parseEnvironment} from "../../../definition/model/EnvironmentModel"; - import ApiEnvironmentConfig from "../../../definition/components/environment/ApiEnvironmentConfig"; import {PRIORITY, RESULT_MAP} from "../../../definition/model/JsonData"; import MsApiAssertions from "../../../definition/components/assertion/ApiAssertions"; import MsSqlBasisParameters from "../../../definition/components/request/database/BasisParameters"; @@ -159,7 +130,6 @@ MsTag, MsTipButton, MsApiRequestForm, - ApiEnvironmentConfig, MsApiAssertions, MsSqlBasisParameters, MsTcpBasisParameters, @@ -192,8 +162,12 @@ runData: [], reportId: "", projectId: "", - checkedCases: new Set(), methodColorMap: new Map(API_METHOD_COLOUR), + + checkAll: false, + checkedIndex: [], + isIndeterminate: true + } }, watch: { @@ -207,7 +181,6 @@ }, created() { this.projectId = getCurrentProjectID(); - this.getEnvironments(); this.getApiTest(); }, methods: { @@ -218,11 +191,6 @@ return RESULT_MAP.get("default"); } }, - handleCommand(e) { - if (e === "run") { - this.batchRun(); - } - }, showInput(row) { row.type = "create"; row.active = true; @@ -232,112 +200,12 @@ this.apiCaseList = []; this.$emit('apiCaseClose'); }, - batchRun() { - if (!this.environment) { - this.$warning(this.$t('api_test.environment.select_environment')); - return; - } - this.loading = true; - if (this.apiCaseList.length > 0) { - this.apiCaseList.forEach(item => { - if (item.type != "create") { - item.request.name = item.id; - item.request.useEnvironment = this.environment.id; - this.runData.push(item.request); - } - }) - this.loading = true; - /*触发执行操作*/ - this.reportId = getUUID().substring(0, 8); - } else { - this.$warning("没有可执行的用例!"); - } - }, - singleRun(row) { - if (!this.environment) { - this.$warning(this.$t('api_test.environment.select_environment')); - return; - } - this.runData = []; - this.loading = true; - row.request.name = row.id; - row.request.useEnvironment = this.environment.id; - this.runData.push(row.request); - /*触发执行操作*/ - this.reportId = getUUID().substring(0, 8); - }, - runRefresh(data) { - this.loading = false; - this.$success(this.$t('schedule.event_success')); - this.getApiTest(); - this.$emit('refresh'); - }, - deleteCase(index, row) { - this.$get('/api/testcase/delete/' + row.id, () => { - this.$success(this.$t('commons.delete_success')); - this.apiCaseList.splice(index, 1); - this.$emit('refresh'); - }); - }, - copyCase(data) { - let obj = {name: data.name, priority: data.priority, type: 'create', active: false, request: data.request}; - this.apiCaseList.unshift(obj); - }, - addCase() { - // 初始化对象 - let request = {}; - if (this.api.request instanceof Object) { - request = this.api.request; - } else { - request = JSON.parse(this.api.request); - } - let obj = {apiDefinitionId: this.api.id, name: '', priority: 'P0', type: 'create', active: false}; - obj.request = request; - this.apiCaseList.unshift(obj); - }, active(item) { item.active = !item.active; }, - getBodyUploadFiles(row) { - let bodyUploadFiles = []; - row.bodyUploadIds = []; - let request = row.request; - if (request.body && request.body.kvs) { - request.body.kvs.forEach(param => { - if (param.files) { - param.files.forEach(item => { - if (item.file) { - let fileId = getUUID().substring(0, 8); - item.name = item.file.name; - item.id = fileId; - row.bodyUploadIds.push(fileId); - bodyUploadFiles.push(item.file); - } - }); - } - }); - if (request.body.binary) { - request.body.binary.forEach(param => { - if (param.files) { - param.files.forEach(item => { - if (item.file) { - let fileId = getUUID().substring(0, 8); - item.name = item.file.name; - item.id = fileId; - row.bodyUploadIds.push(fileId); - bodyUploadFiles.push(item.file); - } - }); - } - }); - } - } - return bodyUploadFiles; - }, getApiTest() { if (this.api) { - this.checkedCases = new Set(); this.loading = true; if (this.currentRow) { this.currentRow.cases = []; @@ -364,61 +232,40 @@ return true; } }, - getEnvironments() { - if (this.projectId) { - this.$get('/api/environment/list/' + this.projectId, response => { - this.environments = response.data; - this.environments.forEach(environment => { - parseEnvironment(environment); - }); - let hasEnvironment = false; - for (let i in this.environments) { - if (this.api && this.environments[i].id === this.api.environmentId) { - hasEnvironment = true; - break; - } - } - if (!hasEnvironment) { - this.environment = undefined; - } - }); - } else { - this.environment = undefined; - } - }, - openEnvironmentConfig() { - if (!this.projectId) { - this.$error(this.$t('api_test.select_project')); - return; - } - this.$refs.environmentConfig.open(this.projectId); - }, - environmentChange(value) { - for (let i in this.environments) { - if (this.environments[i].id === value) { - this.environment = this.environments[i]; - break; - } - } - }, - environmentConfigClose() { - this.getEnvironments(); - }, + getColor(enable, method) { if (enable) { return this.methodColorMap.get(method); } }, - caseChecked(row) { - row.protocol = this.api.protocol; - row.hashTree = []; - if (this.checkedCases.has(row)) { - this.checkedCases.delete(row); + handleCheckAllChange(val) { + this.currentRow.cases = []; + if (val) { + let index = 1; + this.apiCaseList.forEach(item => { + this.checkedIndex.push(index); + item.protocol = this.api.protocol; + item.hashTree = []; + this.currentRow.cases.push(item) + index++; + }) } else { - this.checkedCases.add(row) + this.checkedIndex = []; } - let arr = Array.from(this.checkedCases); - this.currentRow.cases = arr; + this.isIndeterminate = false; + }, + handleCheckedChange(value) { + let checkedCount = value.length; + this.checkAll = checkedCount === this.apiCaseList.length; + this.isIndeterminate = checkedCount > 0 && checkedCount < this.apiCaseList.length; + this.currentRow.cases = []; + value.forEach(i => { + let index = i - 1; + let item = this.apiCaseList[index]; + item.protocol = this.api.protocol; + item.hashTree = []; + this.currentRow.cases.push(item); + }) } } } @@ -449,14 +296,11 @@ } .ms-api-label { - color: #CCCCCC; + /*color: #CCCCCC;*/ } .ms-api-col { - background-color: #7C3985; - border-color: #7C3985; - margin-right: 10px; - color: white; + margin-top: 5px; } .variable-combine { @@ -486,6 +330,7 @@ .api-el-tag { color: white; } + .is-selected { background: #EFF7FF; }