parent
e403e7bc6e
commit
f4d3e95170
|
@ -200,10 +200,10 @@
|
|||
|
||||
computed: {
|
||||
isShowRun() {
|
||||
return this.test.projectId && this.test.name && !this.change;
|
||||
return this.test.isValid() && !this.change;
|
||||
},
|
||||
isDisabled() {
|
||||
return !(this.test.projectId && this.test.name && this.change)
|
||||
return !(this.test.isValid() && this.change)
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -56,6 +56,13 @@
|
|||
},
|
||||
|
||||
data() {
|
||||
let validateURL = (rule, value, callback) => {
|
||||
try {
|
||||
new URL(this.addProtocol(this.request.url));
|
||||
} catch (e) {
|
||||
callback(this.$t('api_test.request.url_invalid'));
|
||||
}
|
||||
};
|
||||
return {
|
||||
activeName: "parameters",
|
||||
rules: {
|
||||
|
@ -63,7 +70,8 @@
|
|||
{max: 100, message: this.$t('commons.input_limit', [0, 100]), trigger: 'blur'}
|
||||
],
|
||||
url: [
|
||||
{max: 100, message: this.$t('commons.input_limit', [0, 100]), trigger: 'blur'}
|
||||
{max: 100, required: true, message: this.$t('commons.input_limit', [0, 100]), trigger: 'blur'},
|
||||
{validator: validateURL, trigger: 'blur'}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -74,16 +82,21 @@
|
|||
if (!this.request.url) return;
|
||||
|
||||
let parameters = [];
|
||||
let url = new URL(this.addProtocol(this.request.url));
|
||||
url.searchParams.forEach((value, key) => {
|
||||
if (key && value) {
|
||||
parameters.push(new KeyValue(key, value));
|
||||
}
|
||||
});
|
||||
// 添加一个空的,用于填写
|
||||
parameters.push(new KeyValue());
|
||||
this.request.parameters = parameters;
|
||||
this.request.url = url.toString();
|
||||
try {
|
||||
let url = new URL(this.addProtocol(this.request.url));
|
||||
url.searchParams.forEach((value, key) => {
|
||||
if (key && value) {
|
||||
parameters.push(new KeyValue(key, value));
|
||||
}
|
||||
});
|
||||
// 添加一个空的,用于填写
|
||||
parameters.push(new KeyValue());
|
||||
this.request.parameters = parameters;
|
||||
this.request.url = url.toString();
|
||||
} catch (e) {
|
||||
this.$error(this.$t('api_test.request.url_invalid'), 2000)
|
||||
}
|
||||
|
||||
},
|
||||
methodChange(value) {
|
||||
if (value === 'GET' && this.activeName === 'body') {
|
||||
|
|
|
@ -110,6 +110,15 @@ export class Test extends BaseConfig {
|
|||
return options;
|
||||
}
|
||||
|
||||
isValid() {
|
||||
for (let i = 0; i < this.scenarioDefinition.length; i++) {
|
||||
if (this.scenarioDefinition[i].isValid()) {
|
||||
return this.projectId && this.name;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
toJMX() {
|
||||
return {
|
||||
name: this.name + '.jmx',
|
||||
|
@ -140,6 +149,15 @@ export class Scenario extends BaseConfig {
|
|||
clone() {
|
||||
return new Scenario(this);
|
||||
}
|
||||
|
||||
isValid() {
|
||||
for (let i = 0; i < this.requests.length; i++) {
|
||||
if (this.requests[i].isValid()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export class Request extends BaseConfig {
|
||||
|
|
|
@ -34,12 +34,12 @@ export default {
|
|||
})
|
||||
};
|
||||
|
||||
Vue.prototype.$error = function (message) {
|
||||
Vue.prototype.$error = function (message, duration) {
|
||||
Message.error({
|
||||
message: message,
|
||||
type: "error",
|
||||
showClose: true,
|
||||
duration: 10000
|
||||
duration: duration || 10000
|
||||
})
|
||||
};
|
||||
|
||||
|
|
|
@ -276,6 +276,7 @@ export default {
|
|||
name: "Scenario Name",
|
||||
base_url: "Base URL",
|
||||
base_url_description: "Base URL as URL prefix for all requests",
|
||||
url_invalid: "Invalid URL",
|
||||
variables: "Variables",
|
||||
headers: "Headers",
|
||||
kv_description: "Variables are available for all requests",
|
||||
|
|
|
@ -287,6 +287,7 @@ export default {
|
|||
method: "请求方法",
|
||||
url: "请求URL",
|
||||
url_description: "例如: https://fit2cloud.com",
|
||||
url_invalid: "URL无效",
|
||||
parameters: "请求参数",
|
||||
parameters_desc: "参数追加到URL,例如https://fit2cloud.com/entries?key1=Value1&Key2=Value2",
|
||||
headers: "请求头",
|
||||
|
|
|
@ -289,6 +289,7 @@ export default {
|
|||
method: "請求方法",
|
||||
url: "請求URL",
|
||||
url_description: "例如:https://fit2cloud.com",
|
||||
url_invalid: "URL無效",
|
||||
parameters: "請求參數",
|
||||
parameters_desc: "參數追加到URL,例如https://fit2cloud.com/entries?key1=Value1&Key2=Value2",
|
||||
headers: "請求頭",
|
||||
|
|
Loading…
Reference in New Issue