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> = {}; 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) {

View File

@ -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}`;