Merge remote-tracking branch 'origin/master' into master

This commit is contained in:
Captain.B 2020-12-21 17:58:26 +08:00
commit e2e740693c
6 changed files with 58 additions and 42 deletions

View File

@ -24,6 +24,9 @@ public class MsThreadGroup extends MsTestElement {
final HashTree groupTree = tree.add(getThreadGroup());
if ((config != null && config.isEnableCookieShare()) || enableCookieShare) {
CookieManager cookieManager = new CookieManager();
cookieManager.setProperty(TestElement.TEST_CLASS, CookieManager.class.getName());
cookieManager.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("CookiePanel"));
cookieManager.setEnabled(true);
cookieManager.setName("CookieManager");
cookieManager.setClearEachIteration(false);
cookieManager.setControlledByThread(false);

View File

@ -78,10 +78,10 @@
<!-- 测试-->
<div v-else-if="item.type=== 'TEST'" class="ms-api-div">
<ms-run-test-http-page :currentProtocol="currentProtocol" :api-data="runTestData" @saveAsApi="editApi" v-if="currentProtocol==='HTTP'"/>
<ms-run-test-tcp-page :currentProtocol="currentProtocol" :api-data="runTestData" @saveAsApi="editApi" v-if="currentProtocol==='TCP'"/>
<ms-run-test-sql-page :currentProtocol="currentProtocol" :api-data="runTestData" @saveAsApi="editApi" v-if="currentProtocol==='SQL'"/>
<ms-run-test-dubbo-page :currentProtocol="currentProtocol" :api-data="runTestData" @saveAsApi="editApi" v-if="currentProtocol==='DUBBO'"/>
<ms-run-test-http-page :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi" v-if="currentProtocol==='HTTP'"/>
<ms-run-test-tcp-page :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi" v-if="currentProtocol==='TCP'"/>
<ms-run-test-sql-page :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi" v-if="currentProtocol==='SQL'"/>
<ms-run-test-dubbo-page :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi" v-if="currentProtocol==='DUBBO'"/>
</div>
</el-tab-pane>
</el-tabs>
@ -144,7 +144,6 @@
selectNodeIds: [],
currentApi: {},
moduleOptions: {},
runTestData: {},
trashEnable: false,
apiTabs: [{
title: this.$t('api_test.definition.api_title'),
@ -260,18 +259,17 @@
break;
}
}
this.runTestData = data;
},
runTest(data) {
this.setTabTitle(data);
this.handleCommand("TEST");
this.handleTabsEdit(this.$t("commons.api"), "TEST", data);
},
saveApi(data) {
this.setTabTitle(data);
this.$refs.apiList[0].initTable(data);
},
showExecResult(row){
showExecResult(row) {
this.debug(row);
},

View File

@ -63,35 +63,7 @@
this.initHttp();
break;
}
if (this.currentApi.response != null && this.currentApi.response != 'null' && this.currentApi.response != undefined) {
if (Object.prototype.toString.call(this.currentApi.response).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
this.response = this.currentApi.response;
} else {
this.response = JSON.parse(this.currentApi.response);
}
} else {
this.response = {headers: [], body: new Body(), statusCode: [], type: "HTTP"};
}
if (this.currentApi != null && this.currentApi.id != null) {
this.reqUrl = "/api/definition/update";
} else {
this.reqUrl = "/api/definition/create";
}
if (!this.request.hashTree) {
this.request.hashTree = [];
}
//
if (this.response.body) {
let body = new Body();
Object.assign(body, this.response.body);
if (!body.binary) {
body.binary = [];
}
if (!body.kvs) {
body.kvs = [];
}
this.response.body = body;
}
this.formatApi();
},
methods: {
runTest(data) {
@ -145,6 +117,40 @@
this.currentApi.request = this.request;
}
},
formatApi() {
if (this.currentApi.response != null && this.currentApi.response != 'null' && this.currentApi.response != undefined) {
if (Object.prototype.toString.call(this.currentApi.response).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
this.response = this.currentApi.response;
} else {
this.response = JSON.parse(this.currentApi.response);
}
} else {
this.response = {headers: [], body: new Body(), statusCode: [], type: "HTTP"};
}
if (this.currentApi != null && this.currentApi.id != null) {
this.reqUrl = "/api/definition/update";
} else {
this.reqUrl = "/api/definition/create";
}
if (!this.request.hashTree) {
this.request.hashTree = [];
}
//
if (this.response.body) {
let body = new Body();
Object.assign(body, this.response.body);
if (!body.binary) {
body.binary = [];
}
if (!body.kvs) {
body.kvs = [];
}
this.response.body = body;
}
if (this.currentApi.moduleId && this.currentApi.moduleId === "root") {
this.currentApi.moduleId = "";
}
},
saveApi(data) {
this.setParameters(data);
let bodyFiles = this.getBodyUploadFiles(data);

View File

@ -72,8 +72,14 @@
},
},
data() {
let validateURL = (rule, value, callback) => {
if (!this.httpForm.path.startsWith("/") || this.httpForm.path.match(/\s/) != null) {
callback(this.$t('api_test.definition.request.path_valid_info'));
}
callback();
};
return {
httpForm: {},
httpForm: {environmentId: ""},
httpVisible: false,
currentModule: {},
maintainerOptions: [],
@ -82,7 +88,7 @@
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
],
path: [{required: true, message: this.$t('api_test.definition.request.path_info'), trigger: 'blur'}],
path: [{required: true, message: this.$t('api_test.definition.request.path_info'), trigger: 'blur'}, {validator: validateURL, trigger: 'blur'}],
userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
},
value: REQ_METHOD[0].id,

View File

@ -117,7 +117,7 @@
moduleId: [{required: true, message: this.$t('test_track.case.input_module'), trigger: 'change'}],
status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
},
httpForm: {},
httpForm: {environmentId: ""},
isShowEnable: false,
maintainerOptions: [],
currentModule: {},
@ -173,6 +173,9 @@
created() {
this.getMaintainerOptions();
if (!this.basisData.environmentId) {
this.basisData.environmentId = "";
}
this.httpForm = JSON.parse(JSON.stringify(this.basisData));
}
}

View File

@ -7,7 +7,7 @@
<el-form-item :label="$t('api_report.request')" prop="url">
<el-input :placeholder="$t('api_test.definition.request.path_all_info')" v-model="debugForm.url"
class="ms-http-input" size="small">
class="ms-http-input" size="small" :disabled="testCase!=undefined">
<el-select v-model="debugForm.method" slot="prepend" style="width: 100px" size="small">
<el-option v-for="item in reqOptions" :key="item.id" :label="item.label" :value="item.id"/>
</el-select>
@ -16,7 +16,7 @@
<el-form-item>
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand"
@command="handleCommand" size="small">
@command="handleCommand" size="small" v-if="testCase===undefined">
{{$t('commons.test')}}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item>