Merge branch 'dev' of https://github.com/metersphere/server into dev
This commit is contained in:
commit
c7f0d842ef
|
@ -200,10 +200,10 @@
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
isShowRun() {
|
isShowRun() {
|
||||||
return this.test.projectId && this.test.name && !this.change;
|
return this.test.isValid() && !this.change;
|
||||||
},
|
},
|
||||||
isDisabled() {
|
isDisabled() {
|
||||||
return !(this.test.projectId && this.test.name && this.change)
|
return !(this.test.isValid() && this.change)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,13 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
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 {
|
return {
|
||||||
activeName: "parameters",
|
activeName: "parameters",
|
||||||
rules: {
|
rules: {
|
||||||
|
@ -63,7 +70,8 @@
|
||||||
{max: 100, message: this.$t('commons.input_limit', [0, 100]), trigger: 'blur'}
|
{max: 100, message: this.$t('commons.input_limit', [0, 100]), trigger: 'blur'}
|
||||||
],
|
],
|
||||||
url: [
|
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;
|
if (!this.request.url) return;
|
||||||
|
|
||||||
let parameters = [];
|
let parameters = [];
|
||||||
let url = new URL(this.addProtocol(this.request.url));
|
try {
|
||||||
url.searchParams.forEach((value, key) => {
|
let url = new URL(this.addProtocol(this.request.url));
|
||||||
if (key && value) {
|
url.searchParams.forEach((value, key) => {
|
||||||
parameters.push(new KeyValue(key, value));
|
if (key && value) {
|
||||||
}
|
parameters.push(new KeyValue(key, value));
|
||||||
});
|
}
|
||||||
// 添加一个空的,用于填写
|
});
|
||||||
parameters.push(new KeyValue());
|
// 添加一个空的,用于填写
|
||||||
this.request.parameters = parameters;
|
parameters.push(new KeyValue());
|
||||||
this.request.url = url.toString();
|
this.request.parameters = parameters;
|
||||||
|
this.request.url = url.toString();
|
||||||
|
} catch (e) {
|
||||||
|
this.$error(this.$t('api_test.request.url_invalid'), 2000)
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
methodChange(value) {
|
methodChange(value) {
|
||||||
if (value === 'GET' && this.activeName === 'body') {
|
if (value === 'GET' && this.activeName === 'body') {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div>
|
<div>
|
||||||
<el-row :gutter="10" type="flex" justify="space-between" align="middle">
|
<el-row :gutter="10" type="flex" justify="space-between" align="middle">
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-input v-model="time" step="100" size="small" type="number"
|
<el-input :value="value" v-bind="$attrs" step="100" size="small" type="number" @change="change" @input="input"
|
||||||
:placeholder="$t('api_test.request.assertions.response_in_time')"/>
|
:placeholder="$t('api_test.request.assertions.response_in_time')"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col class="assertion-btn">
|
<el-col class="assertion-btn">
|
||||||
|
@ -14,32 +14,32 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import {ResponseTime} from "../../model/ScenarioModel";
|
import {ResponseTime} from "../../model/ScenarioModel";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsApiAssertionResponseTime",
|
name: "MsApiAssertionResponseTime",
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
edit: Boolean,
|
|
||||||
duration: ResponseTime,
|
duration: ResponseTime,
|
||||||
|
value: [Number, String],
|
||||||
|
edit: Boolean,
|
||||||
callback: Function
|
callback: Function
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
time: this.duration.value
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
add: function () {
|
add() {
|
||||||
setTimeout(() => {
|
this.duration.value = this.value;
|
||||||
this.duration.value = this.time;
|
this.callback();
|
||||||
this.callback();
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
remove: function () {
|
remove() {
|
||||||
this.duration.value = undefined;
|
this.duration.value = undefined;
|
||||||
|
},
|
||||||
|
change(value) {
|
||||||
|
this.$emit('change', value);
|
||||||
|
},
|
||||||
|
input(value) {
|
||||||
|
this.$emit('input', value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
<el-col :span="20">
|
<el-col :span="20">
|
||||||
<ms-api-assertion-text :list="assertions.regex" v-if="type === options.TEXT" :callback="after"/>
|
<ms-api-assertion-text :list="assertions.regex" v-if="type === options.TEXT" :callback="after"/>
|
||||||
<ms-api-assertion-regex :list="assertions.regex" v-if="type === options.REGEX" :callback="after"/>
|
<ms-api-assertion-regex :list="assertions.regex" v-if="type === options.REGEX" :callback="after"/>
|
||||||
<ms-api-assertion-response-time :duration="assertions.duration" v-if="type === options.RESPONSE_TIME"
|
<ms-api-assertion-response-time v-model="time" :duration="assertions.duration"
|
||||||
:callback="after"/>
|
v-if="type === options.RESPONSE_TIME" :callback="after"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
import MsApiAssertionText from "./ApiAssertionText";
|
import MsApiAssertionText from "./ApiAssertionText";
|
||||||
import MsApiAssertionRegex from "./ApiAssertionRegex";
|
import MsApiAssertionRegex from "./ApiAssertionRegex";
|
||||||
import MsApiAssertionResponseTime from "./ApiAssertionResponseTime";
|
import MsApiAssertionResponseTime from "./ApiAssertionResponseTime";
|
||||||
import {ASSERTION_TYPE, Assertions} from "../../model/ScenarioModel";
|
import {ASSERTION_TYPE, Assertions, ResponseTime} from "../../model/ScenarioModel";
|
||||||
import MsApiAssertionsEdit from "./ApiAssertionsEdit";
|
import MsApiAssertionsEdit from "./ApiAssertionsEdit";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -40,6 +40,7 @@
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
options: ASSERTION_TYPE,
|
options: ASSERTION_TYPE,
|
||||||
|
time: "",
|
||||||
type: "",
|
type: "",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<div>
|
<div>
|
||||||
{{$t("api_test.request.assertions.response_time")}}
|
{{$t("api_test.request.assertions.response_time")}}
|
||||||
</div>
|
</div>
|
||||||
<ms-api-assertion-response-time :duration="assertions.duration" :edit="true"/>
|
<ms-api-assertion-response-time v-model="assertions.duration.value" :duration="assertions.duration" :edit="true"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,15 @@ export class Test extends BaseConfig {
|
||||||
return options;
|
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() {
|
toJMX() {
|
||||||
return {
|
return {
|
||||||
name: this.name + '.jmx',
|
name: this.name + '.jmx',
|
||||||
|
@ -136,6 +145,19 @@ export class Scenario extends BaseConfig {
|
||||||
options.requests = options.requests || [new Request()];
|
options.requests = options.requests || [new Request()];
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
export class Request extends BaseConfig {
|
||||||
|
@ -394,7 +416,8 @@ class JMXGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
addScenarios(testPlan, scenarios) {
|
addScenarios(testPlan, scenarios) {
|
||||||
scenarios.forEach(scenario => {
|
scenarios.forEach(s => {
|
||||||
|
let scenario = s.clone();
|
||||||
scenario.name = this.replace(scenario.name);
|
scenario.name = this.replace(scenario.name);
|
||||||
|
|
||||||
let threadGroup = new ThreadGroup(scenario.name || "");
|
let threadGroup = new ThreadGroup(scenario.name || "");
|
||||||
|
|
|
@ -178,6 +178,7 @@
|
||||||
this.status = data.status;
|
this.status = data.status;
|
||||||
this.reportName = data.name;
|
this.reportName = data.name;
|
||||||
this.testName = data.testName;
|
this.testName = data.testName;
|
||||||
|
this.testId = data.testId;
|
||||||
this.projectName = data.projectName;
|
this.projectName = data.projectName;
|
||||||
|
|
||||||
this.$set(this.report, "id", reportId);
|
this.$set(this.report, "id", reportId);
|
||||||
|
|
|
@ -34,12 +34,12 @@ export default {
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
Vue.prototype.$error = function (message) {
|
Vue.prototype.$error = function (message, duration) {
|
||||||
Message.error({
|
Message.error({
|
||||||
message: message,
|
message: message,
|
||||||
type: "error",
|
type: "error",
|
||||||
showClose: true,
|
showClose: true,
|
||||||
duration: 10000
|
duration: duration || 10000
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -276,6 +276,7 @@ export default {
|
||||||
name: "Scenario Name",
|
name: "Scenario Name",
|
||||||
base_url: "Base URL",
|
base_url: "Base URL",
|
||||||
base_url_description: "Base URL as URL prefix for all requests",
|
base_url_description: "Base URL as URL prefix for all requests",
|
||||||
|
url_invalid: "Invalid URL",
|
||||||
variables: "Variables",
|
variables: "Variables",
|
||||||
headers: "Headers",
|
headers: "Headers",
|
||||||
kv_description: "Variables are available for all requests",
|
kv_description: "Variables are available for all requests",
|
||||||
|
|
|
@ -287,6 +287,7 @@ export default {
|
||||||
method: "请求方法",
|
method: "请求方法",
|
||||||
url: "请求URL",
|
url: "请求URL",
|
||||||
url_description: "例如: https://fit2cloud.com",
|
url_description: "例如: https://fit2cloud.com",
|
||||||
|
url_invalid: "URL无效",
|
||||||
parameters: "请求参数",
|
parameters: "请求参数",
|
||||||
parameters_desc: "参数追加到URL,例如https://fit2cloud.com/entries?key1=Value1&Key2=Value2",
|
parameters_desc: "参数追加到URL,例如https://fit2cloud.com/entries?key1=Value1&Key2=Value2",
|
||||||
headers: "请求头",
|
headers: "请求头",
|
||||||
|
|
|
@ -289,6 +289,7 @@ export default {
|
||||||
method: "請求方法",
|
method: "請求方法",
|
||||||
url: "請求URL",
|
url: "請求URL",
|
||||||
url_description: "例如:https://fit2cloud.com",
|
url_description: "例如:https://fit2cloud.com",
|
||||||
|
url_invalid: "URL無效",
|
||||||
parameters: "請求參數",
|
parameters: "請求參數",
|
||||||
parameters_desc: "參數追加到URL,例如https://fit2cloud.com/entries?key1=Value1&Key2=Value2",
|
parameters_desc: "參數追加到URL,例如https://fit2cloud.com/entries?key1=Value1&Key2=Value2",
|
||||||
headers: "請求頭",
|
headers: "請求頭",
|
||||||
|
|
Loading…
Reference in New Issue