diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index b1a5ff5701..22c78ad384 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONType; import io.metersphere.api.dto.definition.request.MsTestElement; import io.metersphere.api.dto.definition.request.ParameterConfig; +import io.metersphere.api.dto.definition.request.auth.MsAuthManager; import io.metersphere.api.dto.definition.request.dns.MsDNSCacheManager; import io.metersphere.api.dto.scenario.Body; import io.metersphere.api.dto.scenario.KeyValue; @@ -87,6 +88,9 @@ public class MsHTTPSamplerProxy extends MsTestElement { @JSONField(ordinal = 35) private Object requestResult; + @JSONField(ordinal = 36) + private MsAuthManager authManager; + @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { @@ -223,6 +227,9 @@ public class MsHTTPSamplerProxy extends MsTestElement { el.toHashTree(httpSamplerTree, el.getHashTree(), config); } } + if (this.authManager != null) { + this.authManager.toHashTree(tree, hashTree, config); + } } private boolean isVariable(String path, String value) { diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java index fa7fbebfde..adb1757e92 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java @@ -88,6 +88,12 @@ public class ApiDefinitionExecResultService { * @param type */ public void saveApiResultByScheduleTask(TestResult result, String type) { + String saveResultType = type; + if(StringUtils.equalsAny(ApiRunMode.SCHEDULE_API_PLAN.name(),saveResultType)){ + saveResultType = ApiRunMode.API_PLAN.name(); + } + + String finalSaveResultType = saveResultType; result.getScenarios().get(0).getRequestResults().forEach(item -> { ApiDefinitionExecResult saveResult = new ApiDefinitionExecResult(); saveResult.setId(UUID.randomUUID().toString()); @@ -98,7 +104,7 @@ public class ApiDefinitionExecResultService { saveResult.setStartTime(item.getStartTime()); String status = item.isSuccess() ? "success" : "error"; saveResult.setEndTime(item.getResponseResult().getResponseTime()); - saveResult.setType(type); + saveResult.setType(finalSaveResultType); saveResult.setStatus(status); String userID = null; @@ -107,6 +113,7 @@ public class ApiDefinitionExecResultService { String scheduleCreateUser = testPlanService.findScheduleCreateUserById(apiCase.getTestPlanId()); userID = scheduleCreateUser; apiCase.setStatus(status); + apiCase.setUpdateTime(System.currentTimeMillis()); testPlanApiCaseService.updateByPrimaryKeySelective(apiCase); } else { userID = Objects.requireNonNull(SessionUtils.getUser()).getId(); diff --git a/backend/src/main/java/io/metersphere/job/sechedule/TestPlanTestJob.java b/backend/src/main/java/io/metersphere/job/sechedule/TestPlanTestJob.java index aad6505a13..facd021288 100644 --- a/backend/src/main/java/io/metersphere/job/sechedule/TestPlanTestJob.java +++ b/backend/src/main/java/io/metersphere/job/sechedule/TestPlanTestJob.java @@ -27,25 +27,23 @@ import java.util.*; */ public class TestPlanTestJob extends MsScheduleJob { private String projectID; - private Map planScenarioIdMap; - private Map apiTestCaseIdMap; - private Map performanceIdMap; - private PerformanceTestService performanceTestService; - private TestPlanScenarioCaseService testPlanScenarioCaseService; - private TestPlanApiCaseService testPlanApiCaseService; - private ApiTestCaseService apiTestCaseService; - private TestPlanReportService testPlanReportService; - private TestPlanLoadCaseService testPlanLoadCaseService; + +// private PerformanceTestService performanceTestService; +// private TestPlanScenarioCaseService testPlanScenarioCaseService; +// private TestPlanApiCaseService testPlanApiCaseService; +// private ApiTestCaseService apiTestCaseService; +// private TestPlanReportService testPlanReportService; +// private TestPlanLoadCaseService testPlanLoadCaseService; private TestPlanService testPlanService; public TestPlanTestJob() { - this.performanceTestService = CommonBeanFactory.getBean(PerformanceTestService.class); - this.testPlanScenarioCaseService = CommonBeanFactory.getBean(TestPlanScenarioCaseService.class); - this.testPlanApiCaseService = CommonBeanFactory.getBean(TestPlanApiCaseService.class); - this.apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class); - this.testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class); - this.testPlanLoadCaseService = CommonBeanFactory.getBean(TestPlanLoadCaseService.class); +// this.performanceTestService = CommonBeanFactory.getBean(PerformanceTestService.class); +// this.testPlanScenarioCaseService = CommonBeanFactory.getBean(TestPlanScenarioCaseService.class); +// this.testPlanApiCaseService = CommonBeanFactory.getBean(TestPlanApiCaseService.class); +// this.apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class); +// this.testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class); +// this.testPlanLoadCaseService = CommonBeanFactory.getBean(TestPlanLoadCaseService.class); this.testPlanService = CommonBeanFactory.getBean(TestPlanService.class); @@ -67,100 +65,14 @@ public class TestPlanTestJob extends MsScheduleJob { this.expression = jobDataMap.getString("expression"); this.projectID = jobDataMap.getString("projectId"); - planScenarioIdMap = new LinkedHashMap<>(); - apiTestCaseIdMap = new LinkedHashMap<>(); - performanceIdMap = new LinkedHashMap<>(); - List testPlanApiScenarioList = testPlanScenarioCaseService.getCasesByPlanId(this.resourceId); - for (TestPlanApiScenario model :testPlanApiScenarioList) { - planScenarioIdMap.put(model.getApiScenarioId(),model.getId()); - } - List testPlanApiCaseList = testPlanApiCaseService.getCasesByPlanId(this.resourceId); - for (TestPlanApiCase model : - testPlanApiCaseList) { - apiTestCaseIdMap.put(model.getApiCaseId(),model.getId()); - } - - LoadCaseRequest loadCaseRequest = new LoadCaseRequest(); - loadCaseRequest.setTestPlanId(this.resourceId); - loadCaseRequest.setProjectId(this.projectID); - List testPlanLoadCaseDTOList = testPlanLoadCaseService.list(loadCaseRequest); - for (TestPlanLoadCaseDTO dto : testPlanLoadCaseDTOList) { - performanceIdMap.put(dto.getId(),dto.getLoadCaseId()); - } businessExecute(context); } @Override void businessExecute(JobExecutionContext context) { - LogUtil.info("-------------- start testplan schedule ----------"); - //首先创建testPlanReport,然后返回的ID重新赋值为resourceID,作为后续的参数 - TestPlanReport testPlanReport = testPlanReportService.genTestPlanReport(this.resourceId,this.userId,ReportTriggerMode.SCHEDULE.name()); - //执行接口案例任务 - for (Map.Entry entry: this.apiTestCaseIdMap.entrySet()) { - String apiCaseID = entry.getKey(); - String planCaseID = entry.getValue(); - ApiTestCaseWithBLOBs blobs = apiTestCaseService.get(apiCaseID); - //需要更新这里来保证PlanCase的状态能正常更改 - apiTestCaseService.run(blobs,UUID.randomUUID().toString(),testPlanReport.getId(),this.resourceId,ApiRunMode.SCHEDULE_API_PLAN.name()); - } - - //执行场景执行任务 - if(!planScenarioIdMap.isEmpty()){ - LogUtil.info("-------------- testplan schedule ---------- api case over -----------------"); - SchedulePlanScenarioExecuteRequest scenarioRequest = new SchedulePlanScenarioExecuteRequest(); - String senarionReportID = UUID.randomUUID().toString(); - scenarioRequest.setId(senarionReportID); - scenarioRequest.setReportId(senarionReportID); - scenarioRequest.setProjectId(projectID); - scenarioRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name()); - scenarioRequest.setExecuteType(ExecuteType.Saved.name()); - Map> testPlanScenarioIdMap = new HashMap<>(); - testPlanScenarioIdMap.put(resourceId, this.planScenarioIdMap); - scenarioRequest.setTestPlanScenarioIDMap(testPlanScenarioIdMap); - scenarioRequest.setReportUserID(this.userId); - scenarioRequest.setTestPlanID(this.resourceId); - scenarioRequest.setRunMode(ApiRunMode.SCHEDULE_SCENARIO_PLAN.name()); - scenarioRequest.setTestPlanReportId(testPlanReport.getId()); - testPlanService.runScenarioCase(scenarioRequest); - LogUtil.info("-------------- testplan schedule ---------- scenario case over -----------------"); - } - //执行性能测试任务 - List performaneReportIDList = new ArrayList<>(); - for (Map.Entry entry: this.performanceIdMap.entrySet()) { - String id = entry.getKey(); - String caseID = entry.getValue(); - RunTestPlanRequest performanceRequest = new RunTestPlanRequest(); - performanceRequest.setId(caseID); - performanceRequest.setTestPlanLoadId(caseID); - performanceRequest.setTriggerMode(ReportTriggerMode.TEST_PLAN_SCHEDULE.name()); - String reportId = null; - try { - reportId = performanceTestService.run(performanceRequest); - if(reportId!=null){ - performaneReportIDList.add(reportId); - - TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase(); - testPlanLoadCase.setId(performanceRequest.getTestPlanLoadId()); - testPlanLoadCase.setLoadReportId(reportId); - testPlanLoadCaseService.update(testPlanLoadCase); - } - }catch (Exception e){ - e.printStackTrace(); - } - //更新关联处的报告 - TestPlanLoadCase loadCase = new TestPlanLoadCaseDTO(); - loadCase.setId(id); - loadCase.setLoadReportId(reportId); - testPlanLoadCaseService.update(loadCase); - } - - if(!performaneReportIDList.isEmpty()){ - //性能测试时保存性能测试报告ID,在结果返回时用于捕捉并进行 - testPlanReportService.updatePerformanceInfo(testPlanReport,performaneReportIDList,ReportTriggerMode.SCHEDULE.name()); - } - + testPlanService.run(this.resourceId,this.projectID,this.userId,ReportTriggerMode.SCHEDULE.name()); } public static JobKey getJobKey(String testId) { diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java index 1e1e9ccbcc..c688c2a4b3 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -362,8 +362,12 @@ public class TestPlanReportService { testPlan.setStatus(TestPlanStatus.Completed.name()); testPlanMapper.updateByPrimaryKeySelective(testPlan); } - //发送通知 - sendMessage(report); + + if(StringUtils.equalsAny(report.getTriggerMode(),ReportTriggerMode.SCHEDULE.name())){ + //发送通知 + sendMessage(report); + } + } catch (Exception e) { } @@ -401,11 +405,20 @@ public class TestPlanReportService { paramMap.put("type", "testPlan"); paramMap.put("url", url); paramMap.put("status", testPlanReport.getStatus()); + + String successfulMailTemplate = ""; + String errfoMailTemplate = ""; + + if(StringUtils.equals(testPlanReport.getTriggerMode(),ReportTriggerMode.SCHEDULE.name())){ + successfulMailTemplate = "TestPlanSuccessfulNotification"; + errfoMailTemplate = "TestPlanFailedNotification"; + } + NoticeModel noticeModel = NoticeModel.builder() .successContext(successContext) - .successMailTemplate("TestPlanSuccessfulNotification") + .successMailTemplate(successfulMailTemplate) .failedContext(failedContext) - .failedMailTemplate("TestPlanFailedNotification") + .failedMailTemplate(errfoMailTemplate) .testId(testPlan.getId()) .status(testPlanReport.getStatus()) .event(event) diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index f245d46f98..c6651c55f2 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -7,16 +7,14 @@ import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; -import io.metersphere.api.dto.automation.ApiScenarioDTO; -import io.metersphere.api.dto.automation.ScenarioStatus; -import io.metersphere.api.dto.automation.SchedulePlanScenarioExecuteRequest; -import io.metersphere.api.dto.automation.TestPlanScenarioRequest; +import io.metersphere.api.dto.automation.*; import io.metersphere.api.dto.definition.ApiTestCaseRequest; import io.metersphere.api.dto.definition.TestPlanApiCaseDTO; import io.metersphere.api.dto.definition.request.*; import io.metersphere.api.dto.definition.request.variable.ScenarioVariable; import io.metersphere.api.jmeter.JMeterService; import io.metersphere.api.service.ApiAutomationService; +import io.metersphere.api.service.ApiTestCaseService; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.*; @@ -28,6 +26,7 @@ import io.metersphere.dto.BaseSystemConfigDTO; import io.metersphere.i18n.Translator; import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.service.NoticeSendService; +import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.service.ScheduleService; import io.metersphere.service.SystemParameterService; import io.metersphere.track.Factory.ReportComponentFactory; @@ -37,6 +36,7 @@ import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testplan.AddTestPlanRequest; import io.metersphere.track.request.testplan.LoadCaseRequest; +import io.metersphere.track.request.testplan.RunTestPlanRequest; import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.annotations.Param; @@ -109,6 +109,10 @@ public class TestPlanService { private ExtTestPlanLoadCaseMapper extTestPlanLoadCaseMapper; @Resource private ExtTestPlanScenarioCaseMapper extTestPlanScenarioCaseMapper; + @Resource + private ApiTestCaseService apiTestCaseService; + @Resource + private PerformanceTestService performanceTestService; public synchronized void addTestPlan(AddTestPlanRequest testPlan) { if (getTestPlanByName(testPlan.getName()).size() > 0) { @@ -858,4 +862,100 @@ public class TestPlanService { jMeterService.runDefinition(request.getId(), jmeterHashTree, request.getReportId(), runMode); return request.getId(); } + + public void run(String testPlanID,String projectID,String userId,String triggerMode){ + Map planScenarioIdMap; + Map apiTestCaseIdMap; + Map performanceIdMap; + + planScenarioIdMap = new LinkedHashMap<>(); + apiTestCaseIdMap = new LinkedHashMap<>(); + performanceIdMap = new LinkedHashMap<>(); + + List testPlanApiScenarioList = testPlanScenarioCaseService.getCasesByPlanId(testPlanID); + for (TestPlanApiScenario model :testPlanApiScenarioList) { + planScenarioIdMap.put(model.getApiScenarioId(),model.getId()); + } + List testPlanApiCaseList = testPlanApiCaseService.getCasesByPlanId(testPlanID); + for (TestPlanApiCase model : + testPlanApiCaseList) { + apiTestCaseIdMap.put(model.getApiCaseId(),model.getId()); + } + + LoadCaseRequest loadCaseRequest = new LoadCaseRequest(); + loadCaseRequest.setTestPlanId(testPlanID); + loadCaseRequest.setProjectId(projectID); + List testPlanLoadCaseDTOList = testPlanLoadCaseService.list(loadCaseRequest); + for (TestPlanLoadCaseDTO dto : testPlanLoadCaseDTOList) { + performanceIdMap.put(dto.getId(),dto.getLoadCaseId()); + } + + LogUtil.info("-------------- start testplan schedule ----------"); + TestPlanReportService testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class); + //首先创建testPlanReport,然后返回的ID重新赋值为resourceID,作为后续的参数 + TestPlanReport testPlanReport = testPlanReportService.genTestPlanReport(testPlanID,userId,triggerMode); + //执行接口案例任务 + for (Map.Entry entry: apiTestCaseIdMap.entrySet()) { + String apiCaseID = entry.getKey(); + String planCaseID = entry.getValue(); + ApiTestCaseWithBLOBs blobs = apiTestCaseService.get(apiCaseID); + //需要更新这里来保证PlanCase的状态能正常更改 + apiTestCaseService.run(blobs,UUID.randomUUID().toString(),testPlanReport.getId(),testPlanID,ApiRunMode.SCHEDULE_API_PLAN.name()); + } + + //执行场景执行任务 + if(!planScenarioIdMap.isEmpty()){ + LogUtil.info("-------------- testplan schedule ---------- api case over -----------------"); + SchedulePlanScenarioExecuteRequest scenarioRequest = new SchedulePlanScenarioExecuteRequest(); + String senarionReportID = UUID.randomUUID().toString(); + scenarioRequest.setId(senarionReportID); + scenarioRequest.setReportId(senarionReportID); + scenarioRequest.setProjectId(projectID); + scenarioRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name()); + scenarioRequest.setExecuteType(ExecuteType.Saved.name()); + Map> testPlanScenarioIdMap = new HashMap<>(); + testPlanScenarioIdMap.put(testPlanID, planScenarioIdMap); + scenarioRequest.setTestPlanScenarioIDMap(testPlanScenarioIdMap); + scenarioRequest.setReportUserID(userId); + scenarioRequest.setTestPlanID(testPlanID); + scenarioRequest.setRunMode(ApiRunMode.SCHEDULE_SCENARIO_PLAN.name()); + scenarioRequest.setTestPlanReportId(testPlanReport.getId()); + this.runScenarioCase(scenarioRequest); + LogUtil.info("-------------- testplan schedule ---------- scenario case over -----------------"); + } + //执行性能测试任务 + List performaneReportIDList = new ArrayList<>(); + for (Map.Entry entry: performanceIdMap.entrySet()) { + String id = entry.getKey(); + String caseID = entry.getValue(); + RunTestPlanRequest performanceRequest = new RunTestPlanRequest(); + performanceRequest.setId(caseID); + performanceRequest.setTestPlanLoadId(caseID); + performanceRequest.setTriggerMode(ReportTriggerMode.TEST_PLAN_SCHEDULE.name()); + String reportId = null; + try { + reportId = performanceTestService.run(performanceRequest); + if(reportId!=null){ + performaneReportIDList.add(reportId); + + TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase(); + testPlanLoadCase.setId(performanceRequest.getTestPlanLoadId()); + testPlanLoadCase.setLoadReportId(reportId); + testPlanLoadCaseService.update(testPlanLoadCase); + } + }catch (Exception e){ + e.printStackTrace(); + } + //更新关联处的报告 + TestPlanLoadCase loadCase = new TestPlanLoadCaseDTO(); + loadCase.setId(id); + loadCase.setLoadReportId(reportId); + testPlanLoadCaseService.update(loadCase); + } + + if(!performaneReportIDList.isEmpty()){ + //性能测试时保存性能测试报告ID,在结果返回时用于捕捉并进行 + testPlanReportService.updatePerformanceInfo(testPlanReport,performaneReportIDList,ReportTriggerMode.SCHEDULE.name()); + } + } } diff --git a/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue b/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue index 11eba3314f..1d1798ec5a 100644 --- a/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue @@ -1,15 +1,17 @@ @@ -150,6 +151,7 @@ .enable-switch { margin-right: 10px; } + fieldset { padding: 0px; margin: 0px; diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index 433d9ef3f8..5fae058169 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -107,6 +107,15 @@ this.request.url = undefined; } } + // 历史数据 auth 处理 + if (this.request.hashTree) { + for (let index in this.request.hashTree) { + if (this.request.hashTree[index].type == 'AuthManager') { + this.request.authManager = this.request.hashTree[index]; + this.request.hashTree.splice(index, 1); + } + } + } } }, computed: { diff --git a/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue b/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue index 8e9a5cd98e..59e4c6c13c 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue @@ -70,6 +70,8 @@ case ELEMENT_TYPE.scenario: name = "MsApiScenarioComponent"; break; + case "AuthManager": + break; default: name = "MsApiComponent"; break; @@ -107,7 +109,7 @@ suggestClick(node) { this.$emit('suggestClick', node); }, - refReload(){ + refReload() { this.$emit('refReload'); } } diff --git a/frontend/src/business/components/api/definition/components/auth/ApiAuthConfig.vue b/frontend/src/business/components/api/definition/components/auth/ApiAuthConfig.vue index 2fc2b7136b..0f9fa7a651 100644 --- a/frontend/src/business/components/api/definition/components/auth/ApiAuthConfig.vue +++ b/frontend/src/business/components/api/definition/components/auth/ApiAuthConfig.vue @@ -3,7 +3,7 @@ - + @@ -50,9 +50,7 @@ - - @@ -66,11 +64,17 @@ request: {}, }, created() { - for (let index in this.request.hashTree) { - if (this.request.hashTree[index].type == 'AuthManager') { - this.authConfig = this.request.hashTree[index]; + if (this.request.hashTree) { + for (let index in this.request.hashTree) { + if (this.request.hashTree[index].type == 'AuthManager') { + this.request.authManager = this.request.hashTree[index]; + this.request.hashTree.splice(index, 1); + } } } + if (this.request.authManager) { + this.authConfig = this.request.authManager; + } }, data() { return { 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 08f54fca93..7b160b9a1b 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue @@ -147,7 +147,6 @@ saveApiAndCase(api) { this.visible = true; this.api = api; - console.log(api) this.addCase(); }, setEnvironment(environment) { diff --git a/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue index ce99bcbdcc..ac34fc7110 100644 --- a/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue +++ b/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue @@ -198,22 +198,18 @@ }, urlChange() { if (!this.debugForm.url) return; - let url = this.getURL(this.addProtocol(this.debugForm.url)); - if (url) { + let url = this.getURL(this.debugForm.url); + if (url && url.pathname) { if (this.debugForm.url.indexOf('?') != -1) { this.debugForm.url = decodeURIComponent(this.debugForm.url.substr(0, this.debugForm.url.indexOf("?"))); } this.debugForm.path = url.pathname; + } else { + this.debugForm.path = url; } + }, - addProtocol(url) { - if (url) { - if (!url.toLowerCase().startsWith("https") && !url.toLowerCase().startsWith("http")) { - return "https://" + url; - } - } - return url; - }, + getURL(urlStr) { try { let url = new URL(urlStr); @@ -224,7 +220,7 @@ }); return url; } catch (e) { - this.$error(this.$t('api_test.request.url_invalid'), 2000); + return urlStr; } }, } diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 2cc47aeab8..3d7b54e1d1 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -530,7 +530,7 @@ export default { request: { grade_info: "Filter by rank", grade_order_asc: "from high to low by use case level", - grade_order_desc: "from high to low by use case level,", + grade_order_desc: "from low to high by use case level,", create_time_order_asc: "by creation time from front to back", create_time_order_desc: "from back to front by creation time,", update_time_order_asc: "by update time from front to back", diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index c33bef9ed2..9c9f5ef10f 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -530,7 +530,7 @@ export default { request: { grade_info: "按等级筛选", grade_order_asc: "按用例等级从高到低", - grade_order_desc: "按用例等级从高到低", + grade_order_desc: "按用例等级从低到高", create_time_order_asc: "按创建时间从前到后", create_time_order_desc: "按创建时间从后到前", update_time_order_asc: "按更新时间从前到后", diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index e0ad97d891..ef1230efc6 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -529,7 +529,7 @@ export default { request: { grade_info: "按等級篩選", grade_order_asc: "按用例等級從高到低", - grade_order_desc: "按用例等級從高到低", + grade_order_desc: "按用例等級從低到高", create_time_order_asc: "按創建時間從前到後", create_time_order_desc: "按創建時間從後到前", update_time_order_asc: "按更新時間從前到後",