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 String type;
private Document data;
private String label;
}

View File

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

View File

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

View File

@ -5,10 +5,10 @@
{{ assertion.desc }}
</div>
<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') }}
</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') }}
</el-button>
</div>
@ -19,16 +19,16 @@
</div>
<div class="assertion-item btn circle">
<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-switch
v-model="assertion.enable"
class="enable-switch"
size="mini"
:disabled="isReadOnly && !assertion.label"
:disabled="(isReadOnly && !assertion.label) || caseEnable"
style="width: 30px; margin: 0px 10px 0px 10px" />
</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>
</el-row>
@ -114,6 +114,10 @@ export default {
type: Boolean,
default: false,
},
caseEnable: {
type: Boolean,
default: false,
},
},
data() {

View File

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

View File

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

View File

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

View File

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