diff --git a/api-test/backend/src/main/java/io/metersphere/listener/ProjectCreatedListener.java b/api-test/backend/src/main/java/io/metersphere/listener/ProjectCreatedListener.java index af84756ec2..9380cda2fa 100644 --- a/api-test/backend/src/main/java/io/metersphere/listener/ProjectCreatedListener.java +++ b/api-test/backend/src/main/java/io/metersphere/listener/ProjectCreatedListener.java @@ -1,21 +1,21 @@ package io.metersphere.listener; -import io.metersphere.base.domain.ApiModule; -import io.metersphere.base.domain.ModuleNode; -import io.metersphere.base.domain.Project; +import io.metersphere.base.domain.*; import io.metersphere.base.mapper.ApiModuleMapper; +import io.metersphere.base.mapper.ApiScenarioModuleMapper; import io.metersphere.base.mapper.ProjectMapper; import io.metersphere.base.mapper.ext.BaseModuleNodeMapper; import io.metersphere.commons.constants.KafkaTopicConstants; import io.metersphere.commons.constants.ProjectModuleDefaultNodeEnum; import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.LogUtil; -import io.metersphere.commons.utils.SessionUtils; +import org.apache.commons.collections.CollectionUtils; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.springframework.kafka.annotation.KafkaListener; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.util.List; import java.util.UUID; @Component @@ -28,6 +28,8 @@ public class ProjectCreatedListener { @Resource private ApiModuleMapper apiModuleMapper; @Resource + private ApiScenarioModuleMapper apiScenarioModuleMapper; + @Resource private ProjectMapper projectMapper; @@ -52,7 +54,12 @@ public class ProjectCreatedListener { record.setUpdateTime(System.currentTimeMillis()); record.setProjectId(projectId); record.setName(ProjectModuleDefaultNodeEnum.API_SCENARIO_DEFAULT_NODE.getNodeName()); - baseModuleNodeMapper.insert(ProjectModuleDefaultNodeEnum.API_SCENARIO_DEFAULT_NODE.getTableName(), record); + ApiScenarioModuleExample scenarioModuleExample = new ApiScenarioModuleExample(); + scenarioModuleExample.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo(ProjectModuleDefaultNodeEnum.API_SCENARIO_DEFAULT_NODE.getNodeName()).andParentIdIsNull(); + List scenarioModules = apiScenarioModuleMapper.selectByExample(scenarioModuleExample); + if (CollectionUtils.isEmpty(scenarioModules)) { + baseModuleNodeMapper.insert(ProjectModuleDefaultNodeEnum.API_SCENARIO_DEFAULT_NODE.getTableName(), record); + } ApiModule apiRecord = new ApiModule(); BeanUtils.copyBean(apiRecord, record); apiRecord.setName(ProjectModuleDefaultNodeEnum.API_MODULE_DEFAULT_NODE.getNodeName()); @@ -60,7 +67,12 @@ public class ProjectCreatedListener { for (String protocol : protocols) { apiRecord.setProtocol(protocol); apiRecord.setId(UUID.randomUUID().toString()); - apiModuleMapper.insert(apiRecord); + ApiModuleExample apiExample = new ApiModuleExample(); + apiExample.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo(ProjectModuleDefaultNodeEnum.API_MODULE_DEFAULT_NODE.getNodeName()).andParentIdIsNull(); + List apiList = apiModuleMapper.selectByExample(apiExample); + if (CollectionUtils.isEmpty(apiList)) { + apiModuleMapper.insert(apiRecord); + } } } } diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionImportUtil.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionImportUtil.java index 7e41354d09..dcd8a49aac 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionImportUtil.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionImportUtil.java @@ -9,6 +9,7 @@ import io.metersphere.base.domain.*; import io.metersphere.base.mapper.ApiModuleMapper; import io.metersphere.base.mapper.ApiTestCaseMapper; import io.metersphere.commons.constants.NoticeConstants; +import io.metersphere.commons.constants.ProjectModuleDefaultNodeEnum; import io.metersphere.commons.constants.PropertyConstant; import io.metersphere.commons.enums.ApiTestDataStatus; import io.metersphere.commons.utils.BeanUtils; @@ -355,7 +356,7 @@ public class ApiDefinitionImportUtil { public static void setModule(ApiDefinitionWithBLOBs item, ApiModuleMapper apiModuleMapper) { if (item != null && StringUtils.isEmpty(item.getModuleId()) || "default-module".equals(item.getModuleId())) { ApiModuleExample example = new ApiModuleExample(); - example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo("未规划接口"); + example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo(ProjectModuleDefaultNodeEnum.API_MODULE_DEFAULT_NODE.getNodeName()); List modules = apiModuleMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(modules)) { item.setModuleId(modules.get(0).getId()); diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java index 1e44428a86..a50b3f1831 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java @@ -1003,7 +1003,7 @@ public class ApiDefinitionService { private void setModule(ApiDefinitionWithBLOBs item) { if (item != null && StringUtils.isEmpty(item.getModuleId()) || "default-module".equals(item.getModuleId())) { ApiModuleExample example = new ApiModuleExample(); - example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo("未规划接口"); + example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo(ProjectModuleDefaultNodeEnum.API_MODULE_DEFAULT_NODE.getNodeName()); List modules = apiModuleMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(modules)) { item.setModuleId(modules.get(0).getId()); @@ -1840,7 +1840,7 @@ public class ApiDefinitionService { public void initModulePathAndId(String projectId, ApiDefinitionWithBLOBs test) { ApiModuleExample example = new ApiModuleExample(); - example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(test.getProtocol()).andNameEqualTo("未规划接口").andLevelEqualTo(1); + example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(test.getProtocol()).andNameEqualTo(ProjectModuleDefaultNodeEnum.API_MODULE_DEFAULT_NODE.getNodeName()).andLevelEqualTo(1); List modules = apiModuleMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(modules)) { test.setModuleId(modules.get(0).getId()); diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiModuleService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiModuleService.java index 1e8d1d577f..268f31dcef 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiModuleService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiModuleService.java @@ -1,24 +1,15 @@ package io.metersphere.service.definition; import io.metersphere.api.dto.ApiTestImportRequest; -import io.metersphere.api.dto.definition.ApiDefinitionRequest; -import io.metersphere.api.dto.definition.ApiDefinitionResult; -import io.metersphere.api.dto.definition.ApiModuleDTO; -import io.metersphere.api.dto.definition.ApiTestCaseRequest; -import io.metersphere.api.dto.definition.DragModuleRequest; -import io.metersphere.api.dto.definition.UpdateApiModuleDTO; +import io.metersphere.api.dto.definition.*; import io.metersphere.api.parse.api.ApiDefinitionImport; -import io.metersphere.base.domain.ApiDefinition; -import io.metersphere.base.domain.ApiDefinitionExample; -import io.metersphere.base.domain.ApiDefinitionWithBLOBs; -import io.metersphere.base.domain.ApiModule; -import io.metersphere.base.domain.ApiModuleExample; -import io.metersphere.base.domain.ApiTestCaseWithBLOBs; +import io.metersphere.base.domain.*; import io.metersphere.base.mapper.ApiDefinitionMapper; import io.metersphere.base.mapper.ApiModuleMapper; import io.metersphere.base.mapper.ext.ExtApiDefinitionMapper; import io.metersphere.base.mapper.ext.ExtApiModuleMapper; import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper; +import io.metersphere.commons.constants.ProjectModuleDefaultNodeEnum; import io.metersphere.commons.constants.PropertyConstant; import io.metersphere.commons.constants.TestCaseConstants; import io.metersphere.commons.enums.ApiTestDataStatus; @@ -40,19 +31,12 @@ import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.jetbrains.annotations.NotNull; import org.mybatis.spring.SqlSessionUtils; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -204,7 +188,7 @@ public class ApiModuleService extends NodeTreeService { return getNodeTrees(apiModules); } - public List getNodeTreeByCondition(String projectId, String protocol, String versionId, ApiDefinitionRequest request ) { + public List getNodeTreeByCondition(String projectId, String protocol, String versionId, ApiDefinitionRequest request) { // 判断当前项目下是否有默认模块,没有添加默认模块 this.getDefaultNode(projectId, protocol); List apiModules = getApiModulesByProjectAndPro(projectId, protocol); @@ -588,32 +572,33 @@ public class ApiModuleService extends NodeTreeService { public ApiModule getDefaultNode(String projectId, String protocol) { ApiModuleExample example = new ApiModuleExample(); - example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo("未规划接口").andParentIdIsNull(); + example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo(ProjectModuleDefaultNodeEnum.API_MODULE_DEFAULT_NODE.getNodeName()).andParentIdIsNull(); List list = apiModuleMapper.selectByExample(example); if (CollectionUtils.isEmpty(list)) { - ApiModule record = new ApiModule(); - record.setId(UUID.randomUUID().toString()); - record.setName("未规划接口"); - record.setProtocol(protocol); - record.setPos(1.0); - record.setLevel(1); - record.setCreateTime(System.currentTimeMillis()); - record.setUpdateTime(System.currentTimeMillis()); - record.setProjectId(projectId); - record.setCreateUser(SessionUtils.getUserId()); - apiModuleMapper.insert(record); - return record; + return saveDefault(projectId, protocol); } else { return list.get(0); } } - public ApiModule getDefaultNodeUnCreateNew(String projectId, String protocol) { + @Async + public synchronized ApiModule saveDefault(String projectId, String protocol) { ApiModuleExample example = new ApiModuleExample(); - example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo("未规划接口").andParentIdIsNull(); + example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo(ProjectModuleDefaultNodeEnum.API_MODULE_DEFAULT_NODE.getNodeName()).andParentIdIsNull(); List list = apiModuleMapper.selectByExample(example); if (CollectionUtils.isEmpty(list)) { - return null; + ApiModule module = new ApiModule(); + module.setId(UUID.randomUUID().toString()); + module.setName(ProjectModuleDefaultNodeEnum.API_MODULE_DEFAULT_NODE.getNodeName()); + module.setProtocol(protocol); + module.setPos(1.0); + module.setLevel(1); + module.setCreateTime(System.currentTimeMillis()); + module.setUpdateTime(System.currentTimeMillis()); + module.setProjectId(projectId); + module.setCreateUser(SessionUtils.getUserId()); + apiModuleMapper.insert(module); + return module; } else { return list.get(0); } @@ -666,7 +651,7 @@ public class ApiModuleService extends NodeTreeService { if (protocol.equals("HTTP")) { return dealHttp(data, pidChildrenMap, idPathMap, idModuleMap, request, fullCoverage, urlRepeat, importCases); } else { - return delOtherProtocol(data, pidChildrenMap, idPathMap, idModuleMap, request, fullCoverage, importCases); + return delOtherProtocol(data, pidChildrenMap, idPathMap, idModuleMap, request, fullCoverage, importCases); } } @@ -693,7 +678,7 @@ public class ApiModuleService extends NodeTreeService { //处理模块 setModule(moduleMap, pidChildrenMap, idPathMap, idModuleMap, optionData, chooseModule); - return getUpdateApiModuleDTO(chooseModule,idPathMap,optionData,fullCoverage, moduleMap,optionDataCases); + return getUpdateApiModuleDTO(chooseModule, idPathMap, optionData, fullCoverage, moduleMap, optionDataCases); } private UpdateApiModuleDTO dealHttp(List data, @@ -722,8 +707,7 @@ public class ApiModuleService extends NodeTreeService { setModule(moduleMap, pidChildrenMap, idPathMap, idModuleMap, optionData, chooseModule); - - return getUpdateApiModuleDTO(chooseModule,idPathMap,optionData,fullCoverage, moduleMap,optionDataCases); + return getUpdateApiModuleDTO(chooseModule, idPathMap, optionData, fullCoverage, moduleMap, optionDataCases); } @@ -752,7 +736,7 @@ public class ApiModuleService extends NodeTreeService { } } - private UpdateApiModuleDTO getUpdateApiModuleDTO(ApiModuleDTO chooseModule,Map idPathMap,List optionData,Boolean fullCoverage,Map moduleMap, List optionDataCases) { + private UpdateApiModuleDTO getUpdateApiModuleDTO(ApiModuleDTO chooseModule, Map idPathMap, List optionData, Boolean fullCoverage, Map moduleMap, List optionDataCases) { UpdateApiModuleDTO updateApiModuleDTO = new UpdateApiModuleDTO(); updateApiModuleDTO.setChooseModule(chooseModule); updateApiModuleDTO.setIdPathMap(idPathMap); @@ -822,7 +806,7 @@ public class ApiModuleService extends NodeTreeService { //导入时即没选中模块,接口自身也没模块的,直接返会当前项目,当前协议下的默认模块 List moduleList = pidChildrenMap.get(PropertyConstant.ROOT); for (ApiModule module : moduleList) { - if (module.getName().equals("未规划接口")) { + if (module.getName().equals(ProjectModuleDefaultNodeEnum.API_MODULE_DEFAULT_NODE.getNodeName())) { datum.setModuleId(module.getId()); datum.setModulePath("/" + module.getName()); } @@ -846,6 +830,7 @@ public class ApiModuleService extends NodeTreeService { datum.setModulePath(idPathMap.get(chooseModule.getId())); } } + public String[] getPathTree(String modulePath) { String substring = modulePath.substring(0, 1); if (substring.equals("/")) { diff --git a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java index a211918032..17b5cf8575 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java @@ -339,11 +339,19 @@ public class TestPlanScenarioCaseService { if (envMap != null && !envMap.isEmpty()) { env = JSON.toJSONString(envMap); } + } else { + Map existMap = JSON.parseObject(env, Map.class); + if (existMap.isEmpty()) { + if (envMap != null && !envMap.isEmpty()) { + env = JSON.toJSONString(envMap); + } + } } Map map = JSON.parseObject(env, Map.class); if (map.isEmpty()) { continue; } + Set set = map.keySet(); for (String s : set) { if (StringUtils.isNotBlank(envMap.get(s))) { diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioModuleService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioModuleService.java index cac52aed90..e14f733843 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioModuleService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioModuleService.java @@ -11,6 +11,7 @@ import io.metersphere.base.mapper.ApiScenarioMapper; import io.metersphere.base.mapper.ApiScenarioModuleMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioModuleMapper; +import io.metersphere.commons.constants.ProjectModuleDefaultNodeEnum; import io.metersphere.commons.constants.PropertyConstant; import io.metersphere.commons.constants.TestCaseConstants; import io.metersphere.commons.enums.ApiTestDataStatus; @@ -29,6 +30,7 @@ import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionUtils; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -157,7 +159,7 @@ public class ApiScenarioModuleService extends NodeTreeService statusList = new ArrayList<>(); statusList.add(ApiTestDataStatus.TRASH.getValue()); request.getFilters().put("status", statusList); @@ -507,20 +509,32 @@ public class ApiScenarioModuleService extends NodeTreeService list = apiScenarioModuleMapper.selectByExample(example); if (CollectionUtils.isEmpty(list)) { - ApiScenarioModule record = new ApiScenarioModule(); - record.setId(UUID.randomUUID().toString()); - record.setName("未规划场景"); - record.setPos(1.0); - record.setLevel(1); - record.setCreateTime(System.currentTimeMillis()); - record.setUpdateTime(System.currentTimeMillis()); - record.setProjectId(projectId); - record.setCreateUser(SessionUtils.getUserId()); - apiScenarioModuleMapper.insert(record); - return record; + return saveDefault(projectId); + } else { + return list.get(0); + } + } + + @Async + public synchronized ApiScenarioModule saveDefault(String projectId) { + ApiScenarioModuleExample example = new ApiScenarioModuleExample(); + example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo(ProjectModuleDefaultNodeEnum.API_SCENARIO_DEFAULT_NODE.getNodeName()).andParentIdIsNull(); + List list = apiScenarioModuleMapper.selectByExample(example); + if (CollectionUtils.isEmpty(list)) { + ApiScenarioModule module = new ApiScenarioModule(); + module.setId(UUID.randomUUID().toString()); + module.setName(ProjectModuleDefaultNodeEnum.API_SCENARIO_DEFAULT_NODE.getNodeName()); + module.setPos(1.0); + module.setLevel(1); + module.setCreateTime(System.currentTimeMillis()); + module.setUpdateTime(System.currentTimeMillis()); + module.setProjectId(projectId); + module.setCreateUser(SessionUtils.getUserId()); + apiScenarioModuleMapper.insert(module); + return module; } else { return list.get(0); } @@ -825,7 +839,7 @@ public class ApiScenarioModuleService extends NodeTreeService moduleList = pidChildrenMap.get(PropertyConstant.ROOT); for (ApiScenarioModule module : moduleList) { - if (module.getName().equals("未规划场景")) { + if (module.getName().equals(ProjectModuleDefaultNodeEnum.API_SCENARIO_DEFAULT_NODE.getNodeName())) { datum.setApiScenarioModuleId(module.getId()); datum.setModulePath("/" + module.getName()); } diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java index 71a15a0ef8..442a4bfe32 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java @@ -1478,7 +1478,7 @@ public class ApiScenarioService { private void replenishScenarioModuleIdPath(String request, ApiScenarioModuleMapper apiScenarioModuleMapper, ApiScenarioWithBLOBs item) { ApiScenarioModuleExample example = new ApiScenarioModuleExample(); - example.createCriteria().andProjectIdEqualTo(request).andNameEqualTo("未规划场景"); + example.createCriteria().andProjectIdEqualTo(request).andNameEqualTo(ProjectModuleDefaultNodeEnum.API_SCENARIO_DEFAULT_NODE.getNodeName()); List modules = apiScenarioModuleMapper.selectByExample(example); if (CollectionUtils.isNotEmpty(modules)) { item.setApiScenarioModuleId(modules.get(0).getId()); diff --git a/api-test/frontend/src/business/automation/scenario/ScenarioExtendBtns.vue b/api-test/frontend/src/business/automation/scenario/ScenarioExtendBtns.vue index f4ee0a7893..3cc71eba43 100644 --- a/api-test/frontend/src/business/automation/scenario/ScenarioExtendBtns.vue +++ b/api-test/frontend/src/business/automation/scenario/ScenarioExtendBtns.vue @@ -78,6 +78,7 @@ export default { jmxObj.attachFiles = jmxInfo.attachFiles; jmxObj.attachByteFiles = jmxInfo.attachByteFiles; jmxObj.scenarioId = row.id; + jmxObj.caseId = null; jmxObj.version = row.version; jmxObj.projectEnvMap = projectEnvMap; performanceStore.$patch({ test: { name: row.name, jmx: jmxObj } }); diff --git a/api-test/frontend/src/business/definition/components/complete/EditCompleteHTTPApi.vue b/api-test/frontend/src/business/definition/components/complete/EditCompleteHTTPApi.vue index 1d8caf2e35..6b1ab9acd0 100644 --- a/api-test/frontend/src/business/definition/components/complete/EditCompleteHTTPApi.vue +++ b/api-test/frontend/src/business/definition/components/complete/EditCompleteHTTPApi.vue @@ -545,8 +545,10 @@ export default { if (this.httpForm.tags instanceof Array) { this.httpForm.tags = JSON.stringify(this.httpForm.tags); } - if (this.beforeHttpForm.tags instanceof Array) { - this.beforeHttpForm.tags = JSON.stringify(this.beforeHttpForm.tags); + if (this.beforeHttpForm) { + if (this.beforeHttpForm.tags instanceof Array) { + this.beforeHttpForm.tags = JSON.stringify(this.beforeHttpForm.tags); + } } }, saveApi() { @@ -808,11 +810,11 @@ export default { } else { this.versionData = response.data; } - - this.beforeHttpForm = this.versionData[0]; - this.beforeRequest = JSON.parse(this.versionData[0].request); - this.beforeResponse = JSON.parse(this.versionData[0].response); - + if (this.versionData[0]) { + this.beforeHttpForm = this.versionData[0]; + this.beforeRequest = JSON.parse(this.versionData[0].request); + this.beforeResponse = JSON.parse(this.versionData[0].response); + } let latestVersionData = response.data.filter((v) => v.versionId === this.latestVersionId); if (latestVersionData.length > 0) { this.hasLatest = false diff --git a/api-test/frontend/src/business/definition/components/list/ApiCaseSimpleList.vue b/api-test/frontend/src/business/definition/components/list/ApiCaseSimpleList.vue index 03aa298dba..0cb52f6a16 100644 --- a/api-test/frontend/src/business/definition/components/list/ApiCaseSimpleList.vue +++ b/api-test/frontend/src/business/definition/components/list/ApiCaseSimpleList.vue @@ -1433,6 +1433,7 @@ export default { jmxObj.attachFiles = jmxInfo.attachFiles; jmxObj.attachByteFiles = jmxInfo.attachByteFiles; jmxObj.caseId = reqObj.id; + jmxObj.scenarioId = null; jmxObj.version = row.version; jmxObj.envId = environment.id; jmxObj.projectEnvMap = projectEnvMap; @@ -1442,7 +1443,7 @@ export default { }); } }) - .catch((error) => { + .catch(() => { this.$emit('runRefresh', {}); }); }, diff --git a/framework/eureka/pom.xml b/framework/eureka/pom.xml index 9d64c39fa9..ce04c46c11 100644 --- a/framework/eureka/pom.xml +++ b/framework/eureka/pom.xml @@ -36,7 +36,11 @@ org.springframework.boot spring-boot-starter-data-redis - + + org.redisson + redisson-spring-boot-starter + ${redisson-starter.version} + diff --git a/framework/eureka/src/main/resources/application.properties b/framework/eureka/src/main/resources/application.properties index 5279377ea3..4668b728c5 100644 --- a/framework/eureka/src/main/resources/application.properties +++ b/framework/eureka/src/main/resources/application.properties @@ -9,4 +9,5 @@ eureka.dashboard.enabled=true # default eureka eureka.client.service-url.defaultZone=http://localhost:8761/eureka/ -logging.file.path=/opt/metersphere/logs/${spring.application.name} \ No newline at end of file +logging.file.path=/opt/metersphere/logs/${spring.application.name} +spring.redis.redisson.file=file:/opt/metersphere/conf/redisson.yml diff --git a/framework/sdk-parent/frontend/src/components/environment/EnvironmentHttpConfig.vue b/framework/sdk-parent/frontend/src/components/environment/EnvironmentHttpConfig.vue index a1596704c6..d1b6f0918d 100644 --- a/framework/sdk-parent/frontend/src/components/environment/EnvironmentHttpConfig.vue +++ b/framework/sdk-parent/frontend/src/components/environment/EnvironmentHttpConfig.vue @@ -45,11 +45,57 @@ -

{{ $t('api_test.request.headers') }}

- - {{ $t("commons.batch_add") }} - - + + +

{{ $t('api_test.request.headers') }}

+ + {{ + $t("commons.batch_add") + }} + + + +
+ + + + + + + {{ $t("ui.browser") }} + + + + + + + + + {{ $t("ui.performance_mode") }} + + + + + + + + + + + + +
{{ $t('commons.add') }} @@ -121,10 +167,12 @@ import {getUUID} from "../../utils"; import {KeyValue} from "../../model/EnvTestModel"; import Vue from "vue"; import BatchAddParameter from "./commons/BatchAddParameter"; +import FormSection from "metersphere-frontend/src/components/form/FormSection"; +import MsInstructionsIcon from 'metersphere-frontend/src/components/MsInstructionsIcon'; export default { name: "MsEnvironmentHttpConfig", - components: {MsApiKeyValue, MsSelectTree, MsTableOperatorButton, BatchAddParameter}, + components: {MsApiKeyValue, MsSelectTree, MsTableOperatorButton, BatchAddParameter, FormSection, MsInstructionsIcon}, props: { httpConfig: new HttpConfig(), projectId: String, @@ -165,9 +213,21 @@ export default { socket: "", domain: "", port: 0, - headers: [new KeyValue()] + headers: [new KeyValue()], + headlessEnabled: true, + browser: 'CHROME' }, - beforeCondition: {} + beforeCondition: {}, + browsers: [ + { + label: this.$t("chrome"), + value: "CHROME", + }, + { + label: this.$t("firefox"), + value: "FIREFOX", + }, + ], }; }, watch: { @@ -289,7 +349,7 @@ export default { list() { if (this.projectId) { this.result = getApiModuleByProjectIdAndProtocol(this.projectId, "HTTP").then((response) => { - if (response.data && response.data !== null) { + if (response.data && response.data !== null) { this.moduleOptions = response.data; } }); diff --git a/framework/sdk-parent/frontend/src/components/environment/commons/ApiScenarioVariables.vue b/framework/sdk-parent/frontend/src/components/environment/commons/ApiScenarioVariables.vue index 91a9ded583..9c1799bbb6 100644 --- a/framework/sdk-parent/frontend/src/components/environment/commons/ApiScenarioVariables.vue +++ b/framework/sdk-parent/frontend/src/components/environment/commons/ApiScenarioVariables.vue @@ -18,12 +18,18 @@ :content="$t('commons.import')" @click="importJSON" /> - + + + + {{ $t('envrionment.export_variable_tip') }} + + + + + + + + + + + + @@ -128,14 +173,14 @@ sortable >