feat(接口自动化): 添加执行操作
This commit is contained in:
parent
f57b3dcc15
commit
236a9241d8
|
@ -51,6 +51,9 @@ public class MsDubboSampler extends MsTestElement {
|
||||||
@JSONField(ordinal = 59)
|
@JSONField(ordinal = 59)
|
||||||
private List<KeyValue> attachmentArgs;
|
private List<KeyValue> attachmentArgs;
|
||||||
|
|
||||||
|
@JSONField(ordinal = 60)
|
||||||
|
private Object requestResult;
|
||||||
|
|
||||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||||
if (!this.isEnable()) {
|
if (!this.isEnable()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -85,6 +85,9 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
@JSONField(ordinal = 24)
|
@JSONField(ordinal = 24)
|
||||||
private List<KeyValue> arguments;
|
private List<KeyValue> arguments;
|
||||||
|
|
||||||
|
@JSONField(ordinal = 25)
|
||||||
|
private Object requestResult;
|
||||||
|
|
||||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||||
if (!this.isEnable()) {
|
if (!this.isEnable()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -38,6 +38,8 @@ public class MsJDBCSampler extends MsTestElement {
|
||||||
private List<KeyValue> variables;
|
private List<KeyValue> variables;
|
||||||
@JSONField(ordinal = 16)
|
@JSONField(ordinal = 16)
|
||||||
private String environmentId;
|
private String environmentId;
|
||||||
|
@JSONField(ordinal = 17)
|
||||||
|
private Object requestResult;
|
||||||
|
|
||||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||||
if (!this.isEnable()) {
|
if (!this.isEnable()) {
|
||||||
|
|
|
@ -48,6 +48,8 @@ public class MsTCPSampler extends MsTestElement {
|
||||||
private String password = "";
|
private String password = "";
|
||||||
@JSONField(ordinal = 23)
|
@JSONField(ordinal = 23)
|
||||||
private String request;
|
private String request;
|
||||||
|
@JSONField(ordinal = 24)
|
||||||
|
private Object requestResult;
|
||||||
|
|
||||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||||
if (!this.isEnable()) {
|
if (!this.isEnable()) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit bb494fc68a2367359c9048fa7250c7618de4afb6
|
Subproject commit 1fe20ba15a7ca3fe9f77ddf866021e7c7dfe5969
|
|
@ -24,8 +24,10 @@
|
||||||
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
|
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
|
||||||
<div style="margin-right: 20px; float: right">
|
<div style="margin-right: 20px; float: right">
|
||||||
<i class="icon el-icon-arrow-right" :class="{'is-active': request.active}"
|
<i class="icon el-icon-arrow-right" :class="{'is-active': request.active}"
|
||||||
@click="active(request)" v-if="request.referenced!=undefined && request.referenced!='Deleted' && request.referenced!='REF'"/>
|
@click="active(request)"/>
|
||||||
<el-switch v-model="request.enable" style="margin-left: 10px"/>
|
<el-switch v-model="request.enable" style="margin-left: 10px"/>
|
||||||
|
<el-button @click="run" :tip="$t('api_test.run')" icon="el-icon-video-play"
|
||||||
|
style="background-color: #409EFF;color: white;margin-left: 10px" size="mini" circle/>
|
||||||
<el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="margin-left: 10px"/>
|
<el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="margin-left: 10px"/>
|
||||||
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove" style="margin-left: 10px"/>
|
<el-button size="mini" icon="el-icon-delete" type="danger" circle @click="remove" style="margin-left: 10px"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -45,6 +47,10 @@
|
||||||
<ms-tcp-basis-parameters :request="request" v-if="request.protocol==='TCP'"/>
|
<ms-tcp-basis-parameters :request="request" v-if="request.protocol==='TCP'"/>
|
||||||
<ms-sql-basis-parameters :request="request" v-if="request.protocol==='SQL'"/>
|
<ms-sql-basis-parameters :request="request" v-if="request.protocol==='SQL'"/>
|
||||||
<ms-dubbo-basis-parameters :request="request" v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'"/>
|
<ms-dubbo-basis-parameters :request="request" v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'"/>
|
||||||
|
|
||||||
|
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
|
||||||
|
<ms-request-result-tail :response="request.requestResult" ref="runResult"/>
|
||||||
|
|
||||||
<!-- 保存操作 -->
|
<!-- 保存操作 -->
|
||||||
<el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(item)" v-if="!request.referenced">
|
<el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(item)" v-if="!request.referenced">
|
||||||
{{$t('commons.save')}}
|
{{$t('commons.save')}}
|
||||||
|
@ -52,6 +58,9 @@
|
||||||
</div>
|
</div>
|
||||||
</el-collapse-transition>
|
</el-collapse-transition>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
<!-- 执行组件 -->
|
||||||
|
<ms-run :debug="false" :reportId="reportId" :run-data="runData"
|
||||||
|
@runRefresh="runRefresh" ref="runTest"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -61,29 +70,27 @@
|
||||||
import MsDubboBasisParameters from "../../definition/components/request/dubbo/BasisParameters";
|
import MsDubboBasisParameters from "../../definition/components/request/dubbo/BasisParameters";
|
||||||
import MsApiRequestForm from "../../definition/components/request/http/ApiRequestForm";
|
import MsApiRequestForm from "../../definition/components/request/http/ApiRequestForm";
|
||||||
import {REQ_METHOD} from "../../definition/model/JsonData";
|
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 {
|
export default {
|
||||||
name: "MsApiComponent",
|
name: "MsApiComponent",
|
||||||
props: {
|
props: {
|
||||||
request: {},
|
request: {},
|
||||||
node: {},
|
node: {},
|
||||||
|
currentEnvironmentId: String,
|
||||||
},
|
},
|
||||||
components: {MsSqlBasisParameters, MsTcpBasisParameters, MsDubboBasisParameters, MsApiRequestForm},
|
components: {MsSqlBasisParameters, MsTcpBasisParameters, MsDubboBasisParameters, MsApiRequestForm, MsRequestResultTail, MsRun},
|
||||||
data() {
|
data() {
|
||||||
return {loading: false, reqOptions: REQ_METHOD,}
|
return {loading: false, reqOptions: REQ_METHOD, reportId: "", runData: []}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.request.id && this.request.referenced === 'REF') {
|
if (!this.request.requestResult) {
|
||||||
this.$get("/api/definition/get/" + this.request.id, response => {
|
this.request.requestResult = {responseResult: {}};
|
||||||
if (response.data) {
|
|
||||||
this.request.name = response.data.name;
|
|
||||||
this.reload();
|
|
||||||
} else {
|
|
||||||
this.request.referenced = "Deleted";
|
|
||||||
}
|
}
|
||||||
})
|
// 加载引用对象数据
|
||||||
}
|
this.getApiInfo();
|
||||||
|
|
||||||
if (this.request.protocol === 'HTTP') {
|
if (this.request.protocol === 'HTTP') {
|
||||||
try {
|
try {
|
||||||
let urlObject = new URL(this.request.url);
|
let urlObject = new URL(this.request.url);
|
||||||
|
@ -105,10 +112,45 @@
|
||||||
copyRow() {
|
copyRow() {
|
||||||
this.$emit('copyRow', this.request, this.node);
|
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) {
|
active(item) {
|
||||||
item.active = !item.active;
|
item.active = !item.active;
|
||||||
this.reload();
|
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() {
|
reload() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
|
|
@ -186,7 +186,7 @@
|
||||||
<!--提取规则-->
|
<!--提取规则-->
|
||||||
<ms-api-extract @remove="remove" @copyRow="copyRow" v-if="data.type==='Extract'" customizeStyle="margin-top: 0px" :extract="data" :node="node"/>
|
<ms-api-extract @remove="remove" @copyRow="copyRow" v-if="data.type==='Extract'" customizeStyle="margin-top: 0px" :extract="data" :node="node"/>
|
||||||
<!--API 导入 -->
|
<!--API 导入 -->
|
||||||
<ms-api-component :request="data" @remove="remove" @copyRow="copyRow" v-if="data.type==='HTTPSamplerProxy'||data.type==='DubboSampler'||data.type==='JDBCSampler'||data.type==='TCPSampler'" :node="node"/>
|
<ms-api-component :request="data" :currentEnvironmentId="currentEnvironmentId" @remove="remove" @copyRow="copyRow" v-if="data.type==='HTTPSamplerProxy'||data.type==='DubboSampler'||data.type==='JDBCSampler'||data.type==='TCPSampler'" :node="node"/>
|
||||||
</template>
|
</template>
|
||||||
</span>
|
</span>
|
||||||
</el-tree>
|
</el-tree>
|
||||||
|
|
Loading…
Reference in New Issue