feat(接口测试): 接口&用例复制文件
This commit is contained in:
parent
f20fff9b9f
commit
598bcadf94
|
@ -380,13 +380,15 @@
|
||||||
// 复制的步骤需要复制文件
|
// 复制的步骤需要复制文件
|
||||||
let copyFilesMap: Record<string, any> = {};
|
let copyFilesMap: Record<string, any> = {};
|
||||||
const fileIds = parseRequestBodyFiles(res.request.body, [], [], []).uploadFileIds;
|
const fileIds = parseRequestBodyFiles(res.request.body, [], [], []).uploadFileIds;
|
||||||
if (fileIds.length > 0) {
|
if (fileIds.length > 0 && isCopy) {
|
||||||
copyFilesMap = await definitionFileCopy({
|
copyFilesMap = await definitionFileCopy({
|
||||||
resourceId: typeof apiInfo === 'string' ? apiInfo : apiInfo.id,
|
resourceId: typeof apiInfo === 'string' ? apiInfo : apiInfo.id,
|
||||||
fileIds,
|
fileIds,
|
||||||
});
|
});
|
||||||
|
parseRequestBodyFiles(res.request.body, res.response, [], [], copyFilesMap); // 替换请求的文件 id
|
||||||
|
} else {
|
||||||
|
parseRequestBodyResult = parseRequestBodyFiles(res.request.body, res.response, [], [], copyFilesMap); // 解析请求体中的文件,将详情中的文件 id 集合收集,更新时以判断文件是否删除以及是否新上传的文件
|
||||||
}
|
}
|
||||||
parseRequestBodyResult = parseRequestBodyFiles(res.request.body, [], [], [], copyFilesMap); // 解析请求体中的文件,将详情中的文件 id 集合收集,更新时以判断文件是否删除以及是否新上传的文件
|
|
||||||
}
|
}
|
||||||
let { request } = res;
|
let { request } = res;
|
||||||
if (isDebugMock) {
|
if (isDebugMock) {
|
||||||
|
|
|
@ -118,6 +118,7 @@
|
||||||
addCase,
|
addCase,
|
||||||
caseFileCopy,
|
caseFileCopy,
|
||||||
debugCase,
|
debugCase,
|
||||||
|
definitionFileCopy,
|
||||||
getDefinitionDetail,
|
getDefinitionDetail,
|
||||||
getTransferOptionsCase,
|
getTransferOptionsCase,
|
||||||
runCase,
|
runCase,
|
||||||
|
@ -221,6 +222,18 @@
|
||||||
} else {
|
} else {
|
||||||
await getApiDetail();
|
await getApiDetail();
|
||||||
}
|
}
|
||||||
|
if (!isCopy && !record) {
|
||||||
|
// 创建用例需要复制文件
|
||||||
|
let copyFilesMap: Record<string, any> = {};
|
||||||
|
const fileIds = parseRequestBodyFiles(apiDetailInfo.value.request.body, [], [], []).uploadFileIds;
|
||||||
|
if (fileIds.length > 0) {
|
||||||
|
copyFilesMap = await definitionFileCopy({
|
||||||
|
resourceId: apiDetailInfo.value.id as string,
|
||||||
|
fileIds,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
parseRequestBodyFiles(apiDetailInfo.value.request.body, [], [], [], copyFilesMap); // 替换请求文件 id
|
||||||
|
}
|
||||||
// 创建的时候,请求参数为接口定义的请求参数
|
// 创建的时候,请求参数为接口定义的请求参数
|
||||||
environmentId.value = appStore.currentEnvConfig?.id;
|
environmentId.value = appStore.currentEnvConfig?.id;
|
||||||
detailForm.value = {
|
detailForm.value = {
|
||||||
|
@ -238,11 +251,10 @@
|
||||||
: apiDetailInfo.value),
|
: apiDetailInfo.value),
|
||||||
children: apiDetailInfo.value.children ?? apiDetailInfo.value.request.children,
|
children: apiDetailInfo.value.children ?? apiDetailInfo.value.request.children,
|
||||||
};
|
};
|
||||||
let parseRequestBodyResult;
|
|
||||||
// 复制
|
// 复制
|
||||||
if (isCopy) {
|
if (isCopy) {
|
||||||
if (record?.protocol === 'HTTP') {
|
if (record?.protocol === 'HTTP') {
|
||||||
// 复制的步骤需要复制文件
|
// 复制的用例需要复制文件
|
||||||
let copyFilesMap: Record<string, any> = {};
|
let copyFilesMap: Record<string, any> = {};
|
||||||
const fileIds = parseRequestBodyFiles(record.request.body, [], [], []).uploadFileIds;
|
const fileIds = parseRequestBodyFiles(record.request.body, [], [], []).uploadFileIds;
|
||||||
if (fileIds.length > 0) {
|
if (fileIds.length > 0) {
|
||||||
|
@ -251,10 +263,9 @@
|
||||||
fileIds,
|
fileIds,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
parseRequestBodyResult = parseRequestBodyFiles(record.request.body, [], [], [], copyFilesMap); // 解析请求体中的文件,将详情中的文件 id 集合收集,更新时以判断文件是否删除以及是否新上传的文件
|
parseRequestBodyFiles(record.request.body, [], [], [], copyFilesMap); // 替换请求文件 id
|
||||||
detailForm.value = {
|
detailForm.value = {
|
||||||
...cloneDeep(record as RequestParam),
|
...cloneDeep(record as RequestParam),
|
||||||
...parseRequestBodyResult,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
detailForm.value.name = `copy_${record?.name}`;
|
detailForm.value.name = `copy_${record?.name}`;
|
||||||
|
|
Loading…
Reference in New Issue