diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiScenarioRequest.java b/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiScenarioRequest.java index 9d25b4e257..1256a3c350 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiScenarioRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiScenarioRequest.java @@ -1,5 +1,6 @@ package io.metersphere.api.dto.automation; +import io.metersphere.api.dto.definition.request.MsTestElement; import lombok.Getter; import lombok.Setter; @@ -36,7 +37,7 @@ public class SaveApiScenarioRequest { private String description; - private String scenarioDefinition; + private MsTestElement scenarioDefinition; List bodyUploadIds; } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index 48fc7ec826..b49d589d42 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -7,6 +7,7 @@ import com.alibaba.fastjson.annotation.JSONType; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import io.metersphere.api.dto.scenario.KeyValue; import io.metersphere.api.dto.scenario.environment.EnvironmentConfig; import io.metersphere.api.service.ApiAutomationService; import io.metersphere.api.service.ApiTestEnvironmentService; @@ -36,6 +37,9 @@ public class MsScenario extends MsTestElement { @JSONField(ordinal = 12) private String environmentId; + @JSONField(ordinal = 13) + private List variables; + public void toHashTree(HashTree tree, List hashTree, EnvironmentConfig config) { if (environmentId != null) { ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java index 76e6349495..ad11c71b03 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java @@ -60,6 +60,14 @@ public class MsTestElement { @JSONField(ordinal = 3) private String label; @JSONField(ordinal = 4) + private String resourceId; + @JSONField(ordinal = 5) + private String referenced; + @JSONField(ordinal = 6) + private boolean active; + @JSONField(ordinal = 7) + private String index; + @JSONField(ordinal = 8) private LinkedList hashTree; // 公共环境逐层传递,如果自身有环境 以自身引用环境为准否则以公共环境作为请求环境 diff --git a/backend/src/main/java/io/metersphere/api/parse/MsParser.java b/backend/src/main/java/io/metersphere/api/parse/MsParser.java index 676f8b224a..78effbfff9 100644 --- a/backend/src/main/java/io/metersphere/api/parse/MsParser.java +++ b/backend/src/main/java/io/metersphere/api/parse/MsParser.java @@ -5,12 +5,21 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.parser.Feature; import io.metersphere.api.dto.ApiTestImportRequest; +import io.metersphere.api.dto.definition.ApiDefinitionResult; import io.metersphere.api.dto.definition.parse.ApiDefinitionImport; +import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy; +import io.metersphere.api.dto.scenario.Body; +import io.metersphere.api.dto.scenario.KeyValue; import io.metersphere.api.dto.scenario.request.RequestType; -import io.metersphere.commons.constants.MsRequestBodyType; -import org.apache.commons.lang3.StringUtils; +import io.metersphere.api.service.ApiModuleService; +import io.metersphere.base.domain.ApiModule; +import io.metersphere.commons.utils.CommonBeanFactory; +import org.apache.commons.collections.CollectionUtils; import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; public class MsParser extends ApiImportAbstractParser { @@ -18,43 +27,72 @@ public class MsParser extends ApiImportAbstractParser { public ApiDefinitionImport parse(InputStream source, ApiTestImportRequest request) { String testStr = getApiTestStr(source); JSONObject testObject = JSONObject.parseObject(testStr, Feature.OrderedField); - if (testObject.get("projectName") == null) { - testStr = parsePluginFormat(testObject); + apiModuleService = CommonBeanFactory.getBean(ApiModuleService.class); + this.projectId = request.getProjectId(); + if (testObject.get("projectName") != null) { + return parseMsFormat(testStr, request); + } else { + return parsePluginFormat(testObject); } - ApiDefinitionImport apiImport = JSON.parseObject(testStr, ApiDefinitionImport.class); + } + + private ApiDefinitionImport parseMsFormat(String testStr, ApiTestImportRequest importRequest) { + + ApiDefinitionImport apiDefinitionImport = JSON.parseObject(testStr, ApiDefinitionImport.class); + List data = apiDefinitionImport.getData(); + data.forEach(apiDefinition -> { + String id = UUID.randomUUID().toString(); + apiDefinition.setModuleId(null); + apiDefinition.setId(id); + apiDefinition.setProjectId(this.projectId); + String request = apiDefinition.getRequest(); + JSONObject requestObj = JSONObject.parseObject(request); + requestObj.put("id", id); + apiDefinition.setRequest(JSONObject.toJSONString(requestObj)); + }); + return apiDefinitionImport; + } + + private ApiDefinitionImport parsePluginFormat(JSONObject testObject) { + List results = new ArrayList<>(); + ApiDefinitionImport apiImport = new ApiDefinitionImport(); + apiImport.setProtocol(RequestType.HTTP); + apiImport.setData(results); + testObject.keySet().forEach(tag -> { + ApiModule module = apiModuleService.getNewModule(tag, this.projectId, 1); + createModule(module); + JSONObject requests = testObject.getJSONObject(tag); + requests.keySet().forEach(requestName -> { + + JSONObject requestObject = requests.getJSONObject(requestName); + String path = requestObject.getString("url"); + String method = requestObject.getString("method"); + + MsHTTPSamplerProxy request = buildRequest(requestName, path, method); + ApiDefinitionResult apiDefinition = buildApiDefinition(request.getId(), requestName, path, method); + apiDefinition.setModuleId(module.getId()); + apiDefinition.setProjectId(this.projectId); + + parseBody(requestObject, request.getBody()); + parseHeader(requestObject, request.getHeaders()); + apiDefinition.setRequest(JSONObject.toJSONString(request)); + results.add(apiDefinition); + }); + }); return apiImport; } - private String parsePluginFormat( JSONObject testObject) { - //插件格式 - JSONArray scenarios = new JSONArray(); - testObject.keySet().forEach(scenarioName -> { - JSONObject scenario = new JSONObject(); - scenario.put("name", scenarioName); - JSONArray requestsObjects = new JSONArray(); - JSONObject requestsObject = testObject.getJSONObject(scenarioName); - requestsObject.keySet().forEach(requestName -> { - JSONObject requestObject = new JSONObject(true); - JSONObject requestTmpObject = requestsObject.getJSONObject(requestName); - //排序,确保type在第一个,否则转换失败 - if (StringUtils.isBlank(requestTmpObject.getString("type"))) { - requestObject.put("type", RequestType.HTTP); - } - - requestTmpObject.keySet().forEach(key -> requestObject.put(key, requestTmpObject.get(key))); - requestObject.put("name", requestName); - parseBody(requestObject); - requestsObjects.add(requestObject); - }); - scenario.put("requests", requestsObjects); - scenarios.add(scenario); - }); - JSONObject result = new JSONObject(); - result.put("scenarios", scenarios); - return result.toJSONString(); + private void parseHeader(JSONObject requestObject, List msHeaders) { + JSONArray headers = requestObject.getJSONArray("headers"); + if (CollectionUtils.isNotEmpty(headers)) { + for (int i = 0; i < headers.size(); i++) { + JSONObject header = headers.getJSONObject(i); + msHeaders.add(new KeyValue(header.getString("name"), header.getString("value"))); + } + } } - private void parseBody(JSONObject requestObject) { + private void parseBody(JSONObject requestObject, Body msBody) { if (requestObject.containsKey("body")) { Object body = requestObject.get("body"); if (body instanceof JSONArray) { @@ -65,25 +103,18 @@ public class MsParser extends ApiImportAbstractParser { String tmp = bodies.getString(i); bodyStr.append(tmp); } - JSONObject bodyObject = new JSONObject(); - bodyObject.put("raw", bodyStr); - bodyObject.put("type", MsRequestBodyType.RAW.value()); - requestObject.put("body", bodyObject); + msBody.setType(Body.RAW); + msBody.setRaw(bodyStr.toString()); } } else if (body instanceof JSONObject) { JSONObject bodyObj = requestObject.getJSONObject("body"); if (bodyObj != null) { - JSONArray kvs = new JSONArray(); + ArrayList kvs = new ArrayList<>(); bodyObj.keySet().forEach(key -> { - JSONObject kv = new JSONObject(); - kv.put("name", key); - kv.put("value", bodyObj.getString(key)); - kvs.add(kv); + kvs.add(new KeyValue(key, bodyObj.getString(key))); }); - JSONObject bodyRes = new JSONObject(); - bodyRes.put("kvs", kvs); - bodyRes.put("type", MsRequestBodyType.KV.value()); - requestObject.put("body", bodyRes); + msBody.setKvs(kvs); + msBody.setType(Body.WWW_FROM); } } } diff --git a/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java b/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java index 112067cd4a..b5dea282b7 100644 --- a/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java +++ b/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java @@ -156,9 +156,9 @@ public class Swagger2Parser extends ApiImportAbstractParser { case "application/xml": bodyType = Body.XML; break; -// case "": //todo binary 啥类型 -// bodyType = Body.BINARY; -// break; + case "": + bodyType = Body.BINARY; + break; default: bodyType = Body.RAW; } @@ -235,7 +235,6 @@ public class Swagger2Parser extends ApiImportAbstractParser { refSet.add(simpleRef); if (model != null) { JSONObject bodyParameters = getBodyParameters(model.getProperties(), refSet); - //body.setRaw(bodyParameters.toJSONString()); return bodyParameters.toJSONString(); } } else if (schema instanceof ArrayModel) { @@ -250,7 +249,6 @@ public class Swagger2Parser extends ApiImportAbstractParser { Model model = definitions.get(simpleRef); JSONArray propertyList = new JSONArray(); propertyList.add(getBodyParameters(model.getProperties(), refSet)); - // body.setRaw(propertyList.toString()); return propertyList.toString(); } } 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 6b739e95ad..0a8993c4d3 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -101,7 +101,7 @@ public class ApiAutomationService { scenario.setFollowPeople(request.getFollowPeople()); scenario.setPrincipal(request.getPrincipal()); scenario.setStepTotal(request.getStepTotal()); - scenario.setScenarioDefinition(request.getScenarioDefinition()); + scenario.setScenarioDefinition(JSON.toJSONString(request.getScenarioDefinition())); scenario.setCreateTime(System.currentTimeMillis()); scenario.setUpdateTime(System.currentTimeMillis()); if (StringUtils.isNotEmpty(request.getStatus())) { @@ -137,7 +137,7 @@ public class ApiAutomationService { scenario.setFollowPeople(request.getFollowPeople()); scenario.setPrincipal(request.getPrincipal()); scenario.setStepTotal(request.getStepTotal()); - scenario.setScenarioDefinition(request.getScenarioDefinition()); + scenario.setScenarioDefinition(JSON.toJSONString(request.getScenarioDefinition())); scenario.setUpdateTime(System.currentTimeMillis()); if (StringUtils.isNotEmpty(request.getStatus())) { scenario.setStatus(request.getStatus()); diff --git a/frontend/src/business/App.vue b/frontend/src/business/App.vue index 4efdc55ae0..8bc9c05ee2 100644 --- a/frontend/src/business/App.vue +++ b/frontend/src/business/App.vue @@ -86,6 +86,7 @@ export default { background-color: rgb(44, 42, 72); color: rgb(245, 245, 245); font-size: 14px; + height: 40px; } .logo { diff --git a/frontend/src/business/components/api/automation/scenario/ApiCustomize.vue b/frontend/src/business/components/api/automation/scenario/ApiCustomize.vue index 32ee6990b7..41c0501d7e 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiCustomize.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiCustomize.vue @@ -56,7 +56,7 @@ }, editApi(row) { let name = this.request.name; - Object.assign(this.request, JSON.parse(row.request)); + Object.assign(this.request, row.request); this.request.name = name; this.request.resourceId = getUUID(); this.$emit('addCustomizeApi', this.request); diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioVariables.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioVariables.vue new file mode 100644 index 0000000000..8c7f0947b0 --- /dev/null +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioVariables.vue @@ -0,0 +1,111 @@ + + + + + diff --git a/frontend/src/business/components/api/automation/scenario/ApiVariableInput.vue b/frontend/src/business/components/api/automation/scenario/ApiVariableInput.vue new file mode 100644 index 0000000000..53059578a3 --- /dev/null +++ b/frontend/src/business/components/api/automation/scenario/ApiVariableInput.vue @@ -0,0 +1,123 @@ + + + + + diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 50bd67ebbe..8036d093fc 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -125,10 +125,12 @@ {{currentScenario.name ===undefined || ''? $t('api_test.scenario.name') : currentScenario.name}} - {{$t('api_test.automation.step_total')}}:{{scenarioDefinition.length}} + {{$t('api_test.automation.step_total')}}:{{scenarioDefinition.length}} - {{$t('api_test.automation.scenario_total')}}: + {{$t('api_test.automation.scenario_total')}}: + {{this.currentScenario.variables!=undefined?this.currentScenario.variables.length-1: 0}} + {{$t('api_test.definition.request.run_env')}}: @@ -263,6 +265,9 @@ + + + @@ -288,6 +293,7 @@ import MsImportApiScenario from "./ImportApiScenario"; import MsApiScenarioComponent from "./ApiScenarioComponent"; import MsApiReportDetail from "../report/ApiReportDetail"; + import MsScenarioParameters from "./ScenarioParameters"; export default { @@ -297,7 +303,15 @@ currentProject: {}, currentScenario: {}, }, - components: {ApiEnvironmentConfig, MsApiReportDetail, MsAddTag, MsRun, MsApiScenarioComponent, MsImportApiScenario, MsJsr233Processor, MsConstantTimer, MsIfController, MsApiAssertions, MsApiExtract, MsApiDefinition, MsApiComponent, MsApiCustomize}, + components: { + ApiEnvironmentConfig, MsScenarioParameters, + MsApiReportDetail, MsAddTag, MsRun, + MsApiScenarioComponent, MsImportApiScenario, + MsJsr233Processor, MsConstantTimer, + MsIfController, MsApiAssertions, + MsApiExtract, MsApiDefinition, + MsApiComponent, MsApiCustomize + }, data() { return { props: { @@ -648,9 +662,6 @@ if (valid) { this.setParameter(); let bodyFiles = this.getBodyUploadFiles(this.currentScenario); - console.log(bodyFiles) - console.log(this.currentScenario.bodyUploadIds) - this.$fileUpload(this.path, null, bodyFiles, this.currentScenario, () => { this.$success(this.$t('commons.save_success')); this.path = "/api/automation/update"; @@ -685,7 +696,7 @@ this.currentScenario.modulePath = this.getPath(this.currentScenario.apiScenarioModuleId); // 构建一个场景对象 方便引用处理 let scenario = {id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario", referenced: 'Created', environmentId: this.currentEnvironmentId, hashTree: this.scenarioDefinition}; - this.currentScenario.scenarioDefinition = JSON.stringify(scenario); + this.currentScenario.scenarioDefinition = scenario; this.currentScenario.tagId = JSON.stringify(this.currentScenario.tagId); if (this.currentModule != null) { this.currentScenario.modulePath = this.currentModule.method !== undefined ? this.currentModule.method : null; @@ -695,6 +706,13 @@ runRefresh() { this.debugVisible = true; this.isReloadData = false; + }, + showScenarioParameters() { + this.$refs.scenarioParameters.open(this.currentScenario.variables); + }, + addParameters(data) { + this.currentScenario.variables = data; + this.reload(); } } } diff --git a/frontend/src/business/components/api/automation/scenario/ScenarioParameters.vue b/frontend/src/business/components/api/automation/scenario/ScenarioParameters.vue new file mode 100644 index 0000000000..b250fbd08d --- /dev/null +++ b/frontend/src/business/components/api/automation/scenario/ScenarioParameters.vue @@ -0,0 +1,55 @@ + + + + + diff --git a/frontend/src/business/components/api/definition/components/ApiCaseList.vue b/frontend/src/business/components/api/definition/components/ApiCaseList.vue index ba3b68da9c..6dc9aa3c5f 100644 --- a/frontend/src/business/components/api/definition/components/ApiCaseList.vue +++ b/frontend/src/business/components/api/definition/components/ApiCaseList.vue @@ -190,6 +190,7 @@ api: { type: Object }, + createCase: String, visible: { type: Boolean, default: false, @@ -217,7 +218,6 @@ } }, - watch: { // 初始化 api() { @@ -237,13 +237,35 @@ this.currentRow.cases = []; } this.getApiTest(); + }, + createCase() { + this.sysAddition(); } }, created() { - this.getApiTest(); this.getEnvironments(); + if (this.createCase) { + this.sysAddition(); + } else { + this.getApiTest(); + } }, methods: { + sysAddition() { + let condition = {}; + condition.projectId = this.api.projectId; + condition.apiDefinitionId = this.api.id; + condition.priority = this.priorityValue; + condition.name = this.name; + this.$post("/api/testcase/list", condition, response => { + for (let index in response.data) { + let test = response.data[index]; + test.request = JSON.parse(test.request); + } + this.apiCaseList = response.data; + this.addCase(); + }); + }, getResult(data) { if (RESULT_MAP.get(data)) { return RESULT_MAP.get(data); diff --git a/frontend/src/business/components/api/definition/components/ApiConfig.vue b/frontend/src/business/components/api/definition/components/ApiConfig.vue index c49b229cbd..3ece1706c5 100644 --- a/frontend/src/business/components/api/definition/components/ApiConfig.vue +++ b/frontend/src/business/components/api/definition/components/ApiConfig.vue @@ -91,35 +91,38 @@ this.maintainerOptions = response.data; }); }, - initSql() { + setRequest() { if (this.currentApi.request != undefined && this.currentApi.request != null) { - this.request = JSON.parse(this.currentApi.request); + if (Object.prototype.toString.call(this.currentApi.request).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') { + this.request = this.currentApi.request; + } else { + this.request = JSON.parse(this.currentApi.request); + } this.currentApi.request = this.request; - } else { + return true; + } + return false; + }, + initSql() { + if (!this.setRequest()) { this.request = createComponent("JDBCSampler"); + this.currentApi.request = this.request; } }, initDubbo() { - if (this.currentApi.request != undefined && this.currentApi.request != null) { - this.request = JSON.parse(this.currentApi.request); - this.currentApi.request = this.request; - } else { + if (!this.setRequest()) { this.request = createComponent("DubboSampler"); + this.currentApi.request = this.request; } }, initTcp() { - if (this.currentApi.request != undefined && this.currentApi.request != null) { - this.request = JSON.parse(this.currentApi.request); - this.currentApi.request = this.request; - } else { + if (!this.setRequest()) { this.request = createComponent("TCPSampler"); + this.currentApi.request = this.request; } }, initHttp() { - if (this.currentApi.request != undefined && this.currentApi.request != null) { - this.request = JSON.parse(this.currentApi.request); - this.currentApi.request = this.request; - } else { + if (!this.setRequest()) { this.request = createComponent("HTTPSamplerProxy"); this.currentApi.request = this.request; } diff --git a/frontend/src/business/components/api/definition/components/debug/DebugDubboPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugDubboPage.vue index 35052f1162..942bd4a88d 100644 --- a/frontend/src/business/components/api/definition/components/debug/DebugDubboPage.vue +++ b/frontend/src/business/components/api/definition/components/debug/DebugDubboPage.vue @@ -97,7 +97,7 @@ this.$refs.debugResult.reload(); }, saveAs() { - let obj = {request: JSON.stringify(this.request)}; + let obj = {request: this.request}; this.$emit('saveAs', obj); } } 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 2ddca9dd97..a2d405339e 100644 --- a/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue +++ b/frontend/src/business/components/api/definition/components/debug/DebugHttpPage.vue @@ -120,7 +120,7 @@ saveAs() { this.$refs['debugForm'].validate((valid) => { if (valid) { - this.debugForm.request = JSON.stringify(this.request); + this.debugForm.request = this.request; this.debugForm.userId = getCurrentUser().id; this.debugForm.status = "Underway"; this.debugForm.protocol = this.currentProtocol; diff --git a/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue index c45ec3830a..9402c1930b 100644 --- a/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue +++ b/frontend/src/business/components/api/definition/components/debug/DebugJdbcPage.vue @@ -99,7 +99,7 @@ this.$refs.debugResult.reload(); }, saveAs() { - let obj = {request: JSON.stringify(this.request)}; + let obj = {request: this.request}; this.$emit('saveAs', obj); } } diff --git a/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue b/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue index 5ae5a76242..f014471d7a 100644 --- a/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue +++ b/frontend/src/business/components/api/definition/components/debug/DebugTcpPage.vue @@ -98,7 +98,7 @@ this.$refs.debugResult.reload(); }, saveAs() { - let obj = {request: JSON.stringify(this.request)}; + let obj = {request: this.request}; this.$emit('saveAs', obj); } } 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 993f615cea..c603889b9d 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue @@ -31,7 +31,7 @@ > @@ -78,6 +78,7 @@ loaded: false, loading: false, currentRequest: {}, + createCase: "", refreshSign: "", responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []}, reqOptions: REQ_METHOD, @@ -153,9 +154,10 @@ return bodyUploadFiles; }, saveAsCase() { - this.visible = false; + //用于触发创建操作 + this.createCase = getUUID(); + this.visible = true; this.loaded = false; - this.$refs.caseList.addCase(); }, saveAsApi() { let data = {}; 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 e40bef3346..5603ed8ff7 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue @@ -70,9 +70,9 @@ - + @@ -113,8 +113,9 @@ api: {}, loaded: false, loading: false, + createCase: "", currentRequest: {}, - refreshSign:"", + refreshSign: "", responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []}, reqOptions: REQ_METHOD, environments: [], @@ -194,7 +195,9 @@ return bodyUploadFiles; }, saveAsCase() { - this.visible = false; + //用于触发创建操作 + this.createCase = getUUID(); + this.visible = true; this.loaded = false; }, saveAsApi() { @@ -301,7 +304,8 @@ border-radius: 4px; border-left: 4px solid #783887; } - /deep/.el-drawer{ + + /deep/ .el-drawer { overflow: auto; } 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 928426f4e4..255c149965 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue @@ -30,9 +30,10 @@ - > + + > @@ -79,6 +80,7 @@ responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []}, reqOptions: REQ_METHOD, refreshSign: "", + createCase: "", environments: [], rules: { method: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}], @@ -151,9 +153,9 @@ return bodyUploadFiles; }, saveAsCase() { - this.visible = false; + this.createCase = getUUID(); + this.visible = true; this.loaded = false; - this.$refs.caseList.addCase(); }, saveAsApi() { let data = {}; @@ -249,7 +251,8 @@ border-radius: 4px; border-left: 4px solid #783887; } - /deep/.el-drawer{ + + /deep/ .el-drawer { overflow: auto; } 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 aeea40e840..daa77a1ae2 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue @@ -31,7 +31,7 @@ @@ -80,6 +80,7 @@ reqOptions: REQ_METHOD, environments: [], refreshSign: "", + createCase: "", rules: { method: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}], url: [{required: true, message: this.$t('api_test.definition.request.path_info'), trigger: 'blur'}], @@ -151,9 +152,9 @@ return bodyUploadFiles; }, saveAsCase() { - this.visible = false; + this.createCase = getUUID(); + this.visible = true; this.loaded = false; - this.$refs.caseList.addCase(); }, saveAsApi() { let data = {}; diff --git a/frontend/src/business/components/api/head/ApiHeaderMenus.vue b/frontend/src/business/components/api/head/ApiHeaderMenus.vue index 5d87830b41..65420495e0 100644 --- a/frontend/src/business/components/api/head/ApiHeaderMenus.vue +++ b/frontend/src/business/components/api/head/ApiHeaderMenus.vue @@ -1,7 +1,7 @@