Merge remote-tracking branch 'origin/master'

This commit is contained in:
Captain.B 2021-01-22 11:42:34 +08:00
commit c571d000fe
16 changed files with 243 additions and 161 deletions

View File

@ -11,11 +11,11 @@
:title="displayTitle"> :title="displayTitle">
<template v-slot:behindHeaderLeft> <template v-slot:behindHeaderLeft>
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag> <el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag> <el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
<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>
<ms-run :debug="false" :reportId="reportId" :run-data="runData" <ms-run :debug="false" :reportId="reportId" :run-data="runData"
@runRefresh="runRefresh" ref="runTest"/> @runRefresh="runRefresh" ref="runTest"/>
</template> </template>
@ -42,7 +42,7 @@
<ms-dubbo-basis-parameters :request="request" v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'" :showScript="false"/> <ms-dubbo-basis-parameters :request="request" v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'" :showScript="false"/>
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p> <p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
<ms-request-result-tail draggable :currentProtocol="request.protocol" :response="request.requestResult" ref="runResult"/> <api-response-component :result="request.requestResult"/>
<!-- 保存操作 --> <!-- 保存操作 -->
<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">
@ -62,6 +62,8 @@
import MsRun from "../../../definition/components/Run"; import MsRun from "../../../definition/components/Run";
import {getUUID} from "@/common/js/utils"; import {getUUID} from "@/common/js/utils";
import ApiBaseComponent from "../common/ApiBaseComponent"; import ApiBaseComponent from "../common/ApiBaseComponent";
import ApiResponseComponent from "./ApiResponseComponent";
export default { export default {
name: "MsApiComponent", name: "MsApiComponent",
props: { props: {
@ -75,8 +77,9 @@
currentEnvironmentId: String, currentEnvironmentId: String,
}, },
components: { components: {
ApiBaseComponent, ApiBaseComponent, ApiResponseComponent,
MsSqlBasisParameters, MsTcpBasisParameters, MsDubboBasisParameters, MsApiRequestForm, MsRequestResultTail, MsRun}, MsSqlBasisParameters, MsTcpBasisParameters, MsDubboBasisParameters, MsApiRequestForm, MsRequestResultTail, MsRun
},
data() { data() {
return { return {
loading: false, loading: false,
@ -129,31 +132,31 @@
return this.$t('api_test.automation.api_list_import'); return this.$t('api_test.automation.api_list_import');
} else if (this.isExternalImport) { } else if (this.isExternalImport) {
return this.$t('api_test.automation.external_import'); return this.$t('api_test.automation.external_import');
} else if(this.isCustomizeReq) { } else if (this.isCustomizeReq) {
return this.$t('api_test.automation.customize_req'); return this.$t('api_test.automation.customize_req');
} }
return ""; return "";
}, },
isApiImport() { isApiImport() {
if (this.request.referenced!=undefined && this.request.referenced==='Deleted' || this.request.referenced=='REF' || this.request.referenced==='Copy') { if (this.request.referenced != undefined && this.request.referenced === 'Deleted' || this.request.referenced == 'REF' || this.request.referenced === 'Copy') {
return true return true
} }
return false; return false;
}, },
isExternalImport() { isExternalImport() {
if (this.request.referenced!=undefined && this.request.referenced==='OT_IMPORT') { if (this.request.referenced != undefined && this.request.referenced === 'OT_IMPORT') {
return true return true
} }
return false; return false;
}, },
isCustomizeReq() { isCustomizeReq() {
if (this.request.referenced==undefined || this.request.referenced==='Created') { if (this.request.referenced == undefined || this.request.referenced === 'Created') {
return true return true
} }
return false; return false;
}, },
isDeletedOrRef() { isDeletedOrRef() {
if (this.request.referenced!= undefined && this.request.referenced === 'Deleted' || this.request.referenced === 'REF') { if (this.request.referenced != undefined && this.request.referenced === 'Deleted' || this.request.referenced === 'REF') {
return true return true
} }
return false; return false;
@ -218,6 +221,7 @@
this.$error(this.$t('api_test.environment.select_environment')); this.$error(this.$t('api_test.environment.select_environment'));
return; return;
} }
this.request.active = true;
this.loading = true; this.loading = true;
this.runData = []; this.runData = [];
this.request.useEnvironment = this.currentEnvironmentId; this.request.useEnvironment = this.currentEnvironmentId;
@ -250,9 +254,11 @@
margin-right: 20px; margin-right: 20px;
color: #409EFF; color: #409EFF;
} }
/deep/ .el-card__body { /deep/ .el-card__body {
padding: 15px; padding: 15px;
} }
.tip { .tip {
padding: 3px 5px; padding: 3px 5px;
font-size: 16px; font-size: 16px;
@ -260,12 +266,15 @@
border-left: 4px solid #783887; border-left: 4px solid #783887;
margin: 20px 0; margin: 20px 0;
} }
.name-input { .name-input {
width: 30%; width: 30%;
} }
.el-icon-arrow-right { .el-icon-arrow-right {
margin-right: 5px; margin-right: 5px;
} }
.icon.is-active { .icon.is-active {
transform: rotate(90deg); transform: rotate(90deg);
} }

