fix(接口测试): 完善文档结构关于数组类型的校验

This commit is contained in:
fit2-zhao 2021-11-17 17:35:43 +08:00 committed by fit2-zhao
parent 935b7bc071
commit 72c300cc6c
2 changed files with 23 additions and 4 deletions

View File

@ -89,6 +89,9 @@ public class Document {
list.add(newJSONPathAssertion(item, conditionMap.get(item.getId()))); list.add(newJSONPathAssertion(item, conditionMap.get(item.getId())));
} }
if (CollectionUtils.isNotEmpty(item.getChildren())) { if (CollectionUtils.isNotEmpty(item.getChildren())) {
if (item.getType().equals("array") && !item.isArrayVerification()) {
continue;
}
formatting(item.getChildren(), list, item, conditionMap); formatting(item.getChildren(), list, item, conditionMap);
} }
} else { } else {
@ -108,10 +111,13 @@ public class Document {
} else { } else {
item.setJsonPath("$." + item.getName()); item.setJsonPath("$." + item.getName());
} }
if (!StringUtils.equalsAny(item.getContentVerification(), "none", null) || item.isInclude()|| item.isArrayVerification() || item.isTypeVerification()) { if (!StringUtils.equalsAny(item.getContentVerification(), "none", null) || item.isInclude() || item.isArrayVerification() || item.isTypeVerification()) {
list.add(newXMLAssertion(item, conditionMap.get(item.getId()))); list.add(newXMLAssertion(item, conditionMap.get(item.getId())));
} }
if (CollectionUtils.isNotEmpty(item.getChildren())) { if (CollectionUtils.isNotEmpty(item.getChildren())) {
if (item.getType().equals("array") && !item.isArrayVerification()) {
continue;
}
xmlFormatting(item.getChildren(), list, item, conditionMap); xmlFormatting(item.getChildren(), list, item, conditionMap);
} }
} }

View File

@ -16,12 +16,13 @@
@cell-mouse-enter="editRow" @cell-mouse-enter="editRow"
@cell-mouse-leave="editLeave" @cell-mouse-leave="editLeave"
row-key="id" row-key="id"
border
default-expand-all default-expand-all
v-loading="loading"> v-loading="loading">
<el-table-column prop="name" :label="$t('api_test.definition.request.esb_table.name')" width="230"> <el-table-column prop="name" :label="$t('api_test.definition.request.esb_table.name')" width="230">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-if="scope.row.status && scope.column.fixed && scope.row.id!=='root'" v-model="scope.row.name" style="width: 140px" size="mini"/> <el-input v-if="(scope.row.status && scope.column.fixed && scope.row.id!=='root') || (scope.row.type !=='object' && !scope.row.name)" v-model="scope.row.name" style="width: 140px" size="mini" :placeholder="$t('api_test.definition.request.esb_table.name')"/>
<span v-else>{{ scope.row.name }}</span> <span v-else>{{ scope.row.name }}</span>
</template> </template>
</el-table-column> </el-table-column>
@ -69,7 +70,7 @@
<el-table-column :label="$t('commons.operating')" width="200" fixed="right"> <el-table-column :label="$t('commons.operating')" width="200" fixed="right">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span> <span>
<el-button size="mini" type="text" circle @click="addVerification(scope.row)" :disabled="scope.row.type ==='object' || checked || scope.row.id==='root'">添加校验</el-button> <el-button size="mini" type="text" circle @click="addVerification(scope.row)" :disabled="scope.row.type ==='object' ||scope.row.type ==='array' || checked || scope.row.id==='root'">添加校验</el-button>
<el-button size="mini" type="text" @click="addRow(scope.row)" :disabled="(scope.row.type !=='object' && scope.row.type !=='array') || checked">添加子字段</el-button> <el-button size="mini" type="text" @click="addRow(scope.row)" :disabled="(scope.row.type !=='object' && scope.row.type !=='array') || checked">添加子字段</el-button>
<el-button size="mini" type="text" @click="remove(scope.row)" :disabled="checked || scope.row.id==='root'">{{ $t('commons.remove') }}</el-button> <el-button size="mini" type="text" @click="remove(scope.row)" :disabled="checked || scope.row.id==='root'">{{ $t('commons.remove') }}</el-button>
</span> </span>
@ -245,9 +246,10 @@ export default {
'span', [ 'span', [
h('el-checkbox', { h('el-checkbox', {
style: 'margin-right:5px;', style: 'margin-right:5px;',
disabled:this.checked,
on: { on: {
change: this.handleCheckAllChange change: this.handleCheckAllChange
} },
}), }),
h('span', column.label) h('span', column.label)
] ]
@ -258,6 +260,7 @@ export default {
'span', [ 'span', [
h('el-checkbox', { h('el-checkbox', {
style: 'margin-right:5px;', style: 'margin-right:5px;',
disabled:this.checked,
on: { on: {
change: this.handleType change: this.handleType
} }
@ -271,6 +274,7 @@ export default {
'span', [ 'span', [
h('el-checkbox', { h('el-checkbox', {
style: 'margin-right:5px;', style: 'margin-right:5px;',
disabled:this.checked,
on: { on: {
change: this.handleArray change: this.handleArray
} }
@ -298,18 +302,27 @@ export default {
} }
}, },
handleCheckAllChange(val) { handleCheckAllChange(val) {
if(this.checked){
return;
}
this.tableData.forEach(item => { this.tableData.forEach(item => {
item.include = val; item.include = val;
this.childrenChecked(item.children, 1, val); this.childrenChecked(item.children, 1, val);
}) })
}, },
handleType(val) { handleType(val) {
if(this.checked) {
return;
}
this.tableData.forEach(item => { this.tableData.forEach(item => {
item.typeVerification = val; item.typeVerification = val;
this.childrenChecked(item.children, 2, val); this.childrenChecked(item.children, 2, val);
}) })
}, },
handleArray(val) { handleArray(val) {
if(this.checked){
return;
}
this.tableData.forEach(item => { this.tableData.forEach(item => {
item.arrayVerification = val; item.arrayVerification = val;
this.childrenChecked(item.children, 3, val); this.childrenChecked(item.children, 3, val);