diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/RunDefinitionRequest.java b/backend/src/main/java/io/metersphere/api/dto/definition/RunDefinitionRequest.java index 592e9ad0c9..b329cfcffa 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/RunDefinitionRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/RunDefinitionRequest.java @@ -15,6 +15,8 @@ public class RunDefinitionRequest { private String reportId; + private String name; + private String type; private String projectId; 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 8089c6f4d7..47c77263df 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -246,6 +246,7 @@ public class ApiAutomationService { }); scenario.setVariables(variables); } + group.setEnableCookieShare(scenario.isEnableCookieShare()); LinkedList scenarios = new LinkedList<>(); scenarios.add(scenario); group.setHashTree(scenarios); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 907b610bb0..5275448ee0 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -16,10 +16,13 @@ import io.metersphere.base.mapper.TestPlanApiScenarioMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper; import io.metersphere.commons.constants.APITestStatus; import io.metersphere.commons.constants.ApiRunMode; +import io.metersphere.commons.constants.ReportTriggerMode; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.DateUtils; +import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.i18n.Translator; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -28,10 +31,7 @@ import sun.security.util.Cache; import javax.annotation.Resource; import java.nio.charset.StandardCharsets; import java.text.DecimalFormat; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; @Service @Transactional(rollbackFor = Exception.class) @@ -55,6 +55,13 @@ public class ApiScenarioReportService { MSException.throwException(Translator.get("api_report_is_null")); } APIScenarioReportResult report = (APIScenarioReportResult) obj; + if (CollectionUtils.isNotEmpty(result.getScenarios())) { + try { + report.setName(result.getScenarios().get(0).getName() + "-" + DateUtils.getTimeString(System.currentTimeMillis())); + } catch (Exception e) { + LogUtil.error(e.getMessage()); + } + } // report detail ApiScenarioReportDetail detail = new ApiScenarioReportDetail(); detail.setReportId(result.getTestId()); @@ -72,7 +79,9 @@ public class ApiScenarioReportService { } report.setContent(new String(detail.getContent(), StandardCharsets.UTF_8)); this.save(report, runMode); - cache.put(report.getId(), report); + if (!report.getTriggerMode().equals(ReportTriggerMode.SCHEDULE.name())) { + cache.put(report.getId(), report); + } } /** diff --git a/backend/src/main/java/io/metersphere/job/sechedule/ApiScenarioTestJob.java b/backend/src/main/java/io/metersphere/job/sechedule/ApiScenarioTestJob.java index 42e8b70f81..cb6be7bdaa 100644 --- a/backend/src/main/java/io/metersphere/job/sechedule/ApiScenarioTestJob.java +++ b/backend/src/main/java/io/metersphere/job/sechedule/ApiScenarioTestJob.java @@ -1,9 +1,7 @@ package io.metersphere.job.sechedule; -import io.metersphere.api.dto.SaveAPITestRequest; import io.metersphere.api.dto.automation.ExecuteType; import io.metersphere.api.dto.automation.RunScenarioRequest; -import io.metersphere.api.service.APITestService; import io.metersphere.api.service.ApiAutomationService; import io.metersphere.commons.constants.ReportTriggerMode; import io.metersphere.commons.constants.ScheduleGroup; @@ -56,7 +54,7 @@ public class ApiScenarioTestJob extends MsScheduleJob { request.setId(id); request.setReportId(id); request.setProjectId(projectID); - request.setTriggerMode(ReportTriggerMode.MANUAL.name()); + request.setTriggerMode(ReportTriggerMode.SCHEDULE.name()); request.setExecuteType(ExecuteType.Completed.name()); request.setScenarioIds(this.scenarioIds); request.setReportUserID(this.userId); diff --git a/frontend/src/business/components/api/automation/report/ApiReportList.vue b/frontend/src/business/components/api/automation/report/ApiReportList.vue index 6919193a43..c26086dcd2 100644 --- a/frontend/src/business/components/api/automation/report/ApiReportList.vue +++ b/frontend/src/business/components/api/automation/report/ApiReportList.vue @@ -69,7 +69,7 @@ import MsContainer from "../../../common/components/MsContainer"; import MsMainContainer from "../../../common/components/MsMainContainer"; import MsApiReportStatus from "./ApiReportStatus"; - import {_filter, _sort} from "@/common/js/utils"; + import {_filter, _sort,getCurrentProjectID} from "@/common/js/utils"; import MsTableOperatorButton from "../../../common/components/MsTableOperatorButton"; import ReportTriggerModeItem from "../../../common/tableItem/ReportTriggerModeItem"; import {REPORT_CONFIGS} from "../../../common/components/search/search-components"; @@ -130,6 +130,7 @@ if (this.testId !== 'all') { this.condition.testId = this.testId; } + this.condition.projectId = getCurrentProjectID(); let url = "/api/scenario/report/list/" + this.currentPage + "/" + this.pageSize; this.result = this.$post(url, this.condition, response => { let data = response.data; diff --git a/frontend/src/business/components/api/automation/report/components/RequestResultTail.vue b/frontend/src/business/components/api/automation/report/components/RequestResultTail.vue index 500eaa2f1c..7c1ccaf628 100644 --- a/frontend/src/business/components/api/automation/report/components/RequestResultTail.vue +++ b/frontend/src/business/components/api/automation/report/components/RequestResultTail.vue @@ -19,19 +19,14 @@ + :key="index" :indexNumber="index" :request="sub"/> - - -
- +
- -
- +
diff --git a/frontend/src/business/components/api/automation/report/components/RequestSubResult.vue b/frontend/src/business/components/api/automation/report/components/RequestSubResult.vue index 53e26c0c27..fa258162ac 100644 --- a/frontend/src/business/components/api/automation/report/components/RequestSubResult.vue +++ b/frontend/src/business/components/api/automation/report/components/RequestSubResult.vue @@ -3,7 +3,7 @@

