fix(接口测试): 接口测试断言报错空列表过滤保存不正确问题

This commit is contained in:
xinxin.wu 2024-04-23 19:20:54 +08:00 committed by Craftsman
parent d19071ad1e
commit cbab810c8f
3 changed files with 10 additions and 1 deletions

View File

@ -197,6 +197,13 @@ export const defaultExtractParamItem: ExpressionConfig = {
responseFormat: ResponseBodyXPathAssertionFormat.XML,
moreSettingPopoverVisible: false,
};
// @desc 断言的字段xpath和上边的defaultExtractParamItem不匹配所以添加此类型为了保存参数过滤正确
export const assertDefaultParamsItem: ResponseAssertionItem = {
expression: '',
condition: RequestAssertionCondition.EQUALS,
expectedValue: '',
enable: true,
};
// 断言 json默认值
export const jsonPathDefaultParamItem = {

View File

@ -1136,6 +1136,7 @@
//
const { assertionConfig } = requestVModel.value.children[0];
return {
id: requestVModel.value.id.toString(),
reportId: reportId.value,

View File

@ -4,6 +4,7 @@ import { type ExecuteAssertionConfig, ExecuteBody, type ExecuteConditionConfig }
import { RequestConditionProcessor, RequestParamsType, ResponseBodyAssertionType } from '@/enums/apiEnum';
import {
assertDefaultParamsItem,
defaultAssertParamsItem,
defaultBodyParamsItem,
defaultExtractParamItem,
@ -216,7 +217,7 @@ export function filterAssertions(assertionConfig: ExecuteAssertionConfig, isExec
},
xpathAssertion: {
...assertItem.xpathAssertion,
assertions: filterKeyValParams(assertItem?.xpathAssertion?.assertions || [], defaultExtractParamItem, isExecute)
assertions: filterKeyValParams(assertItem?.xpathAssertion?.assertions || [], assertDefaultParamsItem, isExecute)
.validParams,
},
jsonPathAssertion: {