diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java index 1d8c5d0167..424ed45e26 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java @@ -51,6 +51,9 @@ public class MsDubboSampler extends MsTestElement { @JSONField(ordinal = 59) private List attachmentArgs; + @JSONField(ordinal = 60) + private Object requestResult; + public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; 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 f856d8bf31..57cecc27a0 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 @@ -85,6 +85,9 @@ public class MsHTTPSamplerProxy extends MsTestElement { @JSONField(ordinal = 24) private List arguments; + @JSONField(ordinal = 25) + private Object requestResult; + public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { return; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java index 17ddaa54e5..0bcc0a6769 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java @@ -38,6 +38,8 @@ public class MsJDBCSampler extends MsTestElement { private List variables; @JSONField(ordinal = 16) private String environmentId; + @JSONField(ordinal = 17) + private Object requestResult; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java index 904e395a0f..b3e5b92409 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java @@ -48,6 +48,8 @@ public class MsTCPSampler extends MsTestElement { private String password = ""; @JSONField(ordinal = 23) private String request; + @JSONField(ordinal = 24) + private Object requestResult; public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { if (!this.isEnable()) { diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index bb494fc68a..1fe20ba15a 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit bb494fc68a2367359c9048fa7250c7618de4afb6 +Subproject commit 1fe20ba15a7ca3fe9f77ddf866021e7c7dfe5969 diff --git a/frontend/src/business/components/api/automation/scenario/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/ApiComponent.vue index 8056137ced..77f2000da1 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiComponent.vue @@ -24,8 +24,10 @@ {{ $t('api_test.scenario.reference') }}
+ @click="active(request)"/> +
@@ -45,6 +47,10 @@ + +

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

+ + {{$t('commons.save')}} @@ -52,6 +58,9 @@ + + @@ -61,29 +70,27 @@ import MsDubboBasisParameters from "../../definition/components/request/dubbo/BasisParameters"; import MsApiRequestForm from "../../definition/components/request/http/ApiRequestForm"; import {REQ_METHOD} from "../../definition/model/JsonData"; + import MsRequestResultTail from "../../definition/components/response/RequestResultTail"; + import MsRun from "../../definition/components/Run"; + import {getUUID} from "@/common/js/utils"; export default { name: "MsApiComponent", props: { request: {}, node: {}, + currentEnvironmentId: String, }, - components: {MsSqlBasisParameters, MsTcpBasisParameters, MsDubboBasisParameters, MsApiRequestForm}, + components: {MsSqlBasisParameters, MsTcpBasisParameters, MsDubboBasisParameters, MsApiRequestForm, MsRequestResultTail, MsRun}, data() { - return {loading: false, reqOptions: REQ_METHOD,} + return {loading: false, reqOptions: REQ_METHOD, reportId: "", runData: []} }, created() { - if (this.request.id && this.request.referenced === 'REF') { - this.$get("/api/definition/get/" + this.request.id, response => { - if (response.data) { - this.request.name = response.data.name; - this.reload(); - } else { - this.request.referenced = "Deleted"; - } - }) + if (!this.request.requestResult) { + this.request.requestResult = {responseResult: {}}; } - + // 加载引用对象数据 + this.getApiInfo(); if (this.request.protocol === 'HTTP') { try { let urlObject = new URL(this.request.url); @@ -105,10 +112,45 @@ copyRow() { this.$emit('copyRow', this.request, this.node); }, + getApiInfo() { + if (this.request.id && this.request.referenced === 'REF') { + let requestResult = this.request.requestResult; + this.$get("/api/definition/get/" + this.request.id, response => { + if (response.data) { + Object.assign(this.request, JSON.parse(response.data.request)); + this.request.name = response.data.name; + this.request.path = response.data.path; + this.request.method = response.data.method; + this.request.url = response.data.path; + this.request.requestResult = requestResult; + this.reload(); + } else { + this.request.referenced = "Deleted"; + } + }) + } + }, active(item) { item.active = !item.active; this.reload(); }, + run() { + if (!this.currentEnvironmentId) { + this.$error(this.$t('api_test.environment.select_environment')); + return; + } + this.loading = true; + this.runData = []; + this.request.useEnvironment = this.currentEnvironmentId; + this.runData.push(this.request); + /*触发执行操作*/ + this.reportId = getUUID().substring(0, 8); + + }, + runRefresh(data) { + this.request.requestResult = data; + this.loading = false; + }, reload() { this.loading = true this.$nextTick(() => { diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 85ae49d0b5..148e64be54 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -186,7 +186,7 @@ - +