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