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

View File

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

View File

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