fix(接口测试): case的jsonpath断言多余空行处理

This commit is contained in:
baiqi 2024-07-30 18:54:51 +08:00 committed by Craftsman
parent cbd069ca0a
commit de69c69230
3 changed files with 9 additions and 10 deletions

View File

@ -496,7 +496,6 @@
if (!isInit) {
emit('change', { ...condition.value });
}
break;
case ResponseBodyAssertionType.XPATH:
condition.value.xpathAssertion.assertions = data;

View File

@ -224,18 +224,12 @@ export const assertDefaultParamsItem: ResponseAssertionItem = {
// 断言 json默认值
export const jsonPathDefaultParamItem = {
id: '',
enable: true,
variableName: '',
variableType: RequestExtractEnvType.TEMPORARY,
extractScope: RequestExtractScope.BODY,
expression: '',
expectedValue: '',
condition: EQUAL.value,
extractType: RequestExtractExpressionEnum.JSON_PATH,
expressionMatchingRule: RequestExtractExpressionRuleType.EXPRESSION,
resultMatchingRule: RequestExtractResultMatchingRule.RANDOM,
resultMatchingRuleNum: 1,
responseFormat: ResponseBodyXPathAssertionFormat.XML,
moreSettingPopoverVisible: false,
valid: true,
};
// 断言 正则默认值
export const regexDefaultParamItem = {

View File

@ -245,6 +245,12 @@ export function filterConditionsSqlValidParams(condition: ExecuteConditionConfig
*/
export function filterAssertions(assertionConfig: ExecuteAssertionConfig, isExecute = false) {
return assertionConfig.assertions.map((assertItem: any) => {
const lastItem =
assertItem?.jsonPathAssertion?.assertions[(assertItem?.jsonPathAssertion?.assertions.length || 1) - 1];
if (lastItem.expression === '' && lastItem.expectedValue === '' && lastItem.enable === true) {
// 最后一行是空行,将其删除
assertItem.jsonPathAssertion.assertions.splice(-1, 1);
}
return {
...assertItem,
bodyAssertionDataByType: {