fix: 修复接口测试落干bug
This commit is contained in:
parent
ddf4d7f938
commit
bfa01c09e9
1159
backend/tree.txt
1159
backend/tree.txt
File diff suppressed because one or more lines are too long
|
@ -255,7 +255,7 @@
|
||||||
return this.test.isValid() && !this.change;
|
return this.test.isValid() && !this.change;
|
||||||
},
|
},
|
||||||
isDisabled() {
|
isDisabled() {
|
||||||
return !(this.test.isValid() && this.change)
|
return !(this.test.isValid())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -90,14 +90,14 @@
|
||||||
activeName: "parameters",
|
activeName: "parameters",
|
||||||
rules: {
|
rules: {
|
||||||
name: [
|
name: [
|
||||||
{max: 100, message: this.$t('commons.input_limit', [0, 100]), trigger: 'blur'}
|
{max: 100, message: this.$t('commons.input_limit', [1, 100]), trigger: 'blur'}
|
||||||
],
|
],
|
||||||
url: [
|
url: [
|
||||||
{max: 500, required: true, message: this.$t('commons.input_limit', [0, 500]), trigger: 'blur'},
|
{max: 500, required: true, message: this.$t('commons.input_limit', [1, 500]), trigger: 'blur'},
|
||||||
{validator: validateURL, trigger: 'blur'}
|
{validator: validateURL, trigger: 'blur'}
|
||||||
],
|
],
|
||||||
path: [
|
path: [
|
||||||
{max: 500, required: true, message: this.$t('commons.input_limit', [0, 500]), trigger: 'blur'},
|
{max: 500, required: true, message: this.$t('commons.input_limit', [1, 500]), trigger: 'blur'},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,6 +143,7 @@
|
||||||
this.$error(this.$t('api_test.request.please_add_environment_to_scenario'), 2000);
|
this.$error(this.$t('api_test.request.please_add_environment_to_scenario'), 2000);
|
||||||
this.request.useEnvironment = false;
|
this.request.useEnvironment = false;
|
||||||
}
|
}
|
||||||
|
this.$refs["request"].clearValidate();
|
||||||
},
|
},
|
||||||
addProtocol(url) {
|
addProtocol(url) {
|
||||||
if (url) {
|
if (url) {
|
||||||
|
|
|
@ -8,6 +8,11 @@
|
||||||
<el-select :disabled="isReadOnly" v-model="scenario.environmentId" class="environment-select" @change="environmentChange" clearable>
|
<el-select :disabled="isReadOnly" v-model="scenario.environmentId" class="environment-select" @change="environmentChange" clearable>
|
||||||
<el-option v-for="(environment, index) in environments" :key="index" :label="environment.name + ': ' + environment.protocol + '://' + environment.socket" :value="environment.id"/>
|
<el-option v-for="(environment, index) in environments" :key="index" :label="environment.name + ': ' + environment.protocol + '://' + environment.socket" :value="environment.id"/>
|
||||||
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">{{$t('api_test.environment.environment_config')}}</el-button>
|
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">{{$t('api_test.environment.environment_config')}}</el-button>
|
||||||
|
<template v-slot:empty>
|
||||||
|
<div class="empty-environment">
|
||||||
|
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">{{$t('api_test.environment.environment_config')}}</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
@ -65,18 +70,32 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
projectId() {
|
||||||
|
this.getEnvironments();
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getEnvironments() {
|
getEnvironments() {
|
||||||
if (this.projectId) {
|
if (this.projectId) {
|
||||||
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
|
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
|
||||||
this.environments = response.data;
|
this.environments = response.data;
|
||||||
|
let hasEnvironment = false;
|
||||||
for (let i in this.environments) {
|
for (let i in this.environments) {
|
||||||
if (this.environments[i].id === this.scenario.environmentId) {
|
if (this.environments[i].id === this.scenario.environmentId) {
|
||||||
this.scenario.environment = this.environments[i];
|
this.scenario.environment = this.environments[i];
|
||||||
|
hasEnvironment = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!hasEnvironment) {
|
||||||
|
this.scenario.environmentId = '';
|
||||||
|
this.scenario.environment = undefined;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.scenario.environmentId = '';
|
||||||
|
this.scenario.environment = undefined;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
environmentChange(value) {
|
environmentChange(value) {
|
||||||
|
@ -97,6 +116,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openEnvironmentConfig() {
|
openEnvironmentConfig() {
|
||||||
|
if (!this.projectId) {
|
||||||
|
this.$error(this.$t('api_test.select_project'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.$refs.environmentConfig.open(this.projectId);
|
this.$refs.environmentConfig.open(this.projectId);
|
||||||
},
|
},
|
||||||
environmentConfigClose() {
|
environmentConfigClose() {
|
||||||
|
@ -117,4 +140,8 @@
|
||||||
padding: 7px;
|
padding: 7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.empty-environment {
|
||||||
|
padding: 10px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -61,7 +61,10 @@
|
||||||
return {
|
return {
|
||||||
result: {},
|
result: {},
|
||||||
rules: {
|
rules: {
|
||||||
name :[{required: true, message: this.$t('commons.input_name'), trigger: 'blur'}],
|
name :[
|
||||||
|
{required: true, message: this.$t('commons.input_name'), trigger: 'blur'},
|
||||||
|
{max: 64, message: this.$t('commons.input_limit', [1, 64]), trigger: 'blur'}
|
||||||
|
],
|
||||||
socket :[{required: true, validator: socketValidator, trigger: 'blur'}],
|
socket :[{required: true, validator: socketValidator, trigger: 'blur'}],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -83,7 +86,9 @@
|
||||||
url = '/api/environment/update';
|
url = '/api/environment/update';
|
||||||
}
|
}
|
||||||
this.result = this.$post(url, param, response => {
|
this.result = this.$post(url, param, response => {
|
||||||
this.environment.id = response.data;
|
if (!param.id) {
|
||||||
|
this.environment.id = response.data;
|
||||||
|
}
|
||||||
this.$success(this.$t('commons.save_success'));
|
this.$success(this.$t('commons.save_success'));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -169,9 +169,6 @@ export class Scenario extends BaseConfig {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.name) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -396,8 +393,6 @@ class JMXRequest {
|
||||||
constructor(request) {
|
constructor(request) {
|
||||||
if (request && request instanceof Request && (request.url || request.path)) {
|
if (request && request instanceof Request && (request.url || request.path)) {
|
||||||
this.useEnvironment = request.useEnvironment;
|
this.useEnvironment = request.useEnvironment;
|
||||||
this.environment = request.environment;
|
|
||||||
this.path = decodeURIComponent(request.path);
|
|
||||||
this.method = request.method;
|
this.method = request.method;
|
||||||
if (!request.useEnvironment) {
|
if (!request.useEnvironment) {
|
||||||
let url = new URL(request.url);
|
let url = new URL(request.url);
|
||||||
|
@ -405,19 +400,28 @@ class JMXRequest {
|
||||||
this.pathname = decodeURIComponent(url.pathname);
|
this.pathname = decodeURIComponent(url.pathname);
|
||||||
this.port = url.port;
|
this.port = url.port;
|
||||||
this.protocol = url.protocol.split(":")[0];
|
this.protocol = url.protocol.split(":")[0];
|
||||||
}
|
this.pathname = this.getPostQueryParameters(request, this.pathname);
|
||||||
|
} else {
|
||||||
if (this.method.toUpperCase() !== "GET") {
|
this.environment = request.environment;
|
||||||
// this.pathname += url.search.replace('&', '&');
|
this.port = request.environment.port;
|
||||||
this.pathname += '?';
|
this.path = decodeURIComponent(request.path);
|
||||||
request.parameters.forEach(parameter => {
|
this.path = this.getPostQueryParameters(request, this.path);
|
||||||
if (parameter.name) {
|
|
||||||
this.pathname += (parameter.name + '=' + parameter.value + '&');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPostQueryParameters(request, path) {
|
||||||
|
if (this.method.toUpperCase() !== "GET") {
|
||||||
|
path += '?';
|
||||||
|
request.parameters.forEach(parameter => {
|
||||||
|
if (parameter.name) {
|
||||||
|
path += (parameter.name + '=' + parameter.value + '&');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class JMeterTestPlan extends Element {
|
class JMeterTestPlan extends Element {
|
||||||
|
|
Loading…
Reference in New Issue