Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
b9522607ef
|
@ -158,7 +158,8 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
if (!path.startsWith("/")) {
|
if (!path.startsWith("/")) {
|
||||||
path = "/" + path;
|
path = "/" + path;
|
||||||
}
|
}
|
||||||
path = sampler.getProtocol() + "://" + sampler.getDomain() + ":" + sampler.getPort() + path;
|
String port = sampler.getPort() != 80 ? ":" + sampler.getPort() : "";
|
||||||
|
path = sampler.getProtocol() + "://" + sampler.getDomain() + port + path;
|
||||||
}
|
}
|
||||||
sampler.setPath(path);
|
sampler.setPath(path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit a641c1331e1813b5294a1d0e380b8682a78754e1
|
Subproject commit 26d36f3f81e889f58eed7c6903252a129b301d98
|
|
@ -237,8 +237,18 @@
|
||||||
this.$refs.apiScenarioList.search(data);
|
this.$refs.apiScenarioList.search(data);
|
||||||
},
|
},
|
||||||
refresh(data) {
|
refresh(data) {
|
||||||
|
this.setTabTitle(data);
|
||||||
this.$refs.apiScenarioList.search(data);
|
this.$refs.apiScenarioList.search(data);
|
||||||
},
|
},
|
||||||
|
setTabTitle(data) {
|
||||||
|
for (let index in this.tabs) {
|
||||||
|
let tab = this.tabs[index];
|
||||||
|
if (tab.name === this.activeName) {
|
||||||
|
tab.label = data.name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
editScenario(row) {
|
editScenario(row) {
|
||||||
this.addTab({name: 'edit', currentScenario: row});
|
this.addTab({name: 'edit', currentScenario: row});
|
||||||
},
|
},
|
||||||
|
|
|
@ -848,7 +848,7 @@
|
||||||
if (this.currentScenario.tags instanceof String) {
|
if (this.currentScenario.tags instanceof String) {
|
||||||
this.currentScenario.tags = JSON.parse(this.currentScenario.tags);
|
this.currentScenario.tags = JSON.parse(this.currentScenario.tags);
|
||||||
}
|
}
|
||||||
this.$emit('refresh');
|
this.$emit('refresh',this.currentScenario);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
</div>
|
</div>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-dialog :title="$t('api_test.request.assertions.script')" :visible.sync="visible" width="900px">
|
<el-dialog :title="$t('api_test.request.assertions.script')" :visible.sync="visible" width="900px" append-to-body>
|
||||||
<el-row type="flex" justify="space-between" align="middle" class="quick-script-block">
|
<el-row type="flex" justify="space-between" align="middle" class="quick-script-block">
|
||||||
<div class="assertion-item input">
|
<div class="assertion-item input">
|
||||||
<el-input size="small" v-model="assertion.variable"
|
<el-input size="small" v-model="assertion.variable"
|
||||||
|
@ -55,206 +55,206 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {AssertionJSR223} from "../../model/ApiTestModel";
|
import {AssertionJSR223} from "../../model/ApiTestModel";
|
||||||
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
|
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
|
||||||
import MsJsr233Processor from "../../../automation/scenario/component/Jsr233Processor";
|
import MsJsr233Processor from "../../../automation/scenario/common/Jsr233ProcessorContent";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsApiAssertionJsr223",
|
name: "MsApiAssertionJsr223",
|
||||||
components: {MsJsr233Processor, MsDialogFooter},
|
components: {MsJsr233Processor, MsDialogFooter},
|
||||||
props: {
|
props: {
|
||||||
assertion: {
|
assertion: {
|
||||||
default: () => {
|
default: () => {
|
||||||
return new AssertionJSR223();
|
return new AssertionJSR223();
|
||||||
}
|
|
||||||
},
|
|
||||||
edit: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
index: Number,
|
|
||||||
list: Array,
|
|
||||||
callback: Function,
|
|
||||||
isReadOnly: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
visible: false,
|
|
||||||
operators: {
|
|
||||||
EQ: {
|
|
||||||
label: "commons.adv_search.operators.equals",
|
|
||||||
value: "=="
|
|
||||||
},
|
|
||||||
NE: {
|
|
||||||
label: "commons.adv_search.operators.not_equals",
|
|
||||||
value: "!="
|
|
||||||
},
|
|
||||||
CONTAINS: {
|
|
||||||
label: "commons.adv_search.operators.like",
|
|
||||||
value: "contains"
|
|
||||||
},
|
|
||||||
NOT_CONTAINS: {
|
|
||||||
label: "commons.adv_search.operators.not_like",
|
|
||||||
value: "not contains"
|
|
||||||
},
|
|
||||||
GT: {
|
|
||||||
label: "commons.adv_search.operators.gt",
|
|
||||||
value: ">"
|
|
||||||
},
|
|
||||||
LT: {
|
|
||||||
label: "commons.adv_search.operators.lt",
|
|
||||||
value: "<"
|
|
||||||
},
|
|
||||||
IS_EMPTY: {
|
|
||||||
label: "commons.adv_search.operators.is_empty",
|
|
||||||
value: "is empty"
|
|
||||||
},
|
|
||||||
IS_NOT_EMPTY: {
|
|
||||||
label: "commons.adv_search.operators.is_not_empty",
|
|
||||||
value: "is not empty"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
templates: [
|
edit: {
|
||||||
{
|
type: Boolean,
|
||||||
title: this.$t('api_test.request.assertions.set_failure_status'),
|
default: false
|
||||||
value: 'AssertionResult.setFailure(true)',
|
},
|
||||||
|
index: Number,
|
||||||
|
list: Array,
|
||||||
|
callback: Function,
|
||||||
|
isReadOnly: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
visible: false,
|
||||||
|
operators: {
|
||||||
|
EQ: {
|
||||||
|
label: "commons.adv_search.operators.equals",
|
||||||
|
value: "=="
|
||||||
|
},
|
||||||
|
NE: {
|
||||||
|
label: "commons.adv_search.operators.not_equals",
|
||||||
|
value: "!="
|
||||||
|
},
|
||||||
|
CONTAINS: {
|
||||||
|
label: "commons.adv_search.operators.like",
|
||||||
|
value: "contains"
|
||||||
|
},
|
||||||
|
NOT_CONTAINS: {
|
||||||
|
label: "commons.adv_search.operators.not_like",
|
||||||
|
value: "not contains"
|
||||||
|
},
|
||||||
|
GT: {
|
||||||
|
label: "commons.adv_search.operators.gt",
|
||||||
|
value: ">"
|
||||||
|
},
|
||||||
|
LT: {
|
||||||
|
label: "commons.adv_search.operators.lt",
|
||||||
|
value: "<"
|
||||||
|
},
|
||||||
|
IS_EMPTY: {
|
||||||
|
label: "commons.adv_search.operators.is_empty",
|
||||||
|
value: "is empty"
|
||||||
|
},
|
||||||
|
IS_NOT_EMPTY: {
|
||||||
|
label: "commons.adv_search.operators.is_not_empty",
|
||||||
|
value: "is not empty"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
templates: [
|
||||||
title: this.$t('api_test.request.assertions.set_failure_msg'),
|
{
|
||||||
value: 'AssertionResult.setFailureMessage("msg")',
|
title: this.$t('api_test.request.assertions.set_failure_status'),
|
||||||
|
value: 'AssertionResult.setFailure(true)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: this.$t('api_test.request.assertions.set_failure_msg'),
|
||||||
|
value: 'AssertionResult.setFailureMessage("msg")',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
add() {
|
||||||
|
this.list.push(new AssertionJSR223(this.assertion));
|
||||||
|
this.callback();
|
||||||
|
},
|
||||||
|
remove() {
|
||||||
|
this.list.splice(this.index, 1);
|
||||||
|
},
|
||||||
|
changeOperator(value) {
|
||||||
|
if (value.indexOf("empty") > 0 && !!this.assertion.value) {
|
||||||
|
this.assertion.value = "";
|
||||||
}
|
}
|
||||||
],
|
this.quickScript();
|
||||||
}
|
},
|
||||||
},
|
quickScript() {
|
||||||
|
if (this.assertion.variable && this.assertion.operator) {
|
||||||
|
let variable = this.assertion.variable;
|
||||||
|
let operator = this.assertion.operator;
|
||||||
|
let value = this.assertion.value || "";
|
||||||
|
let desc = "${" + variable + "} " + operator + " '" + value + "'";
|
||||||
|
let script = "value = vars.get(\"" + variable + "\");\n"
|
||||||
|
switch (this.assertion.operator) {
|
||||||
|
case "==":
|
||||||
|
script += "result = \"" + value + "\".equals(value);\n";
|
||||||
|
break;
|
||||||
|
case "!=":
|
||||||
|
script += "result = !\"" + value + "\".equals(value);\n";
|
||||||
|
break;
|
||||||
|
case "contains":
|
||||||
|
script += "result = value.contains(\"" + value + "\");\n";
|
||||||
|
break;
|
||||||
|
case "not contains":
|
||||||
|
script += "result = !value.contains(\"" + value + "\");\n";
|
||||||
|
break;
|
||||||
|
case ">":
|
||||||
|
desc = "${" + variable + "} " + operator + " " + value;
|
||||||
|
script += "number = Integer.parseInt(value);\n" +
|
||||||
|
"result = number > " + value + ";\n";
|
||||||
|
break;
|
||||||
|
case "<":
|
||||||
|
desc = "${" + variable + "} " + operator + " " + value;
|
||||||
|
script += "number = Integer.parseInt(value);\n" +
|
||||||
|
"result = number < " + value + ";\n";
|
||||||
|
break;
|
||||||
|
case "is empty":
|
||||||
|
desc = "${" + variable + "} " + operator
|
||||||
|
script += "result = value == void || value.length() == 0;\n";
|
||||||
|
break;
|
||||||
|
case "is not empty":
|
||||||
|
desc = "${" + variable + "} " + operator
|
||||||
|
script += "result = value != void && value.length() > 0;\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
let msg = "assertion [" + desc + "]: false;"
|
||||||
|
script += "if (!result){\n" +
|
||||||
|
"\tmsg = \"" + msg + "\";\n" +
|
||||||
|
"\tAssertionResult.setFailureMessage(msg);\n" +
|
||||||
|
"\tAssertionResult.setFailure(true);\n" +
|
||||||
|
"}";
|
||||||
|
|
||||||
methods: {
|
this.assertion.desc = desc;
|
||||||
add() {
|
this.assertion.script = script;
|
||||||
this.list.push(new AssertionJSR223(this.assertion));
|
this.$refs.jsr233.reload();
|
||||||
this.callback();
|
|
||||||
},
|
|
||||||
remove() {
|
|
||||||
this.list.splice(this.index, 1);
|
|
||||||
},
|
|
||||||
changeOperator(value) {
|
|
||||||
if (value.indexOf("empty") > 0 && !!this.assertion.value) {
|
|
||||||
this.assertion.value = "";
|
|
||||||
}
|
|
||||||
this.quickScript();
|
|
||||||
},
|
|
||||||
quickScript() {
|
|
||||||
if (this.assertion.variable && this.assertion.operator) {
|
|
||||||
let variable = this.assertion.variable;
|
|
||||||
let operator = this.assertion.operator;
|
|
||||||
let value = this.assertion.value || "";
|
|
||||||
let desc = "${" + variable + "} " + operator + " '" + value + "'";
|
|
||||||
let script = "value = vars.get(\"" + variable + "\");\n"
|
|
||||||
switch (this.assertion.operator) {
|
|
||||||
case "==":
|
|
||||||
script += "result = \"" + value + "\".equals(value);\n";
|
|
||||||
break;
|
|
||||||
case "!=":
|
|
||||||
script += "result = !\"" + value + "\".equals(value);\n";
|
|
||||||
break;
|
|
||||||
case "contains":
|
|
||||||
script += "result = value.contains(\"" + value + "\");\n";
|
|
||||||
break;
|
|
||||||
case "not contains":
|
|
||||||
script += "result = !value.contains(\"" + value + "\");\n";
|
|
||||||
break;
|
|
||||||
case ">":
|
|
||||||
desc = "${" + variable + "} " + operator + " " + value;
|
|
||||||
script += "number = Integer.parseInt(value);\n" +
|
|
||||||
"result = number > " + value + ";\n";
|
|
||||||
break;
|
|
||||||
case "<":
|
|
||||||
desc = "${" + variable + "} " + operator + " " + value;
|
|
||||||
script += "number = Integer.parseInt(value);\n" +
|
|
||||||
"result = number < " + value + ";\n";
|
|
||||||
break;
|
|
||||||
case "is empty":
|
|
||||||
desc = "${" + variable + "} " + operator
|
|
||||||
script += "result = value == void || value.length() == 0;\n";
|
|
||||||
break;
|
|
||||||
case "is not empty":
|
|
||||||
desc = "${" + variable + "} " + operator
|
|
||||||
script += "result = value != void && value.length() > 0;\n";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
let msg = "assertion [" + desc + "]: false;"
|
|
||||||
script += "if (!result){\n" +
|
|
||||||
"\tmsg = \"" + msg + "\";\n" +
|
|
||||||
"\tAssertionResult.setFailureMessage(msg);\n" +
|
|
||||||
"\tAssertionResult.setFailure(true);\n" +
|
|
||||||
"}";
|
|
||||||
|
|
||||||
this.assertion.desc = desc;
|
},
|
||||||
this.assertion.script = script;
|
detail() {
|
||||||
this.$refs.jsr233.reload();
|
this.visible = true;
|
||||||
|
},
|
||||||
|
close() {
|
||||||
|
this.visible = false;
|
||||||
|
},
|
||||||
|
confirm() {
|
||||||
|
if (!this.edit) {
|
||||||
|
this.add();
|
||||||
|
}
|
||||||
|
if (!this.assertion.desc) {
|
||||||
|
this.assertion.desc = this.assertion.script;
|
||||||
|
}
|
||||||
|
this.close();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
},
|
computed: {
|
||||||
detail() {
|
hasEmptyOperator() {
|
||||||
this.visible = true;
|
return !!this.assertion.operator && this.assertion.operator.indexOf("empty") > 0;
|
||||||
},
|
|
||||||
close() {
|
|
||||||
this.visible = false;
|
|
||||||
},
|
|
||||||
confirm() {
|
|
||||||
if (!this.edit) {
|
|
||||||
this.add();
|
|
||||||
}
|
}
|
||||||
if (!this.assertion.desc) {
|
|
||||||
this.assertion.desc = this.assertion.script;
|
|
||||||
}
|
|
||||||
this.close();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
|
||||||
hasEmptyOperator() {
|
|
||||||
return !!this.assertion.operator && this.assertion.operator.indexOf("empty") > 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.assertion-item {
|
.assertion-item {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.assertion-item + .assertion-item {
|
.assertion-item + .assertion-item {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.assertion-item.input {
|
.assertion-item.input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.assertion-item.select {
|
.assertion-item.select {
|
||||||
min-width: 150px;
|
min-width: 150px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.assertion-item.label {
|
.assertion-item.label {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.assertion-item.btn {
|
.assertion-item.btn {
|
||||||
min-width: 130px;
|
min-width: 130px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.assertion-item.btn.circle {
|
.assertion-item.btn.circle {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
min-width: 80px;
|
min-width: 80px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quick-script-block {
|
.quick-script-block {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -213,7 +213,7 @@
|
||||||
},
|
},
|
||||||
copyCase(data) {
|
copyCase(data) {
|
||||||
let uuid = getUUID();
|
let uuid = getUUID();
|
||||||
let obj = {name: "copy_" + data.name, priority: data.priority, active: true, request: data.request, uuid: uuid};
|
let obj = {name: "copy_" + data.name, priority: data.priority, active: true, tags: data.tags, request: data.request, uuid: uuid};
|
||||||
this.$emit('copyCase', obj);
|
this.$emit('copyCase', obj);
|
||||||
},
|
},
|
||||||
selectTestCase(item, $event) {
|
selectTestCase(item, $event) {
|
||||||
|
|
|
@ -180,10 +180,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//创建根目录的模块---供父类使用
|
//创建根目录的模块---供父类使用
|
||||||
createRootModel(){
|
createRootModel() {
|
||||||
let dataArr = this.$refs.nodeTree.extendTreeNodes;
|
let dataArr = this.$refs.nodeTree.extendTreeNodes;
|
||||||
if(dataArr.length>0){
|
if (dataArr.length > 0) {
|
||||||
this.$refs.nodeTree.append({},dataArr[0]);
|
this.$refs.nodeTree.append({}, dataArr[0]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
exportAPI() {
|
exportAPI() {
|
||||||
|
@ -197,7 +197,6 @@
|
||||||
},
|
},
|
||||||
refresh() {
|
refresh() {
|
||||||
this.list();
|
this.list();
|
||||||
this.$emit("refreshTable");
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue