fix(接口测试): 修复case无法使用跟随API的缺陷

--bug=1013421 --user=王孝刚 [BUG] [接口测试]
github#13861在用例中添加文档结构断言,选择跟随API定义时,不能将API定义中的内容获取过来,导致断言不生效
https://www.tapd.cn/55049933/s/1164524
This commit is contained in:
wxg0103 2022-05-26 11:33:39 +08:00 committed by f2c-ci-robot[bot]
parent 63fe493af1
commit b01139419f
4 changed files with 26 additions and 3 deletions

View File

@ -1,6 +1,7 @@
<template>
<span class="json-path-suggest-button">
<el-button size="mini" type="primary" @click="$emit('open')" @click.stop :disabled="isReadOnly">
<el-button size="mini" type="primary" @click="$emit('open')" @click.stop :disabled="isReadOnly"
v-if="showSuggestButton">
{{ openTip }}
</el-button>
<el-button size="mini" type="danger" @click="$emit('clear')" :disabled="isReadOnly">
@ -12,7 +13,15 @@
<script>
export default {
name: "ApiJsonPathSuggestButton",
props: ['openTip', 'clearTip','isReadOnly']
props: {
openTip: String,
clearTip: String,
isReadOnly: Boolean,
showSuggestButton: {
type: Boolean,
default: true,
}
}
}
</script>

View File

@ -18,6 +18,13 @@
<el-card :draggable="true">
<el-row>
<span>{{ $t('api_test.request.assertions.description') }}</span>
<span style="float: right">
<api-json-path-suggest-button
:show-suggest-button="false"
:clear-tip="$t('api_test.request.assertions.json_path_clear')"
:isReadOnly="isReadOnly"
@clear="clearJson"/>
</span>
</el-row>
<div class="assertion-add" :draggable="draggable">
<el-row :gutter="10">

View File

@ -218,7 +218,7 @@ export default {
},
getDocument() {
// idid
if (this.document && this.document.nodeType && this.document.nodeType === "scenario") {
if (this.document && this.document.nodeType && (this.document.nodeType === "scenario" || this.document.nodeType === "Case")) {
this.getCase();
} else {
this.getAPI();

View File

@ -311,6 +311,13 @@ export default {
if (requireComponent != null && JSON.stringify(esbDefinition) != '{}' && JSON.stringify(esbDefinitionResponse) != '{}') {
this.isXpack = true;
}
if (this.apiCase.request && this.apiCase.request.hashTree && this.apiCase.request.hashTree.length > 0) {
this.apiCase.request.hashTree.forEach(item => {
if (item.type === 'Assertions') {
item.document.nodeType = 'Case'
}
})
}
this.readonly = !hasPermission('PROJECT_API_DEFINITION:READ+EDIT_CASE');
if (this.apiCase && this.apiCase.id) {
this.showFollow = false;