feat(接口定义): 断言处理
This commit is contained in:
parent
e008baaf2e
commit
ac0d65ee1e
|
@ -2,12 +2,14 @@
|
|||
<div>
|
||||
<el-row :gutter="10" type="flex" justify="space-between" align="middle">
|
||||
<el-col>
|
||||
<el-input :disabled="isReadOnly" :value="value" v-bind="$attrs" step="100" size="small" type="number" @change="change" @input="input"
|
||||
<el-input :disabled="isReadOnly" :value="value" v-bind="$attrs" step="100" size="small" type="number" @change="change" @input="input" :min="0"
|
||||
:placeholder="$t('api_test.request.assertions.response_in_time')"/>
|
||||
</el-col>
|
||||
<el-col class="assertion-btn">
|
||||
<el-button :disabled="isReadOnly" type="danger" size="mini" icon="el-icon-delete" circle @click="remove" v-if="edit"/>
|
||||
<el-button :disabled="isReadOnly" type="primary" size="small" @click="add" v-else>Add</el-button>
|
||||
<el-button :disabled="isReadOnly" type="primary" size="small" @click="add" v-else>
|
||||
{{ $t('api_test.request.assertions.add') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
@ -33,17 +35,28 @@
|
|||
|
||||
methods: {
|
||||
add() {
|
||||
this.duration.value = this.value;
|
||||
this.callback();
|
||||
if (this.validate()) {
|
||||
this.duration.value = this.value;
|
||||
this.callback();
|
||||
}
|
||||
},
|
||||
remove() {
|
||||
this.duration.value = undefined;
|
||||
},
|
||||
change(value) {
|
||||
this.$emit('change', value);
|
||||
if (this.validate()) {
|
||||
this.$emit('change', value);
|
||||
}
|
||||
},
|
||||
input(value) {
|
||||
this.$emit('input', value);
|
||||
},
|
||||
validate() {
|
||||
if (Number(this.value) < 0 || this.value=='') {
|
||||
this.$error(this.$t('commons.formatErr'));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
</el-col>
|
||||
<el-col class="assertion-btn">
|
||||
<el-button :disabled="isReadOnly" type="danger" size="mini" icon="el-icon-delete" circle @click="remove" v-if="edit"/>
|
||||
<el-button :disabled="isReadOnly" type="primary" size="small" @click="add" v-else>Add</el-button>
|
||||
<el-button :disabled="isReadOnly" type="primary" size="small" @click="add" v-else>
|
||||
{{ $t('api_test.request.assertions.add') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
<script>
|
||||
import {AssertionJSR223} from "../../model/ApiTestModel";
|
||||
import MsJsr233Processor from "../processor/Jsr233Processor";
|
||||
import MsJsr233Processor from "@/business/components/api/test/components/processor/Jsr233Processor";
|
||||
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
|
||||
|
||||
export default {
|
||||
|
|
|
@ -21,7 +21,9 @@
|
|||
<el-col class="assertion-btn">
|
||||
<el-button :disabled="isReadOnly" type="danger" size="mini" icon="el-icon-delete" circle @click="remove"
|
||||
v-if="edit"/>
|
||||
<el-button :disabled="isReadOnly" type="primary" size="small" @click="add" v-else>Add</el-button>
|
||||
<el-button :disabled="isReadOnly" type="primary" size="small" @click="add" v-else>
|
||||
{{ $t('api_test.request.assertions.add') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
|
|
@ -29,7 +29,9 @@
|
|||
</el-checkbox>
|
||||
</el-col>
|
||||
<el-col class="assertion-btn">
|
||||
<el-button :disabled="isReadOnly" type="primary" size="small" @click="add">Add</el-button>
|
||||
<el-button :disabled="isReadOnly" type="primary" size="small" @click="add">
|
||||
{{ $t('api_test.request.assertions.add') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
|
|
@ -2,81 +2,116 @@
|
|||
<div>
|
||||
<div class="assertion-item-editing regex" v-if="assertions.regex.length > 0">
|
||||
<div>
|
||||
{{$t("api_test.request.assertions.regex")}}
|
||||
{{ $t("api_test.request.assertions.regex") }}
|
||||
</div>
|
||||
<div class="regex-item" v-for="(regex, index) in assertions.regex" :key="index">
|
||||
<ms-api-assertion-regex :is-read-only="isReadOnly" :list="assertions.regex" :regex="regex" :edit="true" :index="index"/>
|
||||
<ms-api-assertion-regex :is-read-only="isReadOnly" :list="assertions.regex"
|
||||
:regex="regex" :edit="true" :index="index"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="assertion-item-editing json_path" v-if="assertions.jsonPath.length > 0">
|
||||
<div>
|
||||
{{'JSONPath'}}
|
||||
{{ 'JSONPath' }}
|
||||
</div>
|
||||
<div class="regex-item" v-for="(jsonPath, index) in assertions.jsonPath" :key="index">
|
||||
<ms-api-assertion-json-path :is-read-only="isReadOnly" :list="assertions.jsonPath" :json-path="jsonPath" :edit="true" :index="index"/>
|
||||
<ms-api-assertion-json-path :is-read-only="isReadOnly" :list="assertions.jsonPath"
|
||||
:json-path="jsonPath" :edit="true" :index="index"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="assertion-item-editing x_path" v-if="assertions.xpath2.length > 0">
|
||||
<div>
|
||||
{{ 'XPath' }}
|
||||
</div>
|
||||
<div class="regex-item" v-for="(xPath, index) in assertions.xpath2" :key="index">
|
||||
<ms-api-assertion-x-path2 :is-read-only="isReadOnly" :list="assertions.xpath2"
|
||||
:x-path2="xPath" :edit="true" :index="index"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="assertion-item-editing jsr223" v-if="assertions.jsr223.length > 0">
|
||||
<div>
|
||||
{{ $t("api_test.request.assertions.script") }}
|
||||
</div>
|
||||
<div class="regex-item" v-for="(assertion, index) in assertions.jsr223" :key="index">
|
||||
<ms-api-assertion-jsr223 :is-read-only="isReadOnly" :list="assertions.jsr223"
|
||||
:assertion="assertion" :edit="true" :index="index"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="assertion-item-editing response-time" v-if="isShow">
|
||||
<div>
|
||||
{{$t("api_test.request.assertions.response_time")}}
|
||||
{{ $t("api_test.request.assertions.response_time") }}
|
||||
</div>
|
||||
<ms-api-assertion-duration :is-read-only="isReadOnly" v-model="assertions.duration.value" :duration="assertions.duration" :edit="true"/>
|
||||
<ms-api-assertion-duration :is-read-only="isReadOnly" v-model="assertions.duration.value"
|
||||
:duration="assertions.duration" :edit="true"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MsApiAssertionRegex from "./ApiAssertionRegex";
|
||||
import MsApiAssertionDuration from "./ApiAssertionDuration";
|
||||
import {Assertions} from "../../model/ApiTestModel";
|
||||
import MsApiAssertionJsonPath from "./ApiAssertionJsonPath";
|
||||
import MsApiAssertionRegex from "./ApiAssertionRegex";
|
||||
import MsApiAssertionDuration from "./ApiAssertionDuration";
|
||||
import {Assertions} from "../../model/ApiTestModel";
|
||||
import MsApiAssertionJsonPath from "./ApiAssertionJsonPath";
|
||||
import MsApiAssertionJsr223 from "@/business/components/api/test/components/assertion/ApiAssertionJsr223";
|
||||
import MsApiAssertionXPath2 from "./ApiAssertionXPath2";
|
||||
|
||||
export default {
|
||||
name: "MsApiAssertionsEdit",
|
||||
export default {
|
||||
name: "MsApiAssertionsEdit",
|
||||
|
||||
components: {MsApiAssertionJsonPath, MsApiAssertionDuration, MsApiAssertionRegex},
|
||||
components: {
|
||||
MsApiAssertionXPath2,
|
||||
MsApiAssertionJsr223, MsApiAssertionJsonPath, MsApiAssertionDuration, MsApiAssertionRegex},
|
||||
|
||||
props: {
|
||||
assertions: {},
|
||||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
props: {
|
||||
assertions: Assertions,
|
||||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
isShow() {
|
||||
let rt = this.assertions.duration;
|
||||
return rt.value !== undefined;
|
||||
}
|
||||
computed: {
|
||||
isShow() {
|
||||
let rt = this.assertions.duration;
|
||||
return rt.value !== undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.assertion-item-editing {
|
||||
padding-left: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.assertion-item-editing {
|
||||
padding-left: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.assertion-item-editing.regex {
|
||||
border-left: 2px solid #7B0274;
|
||||
}
|
||||
.assertion-item-editing.regex {
|
||||
border-left: 2px solid #7B0274;
|
||||
}
|
||||
|
||||
.assertion-item-editing.json_path {
|
||||
border-left: 2px solid #44B3D2;
|
||||
}
|
||||
.assertion-item-editing.json_path {
|
||||
border-left: 2px solid #44B3D2;
|
||||
}
|
||||
|
||||
.assertion-item-editing.response-time {
|
||||
border-left: 2px solid #DD0240;
|
||||
}
|
||||
.assertion-item-editing.response-time {
|
||||
border-left: 2px solid #DD0240;
|
||||
}
|
||||
|
||||
.regex-item {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.assertion-item-editing.jsr223 {
|
||||
border-left: 2px solid #1FDD02;
|
||||
}
|
||||
|
||||
.assertion-item-editing.x_path {
|
||||
border-left: 2px solid #fca130;
|
||||
}
|
||||
|
||||
.regex-item {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
};
|
||||
},
|
||||
props: {
|
||||
request: {},
|
||||
request: HttpRequest,
|
||||
},
|
||||
methods: {
|
||||
close() {
|
||||
|
|
Loading…
Reference in New Issue