refactor(接口测试): 断言表达式内容过长显示提示

--story=1007679 --user=赵勇 #13627[企业用户] 断言中如果字符过长显示不全,期望有悬浮显示的功能
https://www.tapd.cn/55049933/s/1180364
This commit is contained in:
fit2-zhao 2022-06-13 19:22:58 +08:00 committed by f2c-ci-robot[bot]
parent 160434560f
commit ad32abe6a7
2 changed files with 80 additions and 72 deletions

View File

@ -2,8 +2,10 @@
<div v-loading="loading">
<el-row :gutter="10" type="flex" justify="space-between" align="middle">
<el-col>
<el-input :disabled="isReadOnly" v-model="jsonPath.expression" maxlength="500" size="small" show-word-limit
:placeholder="$t('api_test.request.extract.json_path_expression')"/>
<el-tooltip :disabled="showTip" placement="top" :content="jsonPath.expression">
<el-input :disabled="isReadOnly" v-model="jsonPath.expression" maxlength="500" size="small" show-word-limit
:placeholder="$t('api_test.request.extract.json_path_expression')"/>
</el-tooltip>
</el-col>
<el-col>
<el-select :disabled="isReadOnly" v-model="jsonPath.option" class="ms-col-type" size="small"
@ -37,89 +39,91 @@
</template>
<script>
import {JSONPath} from "../../model/ApiTestModel";
import {JSONPath} from "../../model/ApiTestModel";
export default {
name: "MsApiAssertionJsonPath",
export default {
name: "MsApiAssertionJsonPath",
props: {
jsonPath: {
default: () => {
return new JSONPath();
}
},
edit: {
type: Boolean,
default: false
},
index: Number,
list: Array,
callback: Function,
isReadOnly: {
type: Boolean,
default: false
props: {
jsonPath: {
default: () => {
return new JSONPath();
}
},
created() {
if (!this.jsonPath.option) {
this.jsonPath.option = "REGEX";
}
edit: {
type: Boolean,
default: false
},
index: Number,
list: Array,
callback: Function,
isReadOnly: {
type: Boolean,
default: false
}
},
data() {
return {
loading: false
}
created() {
if (!this.jsonPath.option) {
this.jsonPath.option = "REGEX";
}
},
data() {
return {
loading: false,
showTip: true,
}
},
watch: {
'jsonPath.expect'() {
this.setJSONPathDescription();
},
'jsonPath.expression'() {
this.setJSONPathDescription();
}
},
watch: {
'jsonPath.expect'() {
this.setJSONPathDescription();
},
'jsonPath.expression'() {
this.setJSONPathDescription();
}
methods: {
add: function () {
this.list.push(this.getJSONPath());
this.callback();
},
methods: {
add: function () {
this.list.push(this.getJSONPath());
this.callback();
},
remove: function () {
this.list.splice(this.index, 1);
},
getJSONPath() {
let jsonPath = new JSONPath(this.jsonPath);
jsonPath.enable = true;
jsonPath.description = jsonPath.expression + " expect: " + (jsonPath.expect ? jsonPath.expect : '');
return jsonPath;
},
reload() {
this.loading = true
this.$nextTick(() => {
this.loading = false
})
},
setJSONPathDescription() {
this.jsonPath.description = this.jsonPath.expression + " expect: " + (this.jsonPath.expect ? this.jsonPath.expect : '');
}
remove: function () {
this.list.splice(this.index, 1);
},
getJSONPath() {
let jsonPath = new JSONPath(this.jsonPath);
jsonPath.enable = true;
jsonPath.description = jsonPath.expression + " expect: " + (jsonPath.expect ? jsonPath.expect : '');
return jsonPath;
},
reload() {
this.loading = true
this.$nextTick(() => {
this.loading = false
})
},
setJSONPathDescription() {
this.showTip = this.jsonPath.expression.length < 50;
this.jsonPath.description = this.jsonPath.expression + " expect: " + (this.jsonPath.expect ? this.jsonPath.expect : '');
}
}
}
</script>
<style scoped>
.assertion-select {
width: 250px;
}
.assertion-select {
width: 250px;
}
.assertion-item {
width: 100%;
}
.assertion-item {
width: 100%;
}
.assertion-btn {
text-align: center;
width: 80px;
}
.assertion-btn {
text-align: center;
width: 80px;
}
</style>

View File

@ -10,8 +10,10 @@
</el-select>
</el-col>
<el-col>
<el-input :disabled="isReadOnly" v-model="regex.expression" size="small" show-word-limit
<el-tooltip :disabled="showTip" placement="top" :content="regex.expression">
<el-input :disabled="isReadOnly" v-model="regex.expression" size="small" show-word-limit
:placeholder="$t('api_test.request.assertions.expression')"/>
</el-tooltip>
</el-col>
<el-col class="assertion-checkbox">
<el-checkbox v-model="regex.assumeSuccess" :disabled="isReadOnly">
@ -61,6 +63,7 @@ export default {
data() {
return {
subjects: ASSERTION_REGEX_SUBJECT,
showTip: true,
}
},
@ -88,6 +91,7 @@ export default {
return regex;
},
setRegexDescription() {
this.showTip = this.regex.description.length < 80;
this.regex.description = this.regex.subject + " has: " + this.regex.expression;
}
}