Merge remote-tracking branch 'origin/v1.1' into v1.1

This commit is contained in:
wenyann 2020-07-21 10:16:35 +08:00
commit 9ca7fdf576
12 changed files with 73 additions and 29 deletions

View File

@ -34,7 +34,7 @@ public class ApiTestEnvironmentService {
} }
public void update(ApiTestEnvironmentWithBLOBs apiTestEnvironment) { public void update(ApiTestEnvironmentWithBLOBs apiTestEnvironment) {
apiTestEnvironmentMapper.updateByPrimaryKey(apiTestEnvironment); apiTestEnvironmentMapper.updateByPrimaryKeyWithBLOBs(apiTestEnvironment);
} }
public String add(ApiTestEnvironmentWithBLOBs apiTestEnvironmentWithBLOBs) { public String add(ApiTestEnvironmentWithBLOBs apiTestEnvironmentWithBLOBs) {

View File

@ -58,14 +58,32 @@
} }
}, },
copyEnvironment(environment) { copyEnvironment(environment) {
if (!environment.id) {
this.$warning(this.$t('commons.please_save'))
return;
}
let newEnvironment = {}; let newEnvironment = {};
Object.assign(newEnvironment, environment); Object.assign(newEnvironment, environment);
newEnvironment.id = null; newEnvironment.id = null;
newEnvironment.name = this.getNoRepeatName(newEnvironment.name); newEnvironment.name = this.getNoRepeatName(newEnvironment.name);
if (!this.validateEnvironment(newEnvironment)) {
return;
}
this.$refs.environmentEdit._save(newEnvironment); this.$refs.environmentEdit._save(newEnvironment);
this.environments.push(newEnvironment); this.environments.push(newEnvironment);
this.$refs.environmentItems.itemSelected(this.environments.length -1 , newEnvironment); this.$refs.environmentItems.itemSelected(this.environments.length -1 , newEnvironment);
}, },
validateEnvironment(environment) {
if (!environment.name || !!environment.name && environment.name.length > 64) {
this.$error(this.$t('commons.input_limit', [1, 64]));
return false;
}
if (!this.$refs.environmentEdit.validateSocket(environment.socket)) {
this.$error(this.$t('commons.formatErr'));
return false;
}
return true;
},
getNoRepeatName(name) { getNoRepeatName(name) {
for (let i in this.environments) { for (let i in this.environments) {
if (this.environments[i].name === name) { if (this.environments[i].name === name) {
@ -97,14 +115,13 @@
} }
}, },
getEnvironment(environment) { getEnvironment(environment) {
let item = environment;
if (!(environment.variables instanceof Array)) { if (!(environment.variables instanceof Array)) {
item.variables = JSON.parse(environment.variables); environment.variables = JSON.parse(environment.variables);
} }
if (!(environment.headers instanceof Array)) { if (!(environment.headers instanceof Array)) {
item.headers = JSON.parse(environment.headers); environment.headers = JSON.parse(environment.headers);
} }
this.currentEnvironment = item; this.currentEnvironment = environment;
}, },
getDefaultEnvironment() { getDefaultEnvironment() {
return {variables: [{}], headers: [{}], protocol: 'https', projectId: this.projectId}; return {variables: [{}], headers: [{}], protocol: 'https', projectId: this.projectId};

View File

@ -100,8 +100,12 @@
buildParam(environment) { buildParam(environment) {
let param = {}; let param = {};
Object.assign(param, environment); Object.assign(param, environment);
if (!(environment.variables instanceof String)) {
param.variables = JSON.stringify(environment.variables); param.variables = JSON.stringify(environment.variables);
}
if (!(environment.headers instanceof String)) {
param.headers = JSON.stringify(environment.headers); param.headers = JSON.stringify(environment.headers);
}
return param; return param;
}, },
validateSocket(socket) { validateSocket(socket) {

View File

@ -47,20 +47,21 @@
<el-divider direction="vertical"/> <el-divider direction="vertical"/>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item prop="file" class="api-upload">
<el-upload <el-upload
class="api-upload"
drag drag
action="" action=""
:http-request="upload" :http-request="upload"
:limit="1" :limit="1"
:beforeUpload="uploadValidate" :beforeUpload="uploadValidate"
:on-remove="handleRemove"
:file-list="fileList" :file-list="fileList"
:on-exceed="handleExceed"
multiple> multiple>
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text" v-html="$t('load_test.upload_tips')"></div> <div class="el-upload__text" v-html="$t('load_test.upload_tips')"></div>
<div class="el-upload__tip" slot="tip">{{$t('api_test.api_import.file_size_limit')}}</div> <div class="el-upload__tip" slot="tip">{{$t('api_test.api_import.file_size_limit')}}</div>
</el-upload> </el-upload>
</el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
@ -133,15 +134,12 @@
], ],
projectId: [ projectId: [
{required: true, message: this.$t('api_test.select_project'), trigger: 'blur'}, {required: true, message: this.$t('api_test.select_project'), trigger: 'blur'},
], ]
file: [
{required: true, message: this.$t('commons.please_upload'), trigger: 'blur'},
],
}, },
fileList: [] fileList: []
} }
}, },
created() { activated() {
this.selectedPlatform = this.platforms[0]; this.selectedPlatform = this.platforms[0];
this.getProjects(); this.getProjects();
}, },
@ -164,7 +162,12 @@
}, },
upload(file) { upload(file) {
this.formData.file = file.file; this.formData.file = file.file;
this.fileList.push(file.file); },
handleExceed(files, fileList) {
this.$warning(this.$t('test_track.case.import.upload_limit_count'));
},
handleRemove(file, fileList) {
this.formData.file = undefined;
}, },
uploadValidate(file, fileList) { uploadValidate(file, fileList) {
let suffix = file.name.substring(file.name.lastIndexOf('.') + 1); let suffix = file.name.substring(file.name.lastIndexOf('.') + 1);
@ -208,6 +211,10 @@
Object.assign(param, this.formData); Object.assign(param, this.formData);
param.platform = this.selectedPlatformValue; param.platform = this.selectedPlatformValue;
param.useEnvironment = this.useEnvironment; param.useEnvironment = this.useEnvironment;
if (!this.formData.file) {
this.$warning(this.$t('commons.please_upload'));
return ;
}
this.result = this.$fileUpload('/api/import', param.file, param,response => { this.result = this.$fileUpload('/api/import', param.file, param,response => {
let res = response.data; let res = response.data;
this.$success(this.$t('test_track.case.import.success')); this.$success(this.$t('test_track.case.import.success'));
@ -240,7 +247,15 @@
.api-upload { .api-upload {
text-align: center; text-align: center;
display: inline-block; margin: auto 0;
}
.api-upload >>> .el-upload {
width: 100%;
}
.api-upload >>> .el-upload-dragger {
width: 100%;
} }
.el-radio-group { .el-radio-group {
@ -288,7 +303,7 @@
} }
.name-input { .name-input {
width: 195px; max-width: 195px;
} }
.dialog-footer { .dialog-footer {

View File

@ -10,7 +10,7 @@
<crontab-result v-show="false" :ex="schedule.value" ref="crontabResult" @resultListChange="resultListChange"/> <crontab-result v-show="false" :ex="schedule.value" ref="crontabResult" @resultListChange="resultListChange"/>
</div> </div>
<div> <div>
<span :class="{'disable-character': !schedule.enable}"> {{$t('schedule.next_execution_time')}}{{this.recentList.length > 0 ? this.recentList[0] : $t('schedule.not_set')}} </span> <span :class="{'disable-character': !schedule.enable}"> {{$t('schedule.next_execution_time')}}{{this.recentList.length > 0 && schedule.enable ? this.recentList[0] : $t('schedule.not_set')}} </span>
</div> </div>
</div> </div>
</template> </template>

View File

@ -1,5 +1,5 @@
<template> <template>
<el-dialog width="30%" class="schedule-edit" :title="$t('schedule.edit_timer_task')" :visible.sync="dialogVisible" @close="close"> <el-dialog width="35%" class="schedule-edit" :title="$t('schedule.edit_timer_task')" :visible.sync="dialogVisible" @close="close">
<div id="app"> <div id="app">
<el-form :model="form" :rules="rules" ref="from"> <el-form :model="form" :rules="rules" ref="from">
<el-form-item <el-form-item
@ -47,7 +47,9 @@
data() { data() {
const validateCron = (rule, cronValue, callback) => { const validateCron = (rule, cronValue, callback) => {
let customValidate = this.customValidate(this.getIntervalTime()); let customValidate = this.customValidate(this.getIntervalTime());
if (!cronValidate(cronValue)) { if (!cronValue) {
callback(new Error(this.$t('commons.input_content')));
} else if (!cronValidate(cronValue)) {
callback(new Error(this.$t('schedule.cron_expression_format_error'))); callback(new Error(this.$t('schedule.cron_expression_format_error')));
} else if(!this.intervalShortValidate()) { } else if(!this.intervalShortValidate()) {
callback(new Error(this.$t('schedule.cron_expression_interval_short_error'))); callback(new Error(this.$t('schedule.cron_expression_interval_short_error')));

View File

@ -126,8 +126,8 @@
importAPITest() { importAPITest() {
let apiTest = this.$store.state.api.test; let apiTest = this.$store.state.api.test;
if (apiTest && apiTest.name) { if (apiTest && apiTest.name) {
this.testPlan.projectId = apiTest.projectId; this.$set(this.testPlan, "projectId", apiTest.projectId);
this.testPlan.name = apiTest.name; this.$set(this.testPlan, "name", apiTest.name);
let blob = new Blob([apiTest.jmx.xml], {type: "application/octet-stream"}); let blob = new Blob([apiTest.jmx.xml], {type: "application/octet-stream"});
let file = new File([blob], apiTest.jmx.name); let file = new File([blob], apiTest.jmx.name);
this.$refs.basicConfig.beforeUpload(file); this.$refs.basicConfig.beforeUpload(file);
@ -274,7 +274,7 @@
}, },
checkScheduleEdit() { checkScheduleEdit() {
if (!this.testPlan.id) { if (!this.testPlan.id) {
this.$message('请先保存测试'); this.$message(this.$t('api_test.environment.please_save_test'));
return false; return false;
} }
return true; return true;
@ -284,7 +284,7 @@
if (intervalTime < duration) { if (intervalTime < duration) {
return { return {
pass: false, pass: false,
info: '间隔时间不能小于压测时长' info: this.$t('load_test.schedule_tip')
} }
} }
return { return {

View File

@ -112,7 +112,7 @@
components: {MsTableOperatorButton}, components: {MsTableOperatorButton},
data() { data() {
return { return {
timeout: 100, timeout: 2000,
statusCode: [], statusCode: [],
domains: [], domains: [],
params: [], params: [],

View File

@ -103,7 +103,7 @@
} }
}, },
runTest() { runTest() {
this.result = this.$post(this.runPath, {id: this.test.id}, (response) => { this.result = this.$post(this.runPath, {id: this.test.id, triggerMode: 'MANUAL'}, (response) => {
this.$success(this.$t('load_test.is_running')); this.$success(this.$t('load_test.is_running'));
this.$emit('runTest', response.data); this.$emit('runTest', response.data);
}); });

View File

@ -102,6 +102,7 @@ export default {
login_username: 'ID or email', login_username: 'ID or email',
input_login_username: 'Please input the user ID or email', input_login_username: 'Please input the user ID or email',
input_name: 'Please enter name', input_name: 'Please enter name',
please_save: 'Please save first',
formatErr: 'Format Error', formatErr: 'Format Error',
id: 'ID', id: 'ID',
please_upload: 'Please upload file', please_upload: 'Please upload file',
@ -319,7 +320,8 @@ export default {
download_log_file: 'Download', download_log_file: 'Download',
user_name: 'Creator', user_name: 'Creator',
special_characters_are_not_supported: 'Test name does not support special characters', special_characters_are_not_supported: 'Test name does not support special characters',
pressure_config_params_is_empty: 'Pressure configuration parameters cannot be empty!' pressure_config_params_is_empty: 'Pressure configuration parameters cannot be empty!',
schedule_tip: 'The interval must not be less than the pressure measuring time'
}, },
api_test: { api_test: {
creator: "Creator", creator: "Creator",

View File

@ -104,6 +104,7 @@ export default {
input_name: '请输入名称', input_name: '请输入名称',
please_upload: '请上传文件', please_upload: '请上传文件',
formatErr: '格式错误', formatErr: '格式错误',
please_save: '请先保存',
id: 'ID', id: 'ID',
date: { date: {
select_date: '选择日期', select_date: '选择日期',
@ -318,7 +319,8 @@ export default {
pressure_prediction_chart: '压力预估图', pressure_prediction_chart: '压力预估图',
user_name: '创建人', user_name: '创建人',
special_characters_are_not_supported: '测试名称不支持特殊字符', special_characters_are_not_supported: '测试名称不支持特殊字符',
pressure_config_params_is_empty: '压力配置参数不能为空!' pressure_config_params_is_empty: '压力配置参数不能为空!',
schedule_tip: '间隔时间不能小于压测时长'
}, },
api_test: { api_test: {
creator: "创建人", creator: "创建人",

View File

@ -101,6 +101,7 @@ export default {
delete_confirm: '請輸入以下內容,確認刪除:', delete_confirm: '請輸入以下內容,確認刪除:',
input_name: '請輸入名稱', input_name: '請輸入名稱',
formatErr: '格式錯誤', formatErr: '格式錯誤',
please_save: '請先保存',
id: 'ID', id: 'ID',
please_upload: '請上傳文件', please_upload: '請上傳文件',
date: { date: {
@ -317,7 +318,8 @@ export default {
pressure_prediction_chart: '壓力預估圖', pressure_prediction_chart: '壓力預估圖',
user_name: '創建人', user_name: '創建人',
special_characters_are_not_supported: '測試名稱不支持特殊字符', special_characters_are_not_supported: '測試名稱不支持特殊字符',
pressure_config_params_is_empty: '壓力配置參數不能為空!' pressure_config_params_is_empty: '壓力配置參數不能為空!',
schedule_tip: '間隔時間不能小於壓測時長'
}, },
api_test: { api_test: {
creator: "創建人", creator: "創建人",