diff --git a/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java b/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java index 8819e5d113..d46fd3cd4d 100644 --- a/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java +++ b/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java @@ -29,6 +29,11 @@ public class TestPlanTestCaseController { return PageUtils.setPageInfo(page, testPlanTestCaseService.getTestPlanCases(request)); } + @PostMapping("/list/all") + public List getTestPlanCases(@RequestBody QueryTestPlanCaseRequest request){ + return testPlanTestCaseService.getTestPlanCases(request); + } + @PostMapping("/edit") public void editTestCase(@RequestBody TestPlanTestCase testPlanTestCase){ testPlanTestCaseService.editTestCase(testPlanTestCase); diff --git a/backend/src/main/java/io/metersphere/report/JtlResolver.java b/backend/src/main/java/io/metersphere/report/GenerateReport.java similarity index 97% rename from backend/src/main/java/io/metersphere/report/JtlResolver.java rename to backend/src/main/java/io/metersphere/report/GenerateReport.java index 5e3b4d163e..870b4b6673 100644 --- a/backend/src/main/java/io/metersphere/report/JtlResolver.java +++ b/backend/src/main/java/io/metersphere/report/GenerateReport.java @@ -24,7 +24,7 @@ import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; -public class JtlResolver { +public class GenerateReport { private static final Integer ERRORS_TOP_SIZE = 5; private static final String DATE_TIME_PATTERN = "yyyy/MM/dd HH:mm:ss"; @@ -186,7 +186,7 @@ public class JtlResolver { } } - Map> jtlMap = falseList.stream().collect(Collectors.groupingBy(JtlResolver::getResponseCodeAndFailureMessage)); + Map> jtlMap = falseList.stream().collect(Collectors.groupingBy(GenerateReport::getResponseCodeAndFailureMessage)); for (Map.Entry> next : jtlMap.entrySet()) { String key = next.getKey(); @@ -219,7 +219,7 @@ public class JtlResolver { .collect(Collectors.toList()); Map> collect = falseList.stream() - .collect(Collectors.groupingBy(JtlResolver::getResponseCodeAndFailureMessage)); + .collect(Collectors.groupingBy(GenerateReport::getResponseCodeAndFailureMessage)); for (Map.Entry> next : collect.entrySet()) { String key = next.getKey(); @@ -270,9 +270,9 @@ public class JtlResolver { TestOverview testOverview = new TestOverview(); DecimalFormat decimalFormat = new DecimalFormat("0.00"); - List totalLineList = JtlResolver.resolver(jtlString); + List totalLineList = GenerateReport.resolver(jtlString); // todo 修改测试概览的数值 - List totalLineList2 = JtlResolver.resolver(jtlString); + List totalLineList2 = GenerateReport.resolver(jtlString); // 时间戳转时间 for (Metric metric : totalLineList2) { metric.setTimestamp(stampToDate(DATE_TIME_PATTERN, metric.getTimestamp())); @@ -355,7 +355,7 @@ public class JtlResolver { public static ReportTimeInfo getReportTimeInfo(String jtlString) { ReportTimeInfo reportTimeInfo = new ReportTimeInfo(); - List totalLineList = JtlResolver.resolver(jtlString); + List totalLineList = GenerateReport.resolver(jtlString); totalLineList.sort(Comparator.comparing(t0 -> Long.valueOf(t0.getTimestamp()))); diff --git a/backend/src/main/java/io/metersphere/service/ReportService.java b/backend/src/main/java/io/metersphere/service/ReportService.java index 38c2e88c92..a833a5a07a 100644 --- a/backend/src/main/java/io/metersphere/service/ReportService.java +++ b/backend/src/main/java/io/metersphere/service/ReportService.java @@ -11,7 +11,7 @@ import io.metersphere.controller.request.ReportRequest; import io.metersphere.dto.ReportDTO; import io.metersphere.engine.Engine; import io.metersphere.engine.EngineFactory; -import io.metersphere.report.JtlResolver; +import io.metersphere.report.GenerateReport; import io.metersphere.report.base.ChartsData; import io.metersphere.report.base.Errors; import io.metersphere.report.base.ReportTimeInfo; @@ -90,7 +90,7 @@ public class ReportService { checkReportStatus(id); LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id); String content = loadTestReport.getContent(); - RequestStatisticsDTO requestStatistics = JtlResolver.getRequestStatistics(content); + RequestStatisticsDTO requestStatistics = GenerateReport.getRequestStatistics(content); return requestStatistics; } @@ -98,7 +98,7 @@ public class ReportService { checkReportStatus(id); LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id); String content = loadTestReport.getContent(); - List errors = JtlResolver.getErrorsList(content); + List errors = GenerateReport.getErrorsList(content); return errors; } @@ -106,7 +106,7 @@ public class ReportService { checkReportStatus(id); LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id); String content = loadTestReport.getContent(); - ErrorsTop5DTO errors = JtlResolver.getErrorsTop5DTO(content); + ErrorsTop5DTO errors = GenerateReport.getErrorsTop5DTO(content); return errors; } @@ -114,7 +114,7 @@ public class ReportService { checkReportStatus(id); LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id); String content = loadTestReport.getContent(); - TestOverview testOverview = JtlResolver.getTestOverview(content); + TestOverview testOverview = GenerateReport.getTestOverview(content); return testOverview; } @@ -122,7 +122,7 @@ public class ReportService { checkReportStatus(id); LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id); String content = loadTestReport.getContent(); - ReportTimeInfo reportTimeInfo = JtlResolver.getReportTimeInfo(content); + ReportTimeInfo reportTimeInfo = GenerateReport.getReportTimeInfo(content); return reportTimeInfo; } @@ -130,7 +130,7 @@ public class ReportService { checkReportStatus(id); LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id); String content = loadTestReport.getContent(); - List chartsDataList = JtlResolver.getLoadChartData(content); + List chartsDataList = GenerateReport.getLoadChartData(content); return chartsDataList; } @@ -138,7 +138,7 @@ public class ReportService { checkReportStatus(id); LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(id); String content = loadTestReport.getContent(); - List chartsDataList = JtlResolver.getResponseTimeChartData(content); + List chartsDataList = GenerateReport.getResponseTimeChartData(content); return chartsDataList; } diff --git a/frontend/src/business/components/api/test/ApiTestConfig.vue b/frontend/src/business/components/api/test/ApiTestConfig.vue index a85f5edc15..50d26f98b1 100644 --- a/frontend/src/business/components/api/test/ApiTestConfig.vue +++ b/frontend/src/business/components/api/test/ApiTestConfig.vue @@ -8,13 +8,13 @@ - + 保存 - + @@ -35,9 +35,10 @@ projects: [], change: false, test: { + id: null, projectId: null, name: null, - scenario_definition: [] + scenarioDefinition: [] } } }, @@ -53,11 +54,21 @@ methods: { saveTest: function () { - this.change = false; - this.$message({ - message: this.$t('commons.save_success'), - type: 'success' + + let param = { + id: this.test.id, + projectId: this.test.projectId, + name: this.test.name, + scenarioDefinition: JSON.stringify(this.test.scenarioDefinition) + } + + this.result = this.$post("/api/save", param, response => { + this.test.id = response.data; + this.$message({ + message: this.$t('commons.save_success'), + type: 'success' + }); }); } }, diff --git a/frontend/src/business/components/api/test/components/ApiAssertionRegex.vue b/frontend/src/business/components/api/test/components/ApiAssertionRegex.vue index 3c53617938..bc61db655b 100644 --- a/frontend/src/business/components/api/test/components/ApiAssertionRegex.vue +++ b/frontend/src/business/components/api/test/components/ApiAssertionRegex.vue @@ -4,9 +4,9 @@ - - - + + + diff --git a/frontend/src/business/components/api/test/components/ApiAssertionText.vue b/frontend/src/business/components/api/test/components/ApiAssertionText.vue index 9916f71637..20bc6840c6 100644 --- a/frontend/src/business/components/api/test/components/ApiAssertionText.vue +++ b/frontend/src/business/components/api/test/components/ApiAssertionText.vue @@ -4,19 +4,19 @@ - - - + + + - - - - - + + + + + diff --git a/frontend/src/business/components/api/test/components/ApiKeyValue.vue b/frontend/src/business/components/api/test/components/ApiKeyValue.vue index ed90e30d78..12aff27318 100644 --- a/frontend/src/business/components/api/test/components/ApiKeyValue.vue +++ b/frontend/src/business/components/api/test/components/ApiKeyValue.vue @@ -12,8 +12,21 @@ - + + + + + +
+ + + + + + + + +
@@ -31,45 +44,33 @@ items: Array }, + data() { + return { + kv: new KeyValue() + } + }, + methods: { add: function () { - this.items.push(new KeyValue()); + if (this.kv.key || this.kv.value) { + this.items.push(this.kv); + this.kv = new KeyValue(); + } }, remove: function (index) { this.items.splice(index, 1); - if (this.items.length === 0) { - this.add(); - } }, check: function () { - let isNeedCreate = true; let removeIndex = -1; this.items.forEach((item, index) => { if (!item.key && !item.value) { - // 多余的空行 - if (index !== this.items.length - 1) { - removeIndex = index; - } - // 没有空行,需要创建空行 - isNeedCreate = false; + removeIndex = index; } }); - if (isNeedCreate) { - this.add(); - } if (removeIndex !== -1) { this.remove(removeIndex); } // TODO 检查key重复 - }, - isDisable: function (index) { - return this.items.length - 1 === index; - } - }, - - created() { - if (this.items.length === 0) { - this.add(); } } } diff --git a/frontend/src/business/components/api/test/components/ApiRequestConfig.vue b/frontend/src/business/components/api/test/components/ApiRequestConfig.vue index 9746e52699..7e6f87a15d 100644 --- a/frontend/src/business/components/api/test/components/ApiRequestConfig.vue +++ b/frontend/src/business/components/api/test/components/ApiRequestConfig.vue @@ -11,7 +11,7 @@
- + 复制请求 删除请求 diff --git a/frontend/src/business/components/api/test/components/ApiRequestForm.vue b/frontend/src/business/components/api/test/components/ApiRequestForm.vue index 0ddf3375e9..34b0791f57 100644 --- a/frontend/src/business/components/api/test/components/ApiRequestForm.vue +++ b/frontend/src/business/components/api/test/components/ApiRequestForm.vue @@ -1,20 +1,20 @@