- +
{{ indexNumber+1 }}
@@ -14,7 +14,16 @@ {{ request.name }}
- + +
+ {{ request.method }} +
+
+ +
+ {{ request.url }} +
+
{{ request.responseResult.responseCode }}
diff --git a/frontend/src/business/components/api/automation/report/components/ResponseText.vue b/frontend/src/business/components/api/automation/report/components/ResponseText.vue index d07d044d00..5d10582ba0 100644 --- a/frontend/src/business/components/api/automation/report/components/ResponseText.vue +++ b/frontend/src/business/components/api/automation/report/components/ResponseText.vue @@ -1,18 +1,19 @@ diff --git a/frontend/src/business/components/api/automation/scenario/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/ApiComponent.vue index 895c4f66c5..70acb87907 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiComponent.vue @@ -5,15 +5,22 @@
{{request.index}}
+
+
{{request.index}}
+
{{request.index}}
- + {{$t('api_test.automation.api_list_import')}} - + + {{$t('api_test.automation.external_import')}} + + + {{$t('api_test.automation.customize_req')}} @@ -196,7 +203,7 @@ color: #F56C6C; } - .ms-left-buttion { + .ms-left-button { color: #F56C6C; background-color: #FCF1F1; margin-right: 20px; @@ -209,6 +216,19 @@ color: #008080; } + .ms-api-col-ot-import { + background-color: #EEF5FE; + border-color: #409EFF; + margin-right: 10px; + color: #409EFF; + } + + .ms-api-col-ot-import-button { + background-color: #EEF5FE; + margin-right: 20px; + color: #409EFF; + } + /deep/ .el-card__body { padding: 15px; } @@ -217,7 +237,7 @@ transform: rotate(90deg); } - .ms-create-buttion { + .ms-create-button { color: #008080; background-color: #EBF2F2; margin-right: 20px; diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 04c37fa135..e215b76665 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -782,7 +782,7 @@ apiImport(importData) { if (importData && importData.data) { importData.data.forEach(item => { - this.setApiParameter(item, "API", "Copy"); + this.setApiParameter(item, "API", "OT_IMPORT"); }) this.sort(); this.reload(); diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index 5f0719a8a3..07edcab884 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -78,10 +78,10 @@
- - - - + + + +
diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue index 8ecfbe2067..64f0acbc46 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue @@ -172,9 +172,9 @@ } } this.apiCaseList = response.data; - // if (this.apiCaseList.length == 0) { - // this.addCase(); - // } + if (this.apiCaseList.length == 0 && !this.loaded) { + this.addCase(); + } }); } }, diff --git a/frontend/src/business/components/api/definition/components/complete/EditCompleteDubboApi.vue b/frontend/src/business/components/api/definition/components/complete/EditCompleteDubboApi.vue index b6b9c0f58a..84380d6fa3 100644 --- a/frontend/src/business/components/api/definition/components/complete/EditCompleteDubboApi.vue +++ b/frontend/src/business/components/api/definition/components/complete/EditCompleteDubboApi.vue @@ -22,7 +22,7 @@

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

- +
diff --git a/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue b/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue index 0ceffaca5b..9648a9bbb3 100644 --- a/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue +++ b/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue @@ -77,7 +77,7 @@

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

