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

View File

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

View File

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

View File

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