fix(接口测试): 断言响应体提取类型补充

This commit is contained in:
baiqi 2024-08-20 10:35:28 +08:00 committed by Craftsman
parent 17fc721b46
commit 832b4d540d
1 changed files with 26 additions and 6 deletions

View File

@ -354,7 +354,6 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useVModel } from '@vueuse/core';
import { TableColumnData, TableData } from '@arco-design/web-vue'; import { TableColumnData, TableData } from '@arco-design/web-vue';
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
@ -375,8 +374,8 @@
insertNode, insertNode,
} from '@/utils/tree'; } from '@/utils/tree';
import { ExecuteConditionProcessor, JSONPathExtract, RegexExtract, XPathExtract } from '@/models/apiTest/common'; import { JSONPathExtract, RegexExtract, XPathExtract } from '@/models/apiTest/common';
import { ResponseBodyAssertionType } from '@/enums/apiEnum'; import { RequestExtractExpressionEnum, ResponseBodyAssertionType } from '@/enums/apiEnum';
import { import {
defaultAssertParamsItem, defaultAssertParamsItem,
@ -394,7 +393,6 @@
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
data: Param;
response?: string; response?: string;
disabled?: boolean; disabled?: boolean;
showExtraction?: boolean; showExtraction?: boolean;
@ -405,13 +403,14 @@
); );
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'update:data', data: ExecuteConditionProcessor): void;
(e: 'copy'): void; (e: 'copy'): void;
(e: 'delete', id: number): void; (e: 'delete', id: number): void;
(e: 'change', param: Param): void; (e: 'change', param: Param): void;
}>(); }>();
const condition = useVModel(props, 'data', emit); const condition = defineModel<Param>('data', {
required: true,
});
const rootId = 0; // 1970-01-01 00:00:00 UTC const rootId = 0; // 1970-01-01 00:00:00 UTC
@ -480,6 +479,27 @@
}, },
]; ];
onBeforeMount(() => {
condition.value.jsonPathAssertion.assertions = condition.value.jsonPathAssertion.assertions?.map((e: Param) => {
return {
...e,
extractType: RequestExtractExpressionEnum.JSON_PATH,
};
});
condition.value.xpathAssertion.assertions = condition.value.xpathAssertion.assertions?.map((e: Param) => {
return {
...e,
extractType: RequestExtractExpressionEnum.X_PATH,
};
});
condition.value.regexAssertion.assertions = condition.value.regexAssertion.assertions?.map((e: Param) => {
return {
...e,
extractType: RequestExtractExpressionEnum.REGEX,
};
});
});
const handleChange = (data: any[], type: string, isInit?: boolean) => { const handleChange = (data: any[], type: string, isInit?: boolean) => {
switch (type) { switch (type) {
case ResponseBodyAssertionType.JSON_PATH: case ResponseBodyAssertionType.JSON_PATH: