fix(断言): 断言提取应用到表格不生效修复

This commit is contained in:
baiqi 2024-08-15 10:43:15 +08:00 committed by 刘瑞斌
parent 65e810de6f
commit 5cb8a77abb
4 changed files with 11 additions and 18 deletions

View File

@ -39,7 +39,6 @@
v-model:model-value="record.expression"
class="ms-params-input"
:max-length="255"
size="mini"
:disabled="props.disabled"
:placeholder="t('apiTestDebug.commonPlaceholder')"
@input="() => handleExpressionChange(rowIndex)"
@ -62,7 +61,7 @@
? 'ms-params-input-suffix-icon--disabled'
: 'ms-params-input-suffix-icon'
"
@click.stop="() => showFastExtraction(record, RequestExtractExpressionEnum.JSON_PATH)"
@click.stop="() => showFastExtraction(record)"
/>
</a-tooltip>
</template>
@ -147,7 +146,6 @@
:disabled="props.disabled"
class="ms-params-input"
:max-length="255"
size="mini"
:placeholder="t('apiTestDebug.commonPlaceholder')"
@input="() => handleExpressionChange(rowIndex)"
@change="() => handleExpressionChange(rowIndex)"
@ -168,7 +166,7 @@
? 'ms-params-input-suffix-icon--disabled'
: 'ms-params-input-suffix-icon'
"
@click.stop="() => showFastExtraction(record, RequestExtractExpressionEnum.X_PATH)"
@click.stop="() => showFastExtraction(record)"
/>
</a-tooltip>
</template>
@ -294,7 +292,6 @@
:disabled="props.disabled"
class="ms-params-input"
:max-length="255"
size="mini"
@input="() => handleExpressionChange(rowIndex)"
@change="() => handleExpressionChange(rowIndex)"
>
@ -314,7 +311,7 @@
? 'ms-params-input-suffix-icon--disabled'
: 'ms-params-input-suffix-icon'
"
@click.stop="() => showFastExtraction(record, RequestExtractExpressionEnum.REGEX)"
@click.stop="() => showFastExtraction(record)"
/>
</a-tooltip>
</template>
@ -378,14 +375,8 @@
insertNode,
} from '@/utils/tree';
import {
ExecuteConditionProcessor,
ExpressionType,
JSONPathExtract,
RegexExtract,
XPathExtract,
} from '@/models/apiTest/common';
import { RequestExtractExpressionEnum, ResponseBodyAssertionType } from '@/enums/apiEnum';
import { ExecuteConditionProcessor, JSONPathExtract, RegexExtract, XPathExtract } from '@/models/apiTest/common';
import { ResponseBodyAssertionType } from '@/enums/apiEnum';
import {
defaultAssertParamsItem,
@ -638,7 +629,6 @@
];
const documentDefaultParamItem = {
id: new Date().getTime(),
paramsName: '',
mustInclude: false,
typeChecking: false,
@ -816,9 +806,9 @@
}
}
function showFastExtraction(record: ExpressionConfig, type: ExpressionType) {
function showFastExtraction(record: ExpressionConfig) {
if (props.disabled || !props.response) return;
activeRecord.value = { ...record, extractType: type };
activeRecord.value = { ...record };
fastExtractionVisible.value = true;
}
//

View File

@ -184,6 +184,7 @@ export interface ResponseAssertionItem {
expectedValue?: string;
expression: string;
enable?: boolean;
extractType?: RequestExtractExpressionEnum;
}
// 断言-JSONPath断言子项
export type ResponseJSONPathAssertionItem = ResponseAssertionItem;

View File

@ -199,6 +199,7 @@ export const defaultAssertParamsItem: ResponseAssertionItem = {
condition: RequestAssertionCondition.EQUALS,
expectedValue: '',
enable: true,
extractType: RequestExtractExpressionEnum.X_PATH,
};
// 断言xpath & reg
@ -230,10 +231,10 @@ export const assertDefaultParamsItem: ResponseAssertionItem = {
// 断言 json默认值
export const jsonPathDefaultParamItem = {
id: '',
enable: true,
expression: '',
expectedValue: '',
extractType: RequestExtractExpressionEnum.JSON_PATH,
condition: EQUAL.value,
valid: true,
};

View File

@ -303,6 +303,7 @@
:response="requestVModel.response?.requestResults[0]?.responseResult.body"
:assertion-config="requestVModel.children[0].assertionConfig"
:show-extraction="true"
@change="handleActiveDebugChange"
/>
<auth
v-else-if="requestVModel.activeTab === RequestComposition.AUTH"