View File

@ -24,7 +24,7 @@
export default { export default {
name: "ApiResponseComponent", name: "ApiResponseComponent",
components: {ElCollapseTransition, MsRequestResultTail, ApiBaseComponent, MsRequestMetric}, components: {ElCollapseTransition, MsRequestResultTail, ApiBaseComponent, MsRequestMetric},
props: ['apiItem'], props: {apiItem: {}, result: {}},
data() { data() {
return { return {
isActive: false, isActive: false,
@ -32,8 +32,13 @@
} }
}, },
created() { created() {
this.getExecResult(); if (!this.result) {
if (this.apiItem.isActive) { this.getExecResult();
if (this.apiItem.isActive) {
this.isActive = true;
}
} else {
this.response = this.result;
this.isActive = true; this.isActive = true;
} }
}, },

View File

@ -209,7 +209,7 @@
}, },
addTab(tab) { addTab(tab) {
if (tab.name === 'add') { if (tab.name === 'add') {
this.handleCommand("ADD"); this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug");
} }
}, },
handleCommand(e) { handleCommand(e) {

View File

@ -169,10 +169,27 @@
let bodyFiles = this.getBodyUploadFiles(data); let bodyFiles = this.getBodyUploadFiles(data);
this.$fileUpload(this.reqUrl, null, bodyFiles, data, () => { this.$fileUpload(this.reqUrl, null, bodyFiles, data, () => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
if (this.reqUrl.endsWith('/create')) {
this.saveTestCase(data);
}
this.reqUrl = "/api/definition/update"; this.reqUrl = "/api/definition/update";
this.$emit('saveApi', data); this.$emit('saveApi', data);
}); });
}, },
saveTestCase(row) {
let tmp = {request: JSON.parse(JSON.stringify(row.request))};
tmp.projectId = getCurrentProjectID();
tmp.active = true;
tmp.priority = "P0";
tmp.name = row.name;
tmp.request.path = row.path;
tmp.request.method = row.method;
tmp.apiDefinitionId = row.id;
let bodyFiles = this.getBodyUploadFiles(tmp);
let url = "/api/testcase/create";
this.$fileUpload(url, null, bodyFiles, tmp, (response) => {
});
},
setParameters(data) { setParameters(data) {
data.projectId = this.projectId; data.projectId = this.projectId;
this.request.name = this.currentApi.name; this.request.name = this.currentApi.name;
@ -185,6 +202,9 @@
data.request.protocol = this.currentProtocol; data.request.protocol = this.currentProtocol;
} }
data.id = data.request.id; data.id = data.request.id;
if (!data.method) {
data.method = this.currentProtocol;
}
data.response = this.response; data.response = this.response;
}, },
getBodyUploadFiles(data) { getBodyUploadFiles(data) {

View File

@ -22,7 +22,7 @@
<!-- 请求参数 --> <!-- 请求参数 -->
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p> <p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
<ms-basis-parameters :request="request"/> <ms-basis-parameters :show-script="false" :request="request"/>
</div> </div>

View File

@ -6,7 +6,7 @@
@command="handleCommand" size="small" style="float: right;margin-right: 20px"> @command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{$t('commons.test')}} {{$t('commons.test')}}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item> <el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as_case')}}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -43,7 +43,7 @@
export default { export default {
name: "ApiConfig", name: "ApiConfig",
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters,MsJmxStep}, components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters, MsJmxStep},
props: { props: {
currentProtocol: String, currentProtocol: String,
scenario: Boolean, scenario: Boolean,
@ -119,6 +119,7 @@
}, },
saveAs() { saveAs() {
let obj = {request: this.request}; let obj = {request: this.request};
obj.request.id = getUUID();
this.$emit('saveAs', obj); this.$emit('saveAs', obj);
} }
} }

