fix(接口自动化): 场景变量国际化修改

This commit is contained in:
fit2-zhao 2021-04-01 15:57:44 +08:00 committed by fit2-zhao
parent 5750f3061f
commit 91ae9480b8
6 changed files with 33 additions and 27 deletions

View File

@ -351,16 +351,13 @@ public class MsHTTPSamplerProxy extends MsTestElement {
public boolean isURL(String str) { public boolean isURL(String str) {
try { try {
String regex = "^((https|http|ftp|rtsp|mms)?://)" new URL(str);
+ "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" return true;
+ "(([0-9]{1,3}\\.){3}[0-9]{1,3}" + "|" + "([0-9a-z_!~*'()-]+\\.)*"
+ "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\\."
+ "[a-z]{2,6})"
+ "(:[0-9]{1,5})?"
+ "((/?)|"
+ "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
return str.matches(regex) || (str.matches("^(http|https|ftp)://.*$") && str.matches(".*://\\$\\{.*$"));
} catch (Exception e) { } catch (Exception e) {
// 支持包含变量的url
if (str.matches("^(http|https|ftp)://.*$") && str.matches(".*://\\$\\{.*$")) {
return true;
}
return false; return false;
} }
} }

View File

@ -247,7 +247,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
} }
} }
if (StringUtils.equals(ReportTriggerMode.API.name(), report.getTriggerMode())||StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), report.getTriggerMode())) { if (report != null && StringUtils.equals(ReportTriggerMode.API.name(), report.getTriggerMode())||StringUtils.equals(ReportTriggerMode.SCHEDULE.name(), report.getTriggerMode())) {
sendTask(report, reportUrl, testResult); sendTask(report, reportUrl, testResult);
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<el-dialog title="场景变量" :close-on-click-modal="false" <el-dialog :title="$t('api_test.automation.step_total')" :close-on-click-modal="false"
:visible.sync="visible" class="visible-dialog" width="60%" :visible.sync="visible" class="visible-dialog" width="60%"
@close="close" v-loading="loading" append-to-body> @close="close" v-loading="loading" append-to-body>
<fieldset :disabled="disabled" class="ms-fieldset"> <fieldset :disabled="disabled" class="ms-fieldset">
@ -10,14 +10,14 @@
<div> <div>
<el-row style="margin-bottom: 10px"> <el-row style="margin-bottom: 10px">
<div style="float: left"> <div style="float: left">
<el-input placeholder="变量名称搜索" v-model="selectVariable" size="small" @change="filter" <el-input :placeholder="$t('commons.search_by_name')" v-model="selectVariable" size="small" @change="filter"
@keyup.enter="filter"> @keyup.enter="filter">
<el-select v-model="searchType" slot="prepend" placeholder="类型" style="width: 90px" @change="filter"> <el-select v-model="searchType" slot="prepend" :placeholder="$t('test_resource_pool.type')" style="width: 90px" @change="filter">
<el-option value="CONSTANT" label="常量"></el-option> <el-option value="CONSTANT" :label="$t('api_test.automation.constant')"></el-option>
<el-option value="LIST" label="列表"></el-option> <el-option value="LIST" :label="$t('test_track.case.list')"></el-option>
<el-option value="CSV" label="CSV"></el-option> <el-option value="CSV" label="CSV"></el-option>
<el-option value="COUNTER" label="计数器"></el-option> <el-option value="COUNTER" :label="$t('api_test.automation.counter')"></el-option>
<el-option value="RANDOM" label="随机数"></el-option> <el-option value="RANDOM" :label="$t('api_test.automation.random')"></el-option>
</el-select> </el-select>
</el-input> </el-input>
</div> </div>
@ -27,11 +27,11 @@
size="small" style="margin-left: 10px"> size="small" style="margin-left: 10px">
{{ $t('commons.add') }} {{ $t('commons.add') }}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="CONSTANT">常量</el-dropdown-item> <el-dropdown-item command="CONSTANT">{{$t('api_test.automation.constant')}}</el-dropdown-item>
<el-dropdown-item command="LIST">列表</el-dropdown-item> <el-dropdown-item command="LIST">{{$t('test_track.case.list')}}</el-dropdown-item>
<el-dropdown-item command="CSV">CSV</el-dropdown-item> <el-dropdown-item command="CSV">CSV</el-dropdown-item>
<el-dropdown-item command="COUNTER">计数器</el-dropdown-item> <el-dropdown-item command="COUNTER">{{$t('api_test.automation.counter')}}</el-dropdown-item>
<el-dropdown-item command="RANDOM">随机数</el-dropdown-item> <el-dropdown-item command="RANDOM">{{$t('api_test.automation.random')}}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
<el-button size="small" style="margin-left: 10px" @click="deleteVariable">{{ $t('commons.delete') }} <el-button size="small" style="margin-left: 10px" @click="deleteVariable">{{ $t('commons.delete') }}
@ -137,11 +137,11 @@
selectVariable: "", selectVariable: "",
condition: {}, condition: {},
types: new Map([ types: new Map([
['CONSTANT', '常量'], ['CONSTANT', this.$t('api_test.automation.constant')],
['LIST', '列表'], ['LIST', this.$t('test_track.case.list')],
['CSV', 'CSV'], ['CSV', 'CSV'],
['COUNTER', '计数器'], ['COUNTER', this.$t('api_test.automation.counter')],
['RANDOM', '随机数'] ['RANDOM', this.$t('api_test.automation.random')]
]), ]),
visible: false, visible: false,
selection: [], selection: [],
@ -187,7 +187,7 @@
} }
}, },
handleClick(command) { handleClick(command) {
this.editData = {}; this.editData = {delimiter: ","};
this.editData.type = command; this.editData.type = command;
this.addParameters(this.editData); this.addParameters(this.editData);
}, },
@ -226,7 +226,7 @@
this.headers = headers; this.headers = headers;
} }
this.visible = true; this.visible = true;
this.editData = {type: "CONSTANT", delimiter: ","}; this.editData = {type: "CONSTANT"};
this.addParameters(this.editData); this.addParameters(this.editData);
this.disabled = disabled; this.disabled = disabled;
}, },

View File

@ -705,6 +705,9 @@ export default {
} }
}, },
automation: { automation: {
constant: "constant",
counter: "counter",
random: "random",
view_scene_variables: "View scene variables", view_scene_variables: "View scene variables",
open_scene: "Open scene", open_scene: "Open scene",
save_as_api: "Save as api", save_as_api: "Save as api",

View File

@ -706,6 +706,9 @@ export default {
} }
}, },
automation: { automation: {
constant: "常量",
counter: "计数器",
random: "随机数",
view_scene_variables: "查看场景变量", view_scene_variables: "查看场景变量",
open_scene: "打开场景", open_scene: "打开场景",
save_as_api: "另存为接口定义", save_as_api: "另存为接口定义",

View File

@ -705,6 +705,9 @@ export default {
} }
}, },
automation: { automation: {
constant: "常量",
counter: "計數器",
random: "随机器",
view_scene_variables: "查看場景變量", view_scene_variables: "查看場景變量",
open_scene: "打開場景", open_scene: "打開場景",
save_as_api: "另存為接口定義", save_as_api: "另存為接口定義",