feat(接口测试): 接口&用例复制文件

This commit is contained in:
baiqi 2024-12-13 14:42:16 +08:00 committed by Craftsman
parent f20fff9b9f
commit 598bcadf94
2 changed files with 19 additions and 6 deletions

View File

@ -380,13 +380,15 @@
//
let copyFilesMap: Record<string, any> = {};
const fileIds = parseRequestBodyFiles(res.request.body, [], [], []).uploadFileIds;
if (fileIds.length > 0) {
if (fileIds.length > 0 && isCopy) {
copyFilesMap = await definitionFileCopy({
resourceId: typeof apiInfo === 'string' ? apiInfo : apiInfo.id,
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;
if (isDebugMock) {

View File

@ -118,6 +118,7 @@
addCase,
caseFileCopy,
debugCase,
definitionFileCopy,
getDefinitionDetail,
getTransferOptionsCase,
runCase,
@ -221,6 +222,18 @@
} else {
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;
detailForm.value = {
@ -238,11 +251,10 @@
: apiDetailInfo.value),
children: apiDetailInfo.value.children ?? apiDetailInfo.value.request.children,
};
let parseRequestBodyResult;
//
if (isCopy) {
if (record?.protocol === 'HTTP') {
//
//
let copyFilesMap: Record<string, any> = {};
const fileIds = parseRequestBodyFiles(record.request.body, [], [], []).uploadFileIds;
if (fileIds.length > 0) {
@ -251,10 +263,9 @@
fileIds,
});
}
parseRequestBodyResult = parseRequestBodyFiles(record.request.body, [], [], [], copyFilesMap); // id
parseRequestBodyFiles(record.request.body, [], [], [], copyFilesMap); // id
detailForm.value = {
...cloneDeep(record as RequestParam),
...parseRequestBodyResult,
};
}
detailForm.value.name = `copy_${record?.name}`;