View File

@ -19,7 +19,7 @@
@command="handleCommand" size="small" v-if="testCase===undefined && !scenario"> @command="handleCommand" size="small" v-if="testCase===undefined && !scenario">
{{$t('commons.test')}} {{$t('commons.test')}}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item> <el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as_case')}}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</el-form-item> </el-form-item>
@ -58,7 +58,7 @@
export default { export default {
name: "ApiConfig", name: "ApiConfig",
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun,MsJmxStep}, components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsJmxStep},
props: { props: {
currentProtocol: String, currentProtocol: String,
testCase: {}, testCase: {},
@ -155,6 +155,8 @@
saveAs() { saveAs() {
this.$refs['debugForm'].validate((valid) => { this.$refs['debugForm'].validate((valid) => {
if (valid) { if (valid) {
this.debugForm.id = null;
this.request.id = getUUID();
this.debugForm.request = this.request; this.debugForm.request = this.request;
this.debugForm.userId = getCurrentUser().id; this.debugForm.userId = getCurrentUser().id;
this.debugForm.status = "Underway"; this.debugForm.status = "Underway";

View File

@ -6,7 +6,7 @@
@command="handleCommand" size="small" style="float: right;margin-right: 20px"> @command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{$t('commons.test')}} {{$t('commons.test')}}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item> <el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as_case')}}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
@ -122,6 +122,7 @@
}, },
saveAs() { saveAs() {
let obj = {request: this.request}; let obj = {request: this.request};
obj.request.id = getUUID();
this.$emit('saveAs', obj); this.$emit('saveAs', obj);
} }
} }

View File

@ -15,7 +15,7 @@
@command="handleCommand" size="small" style="float: right;margin-right: 20px"> @command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{$t('commons.test')}} {{$t('commons.test')}}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item> <el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as_case')}}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</el-form-item> </el-form-item>
@ -131,6 +131,7 @@
}, },
saveAs() { saveAs() {
let obj = {request: this.request}; let obj = {request: this.request};
obj.request.id = getUUID();
this.$emit('saveAs', obj); this.$emit('saveAs', obj);
} }
} }

View File

@ -0,0 +1,83 @@
<template>
<el-col :span="3" class="ms-left-cell">
<el-button class="ms-left-buttion" size="small" @click="addPre">+{{$t('api_test.definition.request.pre_script')}}</el-button>
<br/>
<el-button class="ms-left-buttion" size="small" @click="addPost">+{{$t('api_test.definition.request.post_script')}}</el-button>
<br/>
<el-button class="ms-left-buttion" size="small" @click="addAssertions">+{{$t('api_test.definition.request.assertions_rule')}}</el-button>
<br/>
<el-button class="ms-left-buttion" size="small" @click="addExtract">+{{$t('api_test.definition.request.extract_param')}}</el-button>
</el-col>
</template>
<script>
import {createComponent} from "../../jmeter/components";
import {Assertions, Extract} from "../../../model/ApiTestModel";
export default {
name: "ApiDefinitionStepButton",
props: {
request: {
type: Object,
default() {
return {}
}
}
},
methods: {
addPre() {
let jsr223PreProcessor = createComponent("JSR223PreProcessor");
this.request.hashTree.push(jsr223PreProcessor);
},
addPost() {
let jsr223PostProcessor = createComponent("JSR223PostProcessor");
this.request.hashTree.push(jsr223PostProcessor);
},
addAssertions() {
let assertions = new Assertions();
this.request.hashTree.push(assertions);
},
addExtract() {
let jsonPostProcessor = new Extract();
this.request.hashTree.push(jsonPostProcessor);
},
}
}
</script>
<style scoped>
.ms-left-cell .el-button:nth-of-type(1) {
color: #B8741A;
background-color: #F9F1EA;
border: #F9F1EA;
}
.ms-left-cell .el-button:nth-of-type(2) {
color: #783887;
background-color: #F2ECF3;
border: #F2ECF3;
}
.ms-left-cell .el-button:nth-of-type(3) {
color: #A30014;
background-color: #F7E6E9;
border: #F7E6E9;
}
.ms-left-cell .el-button:nth-of-type(4) {
color: #015478;
background-color: #E6EEF2;
border: #E6EEF2;
}
.ms-left-cell {
margin-top: 30px;
}
.ms-left-buttion {
margin: 6px 0px 8px 30px;
}
</style>

