fix(接口测试): 修复jsonpath断言描述不准确的缺陷

--bug=1024854 --user=王孝刚 [接口测试] github#23072断言,Not
Contains类型的,在报告里体现的描述不准确。 https://www.tapd.cn/55049933/s/1355501
This commit is contained in:
wxg0103 2023-03-24 11:17:49 +08:00 committed by fit2-zhao
parent b14e26a1f6
commit f932748609
2 changed files with 20 additions and 18 deletions

View File

@ -9,7 +9,7 @@
maxlength="500" maxlength="500"
size="small" size="small"
show-word-limit show-word-limit
:placeholder="$t('api_test.request.extract.json_path_expression')" /> :placeholder="$t('api_test.request.extract.json_path_expression')"/>
</el-tooltip> </el-tooltip>
</el-col> </el-col>
<el-col> <el-col>
@ -19,14 +19,14 @@
class="ms-col-type" class="ms-col-type"
size="small" size="small"
style="width: 40%; margin-right: 10px" style="width: 40%; margin-right: 10px"
@change="reload"> @change="setJSONPathDescription">
<el-option :label="$t('api_test.request.assertions.contains')" value="CONTAINS" /> <el-option :label="$t('api_test.request.assertions.contains')" value="CONTAINS"/>
<el-option :label="$t('api_test.request.assertions.not_contains')" value="NOT_CONTAINS" /> <el-option :label="$t('api_test.request.assertions.not_contains')" value="NOT_CONTAINS"/>
<el-option :label="$t('api_test.request.assertions.equals')" value="EQUALS" /> <el-option :label="$t('api_test.request.assertions.equals')" value="EQUALS"/>
<el-option :label="$t('commons.adv_search.operators.not_equals')" value="NOT_EQUALS" /> <el-option :label="$t('commons.adv_search.operators.not_equals')" value="NOT_EQUALS"/>
<el-option :label="$t('commons.adv_search.operators.gt')" value="GT" /> <el-option :label="$t('commons.adv_search.operators.gt')" value="GT"/>
<el-option :label="$t('commons.adv_search.operators.lt')" value="LT" /> <el-option :label="$t('commons.adv_search.operators.lt')" value="LT"/>
<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" :disabled="isReadOnly"
@ -34,12 +34,12 @@
size="small" size="small"
show-word-limit show-word-limit
:placeholder="$t('api_test.request.assertions.expect')" :placeholder="$t('api_test.request.assertions.expect')"
style="width: 50%" /> style="width: 50%"/>
<el-tooltip placement="top" v-if="jsonPath.option === 'REGEX'"> <el-tooltip placement="top" v-if="jsonPath.option === 'REGEX'">
<div slot="content"> <div slot="content">
{{ $t('api_test.request.assertions.regex_info') }} {{ $t('api_test.request.assertions.regex_info') }}
</div> </div>
<i class="el-icon-question" style="cursor: pointer" /> <i class="el-icon-question" style="cursor: pointer"/>
</el-tooltip> </el-tooltip>
</el-col> </el-col>
<el-col class="assertion-btn"> <el-col class="assertion-btn">
@ -49,7 +49,7 @@
class="enable-switch" class="enable-switch"
size="mini" size="mini"
:disabled="isReadOnly" :disabled="isReadOnly"
style="width: 30px; margin-right: 10px" /> style="width: 30px; margin-right: 10px"/>
</el-tooltip> </el-tooltip>
<el-button <el-button
:disabled="isReadOnly" :disabled="isReadOnly"
@ -57,7 +57,7 @@
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" :disabled="isReadOnly"
type="danger" type="danger"
@ -65,7 +65,7 @@
icon="el-icon-delete" icon="el-icon-delete"
circle circle
@click="remove" @click="remove"
v-if="edit" /> v-if="edit"/>
<el-button :disabled="isReadOnly" type="primary" size="mini" @click="add" v-else> <el-button :disabled="isReadOnly" type="primary" size="mini" @click="add" v-else>
{{ $t('api_test.request.assertions.add') }} {{ $t('api_test.request.assertions.add') }}
</el-button> </el-button>
@ -75,7 +75,7 @@
</template> </template>
<script> <script>
import { JSONPath } from '../../model/ApiTestModel'; import {JSONPath} from '../../model/ApiTestModel';
export default { export default {
name: 'MsApiAssertionJsonPath', name: 'MsApiAssertionJsonPath',
@ -145,7 +145,8 @@ export default {
setJSONPathDescription() { setJSONPathDescription() {
this.showTip = !this.jsonPath || !this.jsonPath.expression || this.jsonPath.expression.length < 50; this.showTip = !this.jsonPath || !this.jsonPath.expression || this.jsonPath.expression.length < 50;
this.jsonPath.description = this.jsonPath.description =
this.jsonPath.expression + ' expect: ' + (this.jsonPath.expect ? this.jsonPath.expect : ''); this.jsonPath.expression + " " + this.jsonPath.option + ": " + (this.jsonPath.expect ? this.jsonPath.expect : '');
this.reload();
}, },
copyRow() { copyRow() {
let jsonPath = new JSONPath(this.jsonPath); let jsonPath = new JSONPath(this.jsonPath);

View File

@ -9,7 +9,7 @@
</el-col> </el-col>
<el-col> <el-col>
<el-select :disabled="isReadOnly" v-model="jsonPath.option" class="ms-col-type" size="small" <el-select :disabled="isReadOnly" v-model="jsonPath.option" class="ms-col-type" size="small"
style="width:40%;margin-right: 10px" @change="reload"> style="width:40%;margin-right: 10px" @change="setJSONPathDescription">
<el-option :label="$t('api_test.request.assertions.contains')" value="CONTAINS"/> <el-option :label="$t('api_test.request.assertions.contains')" value="CONTAINS"/>
<el-option :label="$t('api_test.request.assertions.not_contains')" value="NOT_CONTAINS"/> <el-option :label="$t('api_test.request.assertions.not_contains')" value="NOT_CONTAINS"/>
<el-option :label="$t('api_test.request.assertions.equals')" value="EQUALS"/> <el-option :label="$t('api_test.request.assertions.equals')" value="EQUALS"/>
@ -110,7 +110,8 @@ export default {
}, },
setJSONPathDescription() { setJSONPathDescription() {
this.showTip = !this.jsonPath || !this.jsonPath.expression || this.jsonPath.expression.length < 50; this.showTip = !this.jsonPath || !this.jsonPath.expression || this.jsonPath.expression.length < 50;
this.jsonPath.description = this.jsonPath.expression + " expect: " + (this.jsonPath.expect ? this.jsonPath.expect : ''); this.jsonPath.description = this.jsonPath.expression + " " + this.jsonPath.option + ": " + (this.jsonPath.expect ? this.jsonPath.expect : '');
this.reload();
} }
} }
} }