feat(接口测试): 请求参数的参数名称唯一的校验(前置,后置)
This commit is contained in:
parent
9a1fc5a1f5
commit
27016d1014
|
@ -305,6 +305,7 @@ export type ExecuteConditionProcessor = Partial<
|
|||
export interface ExecuteConditionConfig {
|
||||
enableGlobal?: boolean; // 是否启用全局前/后置 默认为 true
|
||||
processors: ExecuteConditionProcessor[];
|
||||
activeItemId?: number;
|
||||
}
|
||||
// 执行请求-断言配置子项
|
||||
export type ExecuteAssertionItem = ResponseAssertionCommon &
|
||||
|
|
|
@ -727,6 +727,7 @@ if (!result){
|
|||
title: 'apiTestDebug.paramName',
|
||||
dataIndex: 'key',
|
||||
slotName: 'key',
|
||||
needValidRepeat: true,
|
||||
},
|
||||
{
|
||||
title: 'apiTestDebug.extractValueByColumn',
|
||||
|
@ -767,6 +768,7 @@ if (!result){
|
|||
title: 'apiTestDebug.paramName',
|
||||
dataIndex: 'variableName',
|
||||
slotName: 'key',
|
||||
needValidRepeat: true,
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<conditionList
|
||||
v-model:list="data"
|
||||
:disabled="props.disabled"
|
||||
:active-id="activeItem.id"
|
||||
:active-id="activeItemId"
|
||||
:show-associated-scene="props.showAssociatedScene"
|
||||
:show-pre-post-request="props.showPrePostRequest"
|
||||
@active-change="handleListActiveChange"
|
||||
|
@ -87,6 +87,7 @@
|
|||
required: true,
|
||||
});
|
||||
const activeItem = ref<ExecuteConditionProcessor>(data.value[0]);
|
||||
const activeItemId = computed(() => activeItem.value?.id);
|
||||
|
||||
function handleListActiveChange(item: ExecuteConditionProcessor) {
|
||||
activeItem.value = item;
|
||||
|
@ -109,8 +110,8 @@
|
|||
* 删除列表项
|
||||
*/
|
||||
function deleteListItem(id: string | number) {
|
||||
data.value = data.value.filter((precondition) => precondition.id !== activeItem.value.id);
|
||||
if (activeItem.value.id === id) {
|
||||
data.value = data.value.filter((precondition) => precondition.id !== activeItemId.value);
|
||||
if (activeItemId.value === id) {
|
||||
[activeItem.value] = data.value;
|
||||
}
|
||||
emit('change');
|
||||
|
@ -244,6 +245,10 @@
|
|||
[activeItem.value] = data.value;
|
||||
}
|
||||
});
|
||||
|
||||
defineExpose({
|
||||
activeItemId,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
|
|
@ -1361,6 +1361,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
function setChildErrorMessage(key: number | string, listItem: TabErrorMessage) {
|
||||
if (requestVModel.value.errorMessageInfo) {
|
||||
requestVModel.value.errorMessageInfo[requestVModel.value.activeTab][key] = cloneDeep(listItem);
|
||||
}
|
||||
}
|
||||
|
||||
function changeTabErrorMessageList(tabKey: string, formErrorMessageList: string[]) {
|
||||
if (!requestVModel.value.errorMessageInfo) return;
|
||||
const label = contentTabList.value.find((item) => item.value === tabKey)?.label ?? '';
|
||||
|
@ -1369,11 +1375,13 @@
|
|||
label,
|
||||
messageList: formErrorMessageList,
|
||||
};
|
||||
// TODO: 处理前置的sql 后置的sql和提取 断言的响应头和变量
|
||||
initErrorMessageInfoItem(requestVModel.value.activeTab);
|
||||
if (requestVModel.value.activeTab === RequestComposition.BODY) {
|
||||
initErrorMessageInfoItem(RequestComposition.BODY);
|
||||
requestVModel.value.errorMessageInfo[RequestComposition.BODY][requestVModel.value.body.bodyType] =
|
||||
cloneDeep(listItem);
|
||||
setChildErrorMessage(requestVModel.value.body.bodyType, listItem);
|
||||
} else if (requestVModel.value.activeTab === RequestComposition.POST_CONDITION) {
|
||||
setChildErrorMessage(requestVModel.value.children[0].postProcessorConfig.activeItemId as number, listItem);
|
||||
} else if (requestVModel.value.activeTab === RequestComposition.PRECONDITION) {
|
||||
setChildErrorMessage(requestVModel.value.children[0].preProcessorConfig.activeItemId as number, listItem);
|
||||
} else {
|
||||
requestVModel.value.errorMessageInfo[requestVModel.value.activeTab] = cloneDeep(listItem);
|
||||
}
|
||||
|
@ -1389,10 +1397,21 @@
|
|||
if (!requestVModel.value.errorMessageInfo) return;
|
||||
const flattenedMessages: { label: string; messageList: string[] }[] = [];
|
||||
const { errorMessageInfo } = requestVModel.value;
|
||||
Object.values(errorMessageInfo).forEach((item) => {
|
||||
const label = item.label || (Object.values(item)[0] && Object.values(item)[0].label);
|
||||
Object.entries(errorMessageInfo).forEach(([key, item]) => {
|
||||
const label = item.label || Object.values(item)[0]?.label;
|
||||
// 处理前后置已删除的
|
||||
if ([RequestComposition.POST_CONDITION as string, RequestComposition.PRECONDITION as string].includes(key)) {
|
||||
const processorIds = requestVModel.value.children[0][
|
||||
key === RequestComposition.POST_CONDITION ? 'postProcessorConfig' : 'preProcessorConfig'
|
||||
].processors.map((processorItem) => String(processorItem.id));
|
||||
Object.entries(item).forEach(([childKey, childItem]) => {
|
||||
if (!processorIds.includes(childKey)) {
|
||||
childItem.messageList = [];
|
||||
}
|
||||
});
|
||||
}
|
||||
const messageList: string[] =
|
||||
item.messageList || [...new Set(Object.values(item).flatMap((bodyType) => bodyType.messageList))] || [];
|
||||
item.messageList || [...new Set(Object.values(item).flatMap((child) => child.messageList))] || [];
|
||||
if (messageList.length) {
|
||||
flattenedMessages.push({ label, messageList: [...new Set(messageList)] });
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<template>
|
||||
<condition
|
||||
ref="conditionRef"
|
||||
v-model:list="innerConfig.processors"
|
||||
:condition-types="conditionTypes"
|
||||
add-text="apiTestDebug.postCondition"
|
||||
|
@ -71,6 +72,14 @@
|
|||
}
|
||||
return [RequestConditionProcessor.SCRIPT];
|
||||
});
|
||||
|
||||
const conditionRef = ref<InstanceType<typeof condition>>();
|
||||
watch(
|
||||
() => conditionRef.value?.activeItemId,
|
||||
(val) => {
|
||||
innerConfig.value.activeItemId = val;
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<template>
|
||||
<condition
|
||||
ref="conditionRef"
|
||||
v-model:list="innerConfig.processors"
|
||||
:disabled="props.disabled"
|
||||
:condition-types="conditionTypes"
|
||||
|
@ -62,6 +63,14 @@
|
|||
// 接口调试
|
||||
return [RequestConditionProcessor.SCRIPT, RequestConditionProcessor.TIME_WAITING];
|
||||
});
|
||||
|
||||
const conditionRef = ref<InstanceType<typeof condition>>();
|
||||
watch(
|
||||
() => conditionRef.value?.activeItemId,
|
||||
(val) => {
|
||||
innerConfig.value.activeItemId = val;
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
|
Loading…
Reference in New Issue