View File

@ -71,35 +71,9 @@
</el-tabs> </el-tabs>
</div> </div>
<!--<div v-if="!referenced">-->
<!--<div v-for="row in request.hashTree" :key="row.id">-->
<!--&lt;!&ndash;前置脚本&ndash;&gt;-->
<!--<ms-jsr233-processor v-if="row.type==='JSR223PreProcessor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.definition.request.pre_script')"-->
<!--:jsr223-processor="row"/>-->
<!--&lt;!&ndash;后置脚本&ndash;&gt;-->
<!--<ms-jsr233-processor v-if="row.label ==='JSR223 PostProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.post_script')"-->
<!--:jsr223-processor="row"/>-->
<!--&lt;!&ndash;断言规则&ndash;&gt;-->
<!--<div style="margin-top: 10px">-->
<!--<ms-api-assertions :response="response" v-if="row.type==='Assertions'" @copyRow="copyRow" @remove="remove" :is-read-only="isReadOnly" :assertions="row"/>-->
<!--</div>-->
<!--&lt;!&ndash;提取规则&ndash;&gt;-->
<!--<div style="margin-top: 10px">-->
<!--<ms-api-extract :response="response" :is-read-only="isReadOnly" @copyRow="copyRow" @remove="remove" v-if="row.type==='Extract'" :extract="row"/>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
</el-col> </el-col>
<!--操作按钮--> <!--操作按钮-->
<el-col :span="3" class="ms-left-cell" v-if="!referenced && showScript"> <api-definition-step-button :request="request" v-if="!referenced && showScript"/>
<el-button class="ms-left-buttion" size="small" @click="addPre">+{{$t('api_test.definition.request.pre_script')}}</el-button>
<br/>
<el-button class="ms-left-buttion" size="small" @click="addPost">+{{$t('api_test.definition.request.post_script')}}</el-button>
<br/>
<el-button class="ms-left-buttion" size="small" @click="addAssertions">+{{$t('api_test.definition.request.assertions_rule')}}</el-button>
<br/>
<el-button class="ms-left-buttion" size="small" @click="addExtract">+{{$t('api_test.definition.request.extract_param')}}</el-button>
</el-col>
</el-row> </el-row>
<batch-add-parameter @batchSave="batchSave" ref="batchAddParameter"/> <batch-add-parameter @batchSave="batchSave" ref="batchAddParameter"/>
</div> </div>
@ -120,10 +94,12 @@
import BatchAddParameter from "../../basis/BatchAddParameter"; import BatchAddParameter from "../../basis/BatchAddParameter";
import MsApiAdvancedConfig from "./ApiAdvancedConfig"; import MsApiAdvancedConfig from "./ApiAdvancedConfig";
import MsJsr233Processor from "../../../../automation/scenario/component/Jsr233Processor"; import MsJsr233Processor from "../../../../automation/scenario/component/Jsr233Processor";
import ApiDefinitionStepButton from "../components/ApiDefinitionStepButton";
export default { export default {
name: "MsApiHttpRequestForm", name: "MsApiHttpRequestForm",
components: { components: {
ApiDefinitionStepButton,
MsJsr233Processor, MsJsr233Processor,
MsApiAdvancedConfig, MsApiAdvancedConfig,
BatchAddParameter, BatchAddParameter,
@ -194,26 +170,6 @@
}, },
methods: { methods: {
addPre() {
let jsr223PreProcessor = createComponent("JSR223PreProcessor");
this.request.hashTree.push(jsr223PreProcessor);
this.reload();
},
addPost() {
let jsr223PostProcessor = createComponent("JSR223PostProcessor");
this.request.hashTree.push(jsr223PostProcessor);
this.reload();
},
addAssertions() {
let assertions = new Assertions();
this.request.hashTree.push(assertions);
this.reload();
},
addExtract() {
let jsonPostProcessor = new Extract();
this.request.hashTree.push(jsonPostProcessor);
this.reload();
},
remove(row) { remove(row) {
let index = this.request.hashTree.indexOf(row); let index = this.request.hashTree.indexOf(row);
this.request.hashTree.splice(index, 1); this.request.hashTree.splice(index, 1);
@ -289,13 +245,6 @@
</script> </script>
<style scoped> <style scoped>
.ms-left-cell {
margin-top: 30px;
}
.ms-left-buttion {
margin: 6px 0px 8px 30px;
}
.ms-query { .ms-query {
background: #783887; background: #783887;
@ -316,30 +265,6 @@
min-height: 200px; min-height: 200px;
} }
.ms-left-cell .el-button:nth-of-type(1) {
color: #B8741A;
background-color: #F9F1EA;
border: #F9F1EA;
}
.ms-left-cell .el-button:nth-of-type(2) {
color: #783887;
background-color: #F2ECF3;
border: #F2ECF3;
}
.ms-left-cell .el-button:nth-of-type(3) {
color: #A30014;
background-color: #F7E6E9;
border: #F7E6E9;
}
.ms-left-cell .el-button:nth-of-type(4) {
color: #015478;
background-color: #E6EEF2;
border: #E6EEF2;
}
.ms-el-link { .ms-el-link {
float: right; float: right;
margin-right: 45px; margin-right: 45px;

View File

@ -101,30 +101,11 @@
</el-form> </el-form>
</div> </div>
<!--<div v-for="row in request.hashTree" :key="row.id" v-loading="isReloadData" style="margin-left: 20px;width: 100%">-->
<!--&lt;!&ndash; 前置脚本 &ndash;&gt;-->
<!--<ms-jsr233-processor v-if="row.label ==='JSR223 PreProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.pre_script')" style-type="color: #B8741A;background-color: #F9F1EA"-->
<!--:jsr223-processor="row"/>-->
<!--&lt;!&ndash;后置脚本&ndash;&gt;-->
<!--<ms-jsr233-processor v-if="row.label ==='JSR223 PostProcessor'" @copyRow="copyRow" @remove="remove" :is-read-only="false" :title="$t('api_test.definition.request.post_script')" style-type="color: #783887;background-color: #F2ECF3"-->
<!--:jsr223-processor="row"/>-->
<!--&lt;!&ndash;断言规则&ndash;&gt;-->
<!--<ms-api-assertions v-if="row.type==='Assertions'" @copyRow="copyRow" @remove="remove" :is-read-only="isReadOnly" :assertions="row"/>-->
<!--&lt;!&ndash;提取规则&ndash;&gt;-->
<!--<ms-api-extract :is-read-only="isReadOnly" @copyRow="copyRow" @remove="remove" v-if="row.type==='Extract'" :extract="row"/>-->
<!--</div>-->
</el-col> </el-col>
<!--<el-col :span="3" class="ms-left-cell">--> <!--操作按钮-->
<!--<el-button class="ms-left-buttion" size="small" style="color: #B8741A;background-color: #F9F1EA" @click="addPre">+{{$t('api_test.definition.request.pre_script')}}</el-button>--> <api-definition-step-button :request="request" v-if="!referenced && showScript"/>
<!--<br/>-->
<!--<el-button class="ms-left-buttion" size="small" style="color: #783887;background-color: #F2ECF3" @click="addPost">+{{$t('api_test.definition.request.post_script')}}</el-button>-->
<!--<br/>-->
<!--<el-button class="ms-left-buttion" size="small" style="color: #A30014;background-color: #F7E6E9" @click="addAssertions">+{{$t('api_test.definition.request.assertions_rule')}}</el-button>-->
<!--<br/>-->
<!--<el-button class="ms-left-buttion" size="small" style="color: #015478;background-color: #E6EEF2" @click="addExtract">+{{$t('api_test.definition.request.extract_param')}}</el-button>-->
<!--</el-col>-->
</el-row> </el-row>
</div> </div>
</template> </template>
@ -147,11 +128,13 @@
import MsInstructionsIcon from "../../../../../common/components/MsInstructionsIcon"; import MsInstructionsIcon from "../../../../../common/components/MsInstructionsIcon";
import Jsr233ProcessorContent from "../../../../automation/scenario/common/Jsr233ProcessorContent"; import Jsr233ProcessorContent from "../../../../automation/scenario/common/Jsr233ProcessorContent";
import JSR223PreProcessor from "../../jmeter/components/pre-processors/jsr223-pre-processor"; import JSR223PreProcessor from "../../jmeter/components/pre-processors/jsr223-pre-processor";
import ApiDefinitionStepButton from "../components/ApiDefinitionStepButton";
export default { export default {
name: "TcpBasisParameters", name: "TcpBasisParameters",
components: { components: {
ApiDefinitionStepButton,
Jsr233ProcessorContent, Jsr233ProcessorContent,
MsInstructionsIcon, MsInstructionsIcon,
MsApiVariable, MsApiVariable,
@ -167,6 +150,14 @@
type: Boolean, type: Boolean,
default: false default: false
}, },
showScript: {
type: Boolean,
default: true,
},
referenced: {
type: Boolean,
default: false,
},
}, },
data() { data() {
return { return {

View File

@ -2,34 +2,43 @@
<div class="card-container"> <div class="card-container">
<el-card class="card-content" v-loading="loading"> <el-card class="card-content" v-loading="loading">
<!-- 操作按钮 -->
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand('add')"
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{$t('commons.test')}}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="load_case">{{$t('api_test.definition.request.load_case')}}
</el-dropdown-item>
<el-dropdown-item command="save_as_case">{{$t('api_test.definition.request.save_as_case')}}
</el-dropdown-item>
<el-dropdown-item command="update_api">{{$t('api_test.definition.request.update_api')}}</el-dropdown-item>
<el-dropdown-item command="save_as_api">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<p class="tip">{{$t('test_track.plan_view.base_info')}} </p> <el-form :model="api" :rules="rules" ref="apiData" :inline="true" label-position="right">
<!-- 执行环境 -->
{{$t('api_test.definition.request.run_env')}}
<environment-select :type="'TCP'" :current-data="api" :project-id="projectId"/>
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p> <!-- 操作按钮 -->
<!-- TCP 请求参数 --> <el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand('add')"
<ms-basis-parameters :request="api.request" @callback="runTest" ref="requestForm"/> @command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{$t('commons.test')}}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="load_case">{{$t('api_test.definition.request.load_case')}}
</el-dropdown-item>
<el-dropdown-item command="save_as_case">{{$t('api_test.definition.request.save_as_case')}}
</el-dropdown-item>
<el-dropdown-item command="update_api">{{$t('api_test.definition.request.update_api')}}</el-dropdown-item>
<el-dropdown-item command="save_as_api">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<p class="tip">{{$t('test_track.plan_view.base_info')}} </p>
<!-- 执行环境 -->
<el-form-item prop="environmentId">
{{$t('api_test.definition.request.run_env')}}
<environment-select :type="'TCP'" :current-data="api" :project-id="projectId"/>
</el-form-item>
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
<!-- TCP 请求参数 -->
<ms-basis-parameters :request="api.request" @callback="runTest" ref="requestForm"/>
</el-form>
<!--返回结果--> <!--返回结果-->
<!-- HTTP 请求返回数据 --> <!-- HTTP 请求返回数据 -->
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p> <p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
<ms-request-result-tail :response="responseData" ref="runResult"/> <ms-request-result-tail :response="responseData" ref="runResult"/>
<ms-jmx-step :request="api.request" :response="responseData"/>
</el-card> </el-card>
<!-- 加载用例 --> <!-- 加载用例 -->
@ -55,10 +64,12 @@
import MsBasisParameters from "../request/tcp/TcpBasisParameters"; import MsBasisParameters from "../request/tcp/TcpBasisParameters";
import {REQ_METHOD} from "../../model/JsonData"; import {REQ_METHOD} from "../../model/JsonData";
import EnvironmentSelect from "../environment/EnvironmentSelect"; import EnvironmentSelect from "../environment/EnvironmentSelect";
import MsJmxStep from "../step/JmxStep";
export default { export default {
name: "RunTestTCPPage", name: "RunTestTCPPage",
components: { components: {
MsJmxStep,
EnvironmentSelect, EnvironmentSelect,
MsApiRequestForm, MsApiRequestForm,
MsApiCaseList, MsApiCaseList,
@ -81,8 +92,6 @@
refreshSign: "", refreshSign: "",
createCase: "", createCase: "",
rules: { 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'}],
environmentId: [{required: true, message: this.$t('api_test.definition.request.run_env'), trigger: 'change'}], environmentId: [{required: true, message: this.$t('api_test.definition.request.run_env'), trigger: 'change'}],
}, },
runData: [], runData: [],
@ -110,13 +119,17 @@
this.$emit('refresh'); this.$emit('refresh');
}, },
runTest() { runTest() {
this.loading = true; this.$refs['apiData'].validate((valid) => {
this.api.request.name = this.api.id; if (valid) {
this.api.protocol = this.currentProtocol; this.loading = true;
this.runData = []; this.api.request.name = this.api.id;
this.runData.push(this.api.request); this.api.protocol = this.currentProtocol;
/*触发执行操作*/ this.runData = [];
this.reportId = getUUID().substring(0, 8); this.runData.push(this.api.request);
/*触发执行操作*/
this.reportId = getUUID().substring(0, 8);
}
})
}, },
runRefresh(data) { runRefresh(data) {
this.responseData = data; this.responseData = data;

View File

@ -1,10 +1,10 @@
<template> <template>
<div> <div v-if="request.hashTree && request.hashTree.length > 0">
<p class="tip"> <p class="tip">
{{$t('test_track.plan_view.step')}} {{$t('test_track.plan_view.step')}}
</p> </p>
<!-- HTTP 请求参数 --> <!-- HTTP 请求参数 -->
<div style="border:1px #DCDFE6 solid; height: 100%;border-radius: 4px ;width: 100%" v-loading="isReloadData" v-if="request.hashTree && request.hashTree.length>0"> <div style="height: 100%;border-radius: 4px ;width: 100%" v-loading="isReloadData" v-if="request.hashTree && request.hashTree.length>0">
<div v-for="row in request.hashTree" :key="row.id"> <div v-for="row in request.hashTree" :key="row.id">
<!--前置脚本--> <!--前置脚本-->

View File

@ -10,7 +10,21 @@
<el-table-column <el-table-column
prop="label" prop="label"
label="Label" label="Label"
width="450"/> width="450">
<template v-slot:header="{column}">
<span>Label</span>
<i class="el-icon-search" style="margin-left: 8px;cursor: pointer;font-weight: bold;" @click="click(column)"></i>
<el-input v-model="searchLabel"
placeholder="请输入 Label 搜索"
size="mini"
class="search_input"
style="width: 250px; margin-left: 5px"
v-if="column.showSearch"
clearable
@clear="filterLabel"
@keyup.enter.native="filterLabel"/>
</template>
</el-table-column>
</el-table-column> </el-table-column>
<el-table-column label="Executions" align="center"> <el-table-column label="Executions" align="center">
@ -94,17 +108,35 @@ export default {
data() { data() {
return { return {
tableData: [], tableData: [],
id: '' originalData: [],
id: '',
searchLabel: '',
showSearch: false,
showBtn: true,
} }
}, },
methods: { methods: {
initTableData() { initTableData() {
this.$get("/performance/report/content/" + this.id).then(res => { this.$get("/performance/report/content/" + this.id).then(res => {
this.tableData = res.data.data; this.tableData = res.data.data;
this.originalData = res.data.data;
}).catch(() => { }).catch(() => {
this.tableData = []; this.tableData = [];
}) })
}, },
click(column) {
this.searchLabel = '';
this.tableData = this.originalData;
this.$set(column, 'showSearch', !column.showSearch);
},
filterLabel() {
this.tableData = this.searchLabel ? this.originalData.filter(this.createFilter(this.searchLabel)) : this.originalData;
},
createFilter(queryString) {
return item => {
return (item.label.toLowerCase().indexOf(queryString.toLowerCase()) !== -1);
};
},
}, },
watch: { watch: {
report: { report: {
@ -128,5 +160,7 @@ export default {
</script> </script>
<style scoped> <style scoped>
.search_input >>> .el-input__inner {
border-radius: 50px;
}
</style> </style>

View File

@ -226,10 +226,7 @@ export default {
if (projectId) { if (projectId) {
this.projectId = projectId; this.projectId = projectId;
} }
this.$refs.nodeTree.result = this.$post("/case/node/list/all/plan", this.treeNodes = [];
{testPlanId: this.planId, projectId: this.projectId}, response => {
this.treeNodes = response.data;
});
this.selectNodeIds = []; this.selectNodeIds = [];
} }
} }