fix(接口测试): 修复清空断言没反应的缺陷

--bug=1028286 --user=王孝刚 【接口测试】test、case、场景下复制的api-对应的jsonpath断言-点击清空没反应
https://www.tapd.cn/55049933/s/1399978
This commit is contained in:
wxg0103 2023-08-01 17:58:04 +08:00 committed by wxg0103
parent 4822880d91
commit eac325046c
8 changed files with 66 additions and 33 deletions

View File

@ -7,4 +7,5 @@ public class MsAssertionDocument {
private boolean enable = true; private boolean enable = true;
private String type; private String type;
private Document data; private Document data;
private String label;
} }

View File

@ -3,7 +3,7 @@
<el-row :gutter="10" type="flex" justify="space-between" align="middle"> <el-row :gutter="10" type="flex" justify="space-between" align="middle">
<el-col> <el-col>
<el-input <el-input
:disabled="isReadOnly && !duration.label" :disabled="(isReadOnly && !duration.label) || caseEnable"
:value="value" :value="value"
v-bind="$attrs" v-bind="$attrs"
step="100" step="100"
@ -21,18 +21,18 @@
v-model="duration.enable" v-model="duration.enable"
class="enable-switch" class="enable-switch"
size="mini" size="mini"
:disabled="isReadOnly && !duration.label" :disabled="(isReadOnly && !duration.label) || caseEnable"
style="width: 30px; margin-right: 10px" /> style="width: 30px; margin-right: 10px" />
</el-tooltip> </el-tooltip>
<el-button <el-button
:disabled="isReadOnly && !duration.label" :disabled="(isReadOnly && !duration.label) || caseEnable"
type="danger" type="danger"
size="mini" size="mini"
icon="el-icon-delete" icon="el-icon-delete"
circle circle
@click="remove" @click="remove"
v-if="edit" /> v-if="edit" />
<el-button :disabled="isReadOnly && !duration.label" type="primary" size="mini" @click="add" v-else> <el-button :disabled="(isReadOnly && !duration.label) || caseEnable" type="primary" size="mini" @click="add" v-else>
{{ $t('api_test.request.assertions.add') }} {{ $t('api_test.request.assertions.add') }}
</el-button> </el-button>
</el-col> </el-col>
@ -53,6 +53,10 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
caseEnable: {
type: Boolean,
default: false,
},
}, },
created() { created() {

View File

@ -4,7 +4,7 @@
<el-col> <el-col>
<el-tooltip :disabled="showTip" placement="top" :content="jsonPath.expression"> <el-tooltip :disabled="showTip" placement="top" :content="jsonPath.expression">
<el-input <el-input
:disabled="isReadOnly && !jsonPath.label" :disabled="(isReadOnly && !jsonPath.label) || caseEnable"
v-model="jsonPath.expression" v-model="jsonPath.expression"
maxlength="500" maxlength="500"
size="small" size="small"
@ -14,7 +14,7 @@
</el-col> </el-col>
<el-col> <el-col>
<el-select <el-select
:disabled="isReadOnly && !jsonPath.label" :disabled="(isReadOnly && !jsonPath.label) || caseEnable"
v-model="jsonPath.option" v-model="jsonPath.option"
class="ms-col-type" class="ms-col-type"
size="small" size="small"
@ -29,7 +29,7 @@
<el-option :label="$t('api_test.request.assertions.regular_match')" value="REGEX"/> <el-option :label="$t('api_test.request.assertions.regular_match')" value="REGEX"/>
</el-select> </el-select>
<el-input <el-input
:disabled="isReadOnly && !jsonPath.label" :disabled="(isReadOnly && !jsonPath.label) || caseEnable"
v-model="jsonPath.expect" v-model="jsonPath.expect"
size="small" size="small"
show-word-limit show-word-limit
@ -48,25 +48,25 @@
v-model="jsonPath.enable" v-model="jsonPath.enable"
class="enable-switch" class="enable-switch"
size="mini" size="mini"
:disabled="isReadOnly && !jsonPath.label" :disabled="(isReadOnly && !jsonPath.label) || caseEnable"
style="width: 30px; margin-right: 10px"/> style="width: 30px; margin-right: 10px"/>
</el-tooltip> </el-tooltip>
<el-button <el-button
:disabled="isReadOnly && !jsonPath.label" :disabled="(isReadOnly && !jsonPath.label) || caseEnable"
size="mini" size="mini"
icon="el-icon-copy-document" icon="el-icon-copy-document"
circle circle
@click="copyRow" @click="copyRow"
v-if="edit"/> v-if="edit"/>
<el-button <el-button
:disabled="isReadOnly && !jsonPath.label" :disabled="(isReadOnly && !jsonPath.label) || caseEnable"
type="danger" type="danger"
size="mini" size="mini"
icon="el-icon-delete" icon="el-icon-delete"
circle circle
@click="remove" @click="remove"
v-if="edit"/> v-if="edit"/>
<el-button :disabled="isReadOnly && !jsonPath.label" type="primary" size="mini" @click="add" v-else> <el-button :disabled="(isReadOnly && !jsonPath.label) || caseEnable" type="primary" size="mini" @click="add" v-else>
{{ $t('api_test.request.assertions.add') }} {{ $t('api_test.request.assertions.add') }}
</el-button> </el-button>
</el-col> </el-col>
@ -97,6 +97,10 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
caseEnable: {
type: Boolean,
default: false,
},
}, },
created() { created() {

View File

@ -5,10 +5,10 @@
{{ assertion.desc }} {{ assertion.desc }}
</div> </div>
<div class="assertion-item btn"> <div class="assertion-item btn">
<el-button :disabled="isReadOnly && !assertion.label" type="success" size="mini" @click="detail"> <el-button :disabled="(isReadOnly && !assertion.label) || caseEnable" type="success" size="mini" @click="detail">
{{ $t('commons.edit') }} {{ $t('commons.edit') }}
</el-button> </el-button>
<el-button :disabled="isReadOnly && !assertion.label" type="primary" size="mini" @click="add"> <el-button :disabled="(isReadOnly && !assertion.label) || caseEnable" type="primary" size="mini" @click="add">
{{ $t('api_test.request.assertions.add') }} {{ $t('api_test.request.assertions.add') }}
</el-button> </el-button>
</div> </div>
@ -19,16 +19,16 @@
</div> </div>
<div class="assertion-item btn circle"> <div class="assertion-item btn circle">
<i class="el-icon-view el-button el-button--primary el-button--mini is-circle" circle @click="showPage" /> <i class="el-icon-view el-button el-button--primary el-button--mini is-circle" circle @click="showPage" />
<el-button :disabled="isReadOnly && !assertion.label" type="success" size="mini" icon="el-icon-edit" circle @click="detail" /> <el-button :disabled="(isReadOnly && !assertion.label) || caseEnable" type="success" size="mini" icon="el-icon-edit" circle @click="detail" />
<el-tooltip :content="$t('test_resource_pool.enable_disable')" placement="top"> <el-tooltip :content="$t('test_resource_pool.enable_disable')" placement="top">
<el-switch <el-switch
v-model="assertion.enable" v-model="assertion.enable"
class="enable-switch" class="enable-switch"
size="mini" size="mini"
:disabled="isReadOnly && !assertion.label" :disabled="(isReadOnly && !assertion.label) || caseEnable"
style="width: 30px; margin: 0px 10px 0px 10px" /> style="width: 30px; margin: 0px 10px 0px 10px" />
</el-tooltip> </el-tooltip>
<el-button :disabled="isReadOnly && !assertion.label" type="danger" size="mini" icon="el-icon-delete" circle @click="remove" /> <el-button :disabled="(isReadOnly && !assertion.label) || caseEnable" type="danger" size="mini" icon="el-icon-delete" circle @click="remove" />
</div> </div>
</el-row> </el-row>
@ -114,6 +114,10 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
caseEnable: {
type: Boolean,
default: false,
},
}, },
data() { data() {

View File

@ -3,7 +3,7 @@
<el-row :gutter="10" type="flex" justify="space-between" align="middle"> <el-row :gutter="10" type="flex" justify="space-between" align="middle">
<el-col class="assertion-select"> <el-col class="assertion-select">
<el-select <el-select
:disabled="isReadOnly && !regex.label" :disabled="(isReadOnly && !regex.label) || caseEnable"
class="assertion-item" class="assertion-item"
v-model="regex.subject" v-model="regex.subject"
size="small" size="small"
@ -16,7 +16,7 @@
<el-col> <el-col>
<el-tooltip :disabled="showTip" placement="top" :content="regex.expression"> <el-tooltip :disabled="showTip" placement="top" :content="regex.expression">
<el-input <el-input
:disabled="isReadOnly && !regex.label" :disabled="(isReadOnly && !regex.label) || caseEnable"
v-model="regex.expression" v-model="regex.expression"
size="small" size="small"
show-word-limit show-word-limit
@ -24,7 +24,7 @@
</el-tooltip> </el-tooltip>
</el-col> </el-col>
<el-col class="assertion-checkbox"> <el-col class="assertion-checkbox">
<el-checkbox v-model="regex.assumeSuccess" :disabled="isReadOnly && !regex.label"> <el-checkbox v-model="regex.assumeSuccess" :disabled="(isReadOnly && !regex.label) || caseEnable">
{{ $t('api_test.request.assertions.ignore_status') }} {{ $t('api_test.request.assertions.ignore_status') }}
</el-checkbox> </el-checkbox>
</el-col> </el-col>
@ -34,26 +34,26 @@
v-model="regex.enable" v-model="regex.enable"
class="enable-switch" class="enable-switch"
size="mini" size="mini"
:disabled="isReadOnly && !regex.label" :disabled="(isReadOnly && !regex.label) || caseEnable"
style="width: 30px; margin-right: 10px" /> style="width: 30px; margin-right: 10px" />
</el-tooltip> </el-tooltip>
<el-button <el-button
:disabled="isReadOnly && !regex.label" :disabled="(isReadOnly && !regex.label) || caseEnable"
size="mini" size="mini"
icon="el-icon-copy-document" icon="el-icon-copy-document"
circle circle
@click="copyRow" @click="copyRow"
v-if="edit" /> v-if="edit" />
<el-button <el-button
:disabled="isReadOnly && !regex.label" :disabled="(isReadOnly && !regex.label) || caseEnable"
type="danger" type="danger"
size="mini" size="mini"
icon="el-icon-delete" icon="el-icon-delete"
circle circle
@click="remove" @click="remove"
v-if="edit" /> v-if="edit" />
<el-button :disabled="isReadOnly && !regex.label" type="primary" size="mini" @click="add" v-else> <el-button :disabled="(isReadOnly && !regex.label) || caseEnable" type="primary" size="mini" @click="add" v-else>
{{ $t('api_test.request.assertions.add') }} {{ $t('api_test.request.assertions.add') }}
</el-button> </el-button>
</el-col> </el-col>
@ -84,6 +84,10 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
caseEnable: {
type: Boolean,
default: false,
},
}, },
data() { data() {

View File

@ -3,7 +3,7 @@
<el-row :gutter="10" type="flex" justify="space-between" align="middle"> <el-row :gutter="10" type="flex" justify="space-between" align="middle">
<el-col> <el-col>
<el-input <el-input
:disabled="isReadOnly && !xPath2.label" :disabled="(isReadOnly && !xPath2.label) || caseEnable"
v-model="xPath2.expression" v-model="xPath2.expression"
maxlength="500" maxlength="500"
size="small" size="small"
@ -16,25 +16,25 @@
v-model="xPath2.enable" v-model="xPath2.enable"
class="enable-switch" class="enable-switch"
size="mini" size="mini"
:disabled="isReadOnly && !xPath2.label" :disabled="(isReadOnly && !xPath2.label) || caseEnable"
style="width: 30px; margin-right: 10px" /> style="width: 30px; margin-right: 10px" />
</el-tooltip> </el-tooltip>
<el-button <el-button
:disabled="isReadOnly && !xPath2.label" :disabled="(isReadOnly && !xPath2.label) || caseEnable"
size="mini" size="mini"
icon="el-icon-copy-document" icon="el-icon-copy-document"
circle circle
@click="copyRow" @click="copyRow"
v-if="edit" /> v-if="edit" />
<el-button <el-button
:disabled="isReadOnly && !xPath2.label" :disabled="(isReadOnly && !xPath2.label) || caseEnable"
type="danger" type="danger"
size="mini" size="mini"
icon="el-icon-delete" icon="el-icon-delete"
circle circle
@click="remove" @click="remove"
v-if="edit" /> v-if="edit" />
<el-button :disabled="isReadOnly && !xPath2.label" type="primary" size="mini" @click="add" v-else> <el-button :disabled="(isReadOnly && !xPath2.label) || caseEnable" type="primary" size="mini" @click="add" v-else>
{{ $t('api_test.request.assertions.add') }} {{ $t('api_test.request.assertions.add') }}
</el-button> </el-button>
</el-col> </el-col>
@ -65,6 +65,10 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
caseEnable: {
type: Boolean,
default: false,
},
}, },
created() { created() {

View File

@ -80,6 +80,7 @@
:assertions="assertions" :assertions="assertions"
:apiId="apiId" :apiId="apiId"
:reloadData="reloadData" :reloadData="reloadData"
:case-enable="request.caseEnable"
style="margin-bottom: 20px" /> style="margin-bottom: 20px" />
<ms-api-jsonpath-suggest <ms-api-jsonpath-suggest
@ -249,11 +250,13 @@ export default {
this.assertions.jsonPath.push(jsonItem); this.assertions.jsonPath.push(jsonItem);
}, },
clearJson() { clearJson() {
if (this.assertions.jsonPath) { if (this.isReadOnly && this.assertions.jsonPath) {
const tmpArr = this.assertions.jsonPath.filter((item) => const tmpArr = this.assertions.jsonPath.filter((item) =>
!item.label !item.label
); );
this.assertions.jsonPath = tmpArr; this.assertions.jsonPath = tmpArr;
}else {
this.assertions.jsonPath = [];
} }
}, },
}, },

View File

@ -6,6 +6,7 @@
<ms-api-assertion-regex <ms-api-assertion-regex
:is-read-only="isReadOnly" :is-read-only="isReadOnly"
:list="assertions.regex" :list="assertions.regex"
:case-enable="caseEnable"
:regex="regex" :regex="regex"
:edit="true" :edit="true"
:index="index" /> :index="index" />
@ -18,6 +19,7 @@
<ms-api-assertion-json-path <ms-api-assertion-json-path
:is-read-only="isReadOnly" :is-read-only="isReadOnly"
:list="assertions.jsonPath" :list="assertions.jsonPath"
:case-enable="caseEnable"
:json-path="jsonPath" :json-path="jsonPath"
:edit="true" :edit="true"
:index="index" /> :index="index" />
@ -28,7 +30,7 @@
<div> <div>
XPath XPath
<el-select v-model="assertions.xpathType" size="mini" v-loading="loading" @change="reload" <el-select v-model="assertions.xpathType" size="mini" v-loading="loading" @change="reload"
:disabled="isReadOnly && !assertions.document.label"> :disabled="caseEnable ">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option> <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select> </el-select>
<el-tooltip placement="top"> <el-tooltip placement="top">
@ -42,6 +44,7 @@
<ms-api-assertion-x-path2 <ms-api-assertion-x-path2
:is-read-only="isReadOnly" :is-read-only="isReadOnly"
:list="assertions.xpath2" :list="assertions.xpath2"
:case-enable="caseEnable"
:x-path2="xPath" :x-path2="xPath"
:edit="true" :edit="true"
:index="index" /> :index="index" />
@ -54,6 +57,7 @@
<ms-api-assertion-jsr223 <ms-api-assertion-jsr223
:is-read-only="isReadOnly" :is-read-only="isReadOnly"
:list="assertions.jsr223" :list="assertions.jsr223"
:case-enable="caseEnable"
:assertion="assertion" :assertion="assertion"
:edit="true" :edit="true"
:index="index" /> :index="index" />
@ -65,6 +69,7 @@
<div class="regex-item"> <div class="regex-item">
<ms-api-assertion-duration <ms-api-assertion-duration
:is-read-only="isReadOnly" :is-read-only="isReadOnly"
:case-enable="caseEnable"
v-model="assertions.duration.value" v-model="assertions.duration.value"
:duration="assertions.duration" :duration="assertions.duration"
:edit="true" /> :edit="true" />
@ -80,7 +85,7 @@
v-model="assertions.document.enable" v-model="assertions.document.enable"
class="enable-switch" class="enable-switch"
size="mini" size="mini"
:disabled="isReadOnly && !assertions.document.label" :disabled="(isReadOnly && !assertions.document.label) || caseEnable"
style="width: 30px; margin-right: 10px" /> style="width: 30px; margin-right: 10px" />
</el-tooltip> </el-tooltip>
<el-tooltip effect="dark" :content="$t('commons.remove')" placement="top-start"> <el-tooltip effect="dark" :content="$t('commons.remove')" placement="top-start">
@ -90,12 +95,12 @@
size="mini" size="mini"
circle circle
@click="remove()" @click="remove()"
:disabled="isReadOnly && !assertions.document.label && !assertions.root" /> :disabled="(isReadOnly && !assertions.document.label && !assertions.root) || caseEnable" />
</el-tooltip> </el-tooltip>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
<ms-document-body :document="assertions.document" :apiId="apiId" :isReadOnly="isReadOnly && !assertions.document.label" @remove="remove" /> <ms-document-body :document="assertions.document" :apiId="apiId" :isReadOnly="isReadOnly && !assertions.document.label || caseEnable" @remove="remove" />
</div> </div>
</div> </div>
</template> </template>
@ -127,6 +132,10 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
caseEnable: {
type: Boolean,
default: false,
},
}, },
data() { data() {
return { return {