- +
diff --git a/frontend/src/business/components/api/definition/components/complete/EditCompleteSQLApi.vue b/frontend/src/business/components/api/definition/components/complete/EditCompleteSQLApi.vue index 8ffbd2e577..54bc58ea4e 100644 --- a/frontend/src/business/components/api/definition/components/complete/EditCompleteSQLApi.vue +++ b/frontend/src/business/components/api/definition/components/complete/EditCompleteSQLApi.vue @@ -21,7 +21,7 @@

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

- +
diff --git a/frontend/src/business/components/api/definition/components/request/database/BasisParameters.vue b/frontend/src/business/components/api/definition/components/request/database/BasisParameters.vue index 63fb764d8d..a58ad0ae54 100644 --- a/frontend/src/business/components/api/definition/components/request/database/BasisParameters.vue +++ b/frontend/src/business/components/api/definition/components/request/database/BasisParameters.vue @@ -77,7 +77,7 @@ - + +{{$t('api_test.definition.request.pre_script')}}
@@ -120,6 +120,10 @@ request: {}, basisData: {}, moduleOptions: Array, + showScript: { + type: Boolean, + default: true, + }, isReadOnly: { type: Boolean, default: false @@ -172,7 +176,7 @@ this.reload(); }, copyRow(row) { - let obj =JSON.parse(JSON.stringify(row)); + let obj = JSON.parse(JSON.stringify(row)); obj.id = getUUID(); this.request.hashTree.push(obj); this.reload(); diff --git a/frontend/src/business/components/api/definition/components/request/dubbo/BasisParameters.vue b/frontend/src/business/components/api/definition/components/request/dubbo/BasisParameters.vue index 64a4065e72..9e3057827b 100644 --- a/frontend/src/business/components/api/definition/components/request/dubbo/BasisParameters.vue +++ b/frontend/src/business/components/api/definition/components/request/dubbo/BasisParameters.vue @@ -57,7 +57,7 @@
- + +{{$t('api_test.definition.request.pre_script')}}
+{{$t('api_test.definition.request.post_script')}} @@ -105,6 +105,10 @@ type: Boolean, default: false }, + showScript: { + type: Boolean, + default: true, + } }, data() { return { @@ -141,7 +145,7 @@ this.reload(); }, copyRow(row) { - let obj =JSON.parse(JSON.stringify(row)); + let obj = JSON.parse(JSON.stringify(row)); obj.id = getUUID(); this.request.hashTree.push(obj); this.reload(); diff --git a/frontend/src/business/components/api/definition/components/request/http/ApiHttpRequestForm.vue b/frontend/src/business/components/api/definition/components/request/http/ApiHttpRequestForm.vue index 47301e9c71..ef886a900d 100644 --- a/frontend/src/business/components/api/definition/components/request/http/ApiHttpRequestForm.vue +++ b/frontend/src/business/components/api/definition/components/request/http/ApiHttpRequestForm.vue @@ -85,7 +85,7 @@
- + +{{$t('api_test.definition.request.pre_script')}}
+{{$t('api_test.definition.request.post_script')}} @@ -131,6 +131,7 @@ }, props: { request: {}, + showScript: Boolean, headers: { type: Array, default() { diff --git a/frontend/src/business/components/api/definition/components/request/http/ApiRequestForm.vue b/frontend/src/business/components/api/definition/components/request/http/ApiRequestForm.vue index de97afb499..0f2274df8a 100644 --- a/frontend/src/business/components/api/definition/components/request/http/ApiRequestForm.vue +++ b/frontend/src/business/components/api/definition/components/request/http/ApiRequestForm.vue @@ -1,6 +1,6 @@ @@ -17,6 +17,10 @@ type: Boolean, default: true }, + showScript: { + type: Boolean, + default: true, + }, referenced: { type: Boolean, default: false diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue index 8d1f43638d..4179a65ab4 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue @@ -29,7 +29,7 @@ - @@ -104,6 +104,9 @@ return this.runTest(); } }, + refresh(){ + this.$emit('refresh'); + }, runTest() { this.loading = true; this.api.request.name = this.api.id; diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue index e3c2b2ddfd..861047c291 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue @@ -70,7 +70,7 @@ - { diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue index c6094c3108..3a52f408dc 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue @@ -28,7 +28,7 @@ - @@ -103,6 +103,9 @@ return this.$refs['requestForm'].validate(); } }, + refresh(){ + this.$emit('refresh'); + }, runTest() { this.loading = true; this.api.request.name = this.api.id; diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue index a9afdda538..687083ad33 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue @@ -29,7 +29,7 @@ - @@ -103,6 +103,9 @@ return this.$refs['requestForm'].validate(); } }, + refresh(){ + this.$emit('refresh'); + }, runTest() { this.loading = true; this.api.request.name = this.api.id;