feat(接口测试): 导入场景请求时场景子步骤复制文件
This commit is contained in:
parent
3f476afcdc
commit
06cd4cc317
|
@ -1218,14 +1218,17 @@
|
|||
if (res.protocol === 'HTTP') {
|
||||
if ((props.step?.copyFromStepId || props.step?.refType === ScenarioStepRefType.COPY) && props.step?.isNew) {
|
||||
// 复制的步骤需要复制文件
|
||||
const fileIds = parseRequestBodyFiles(res.request.body, [], [], []).uploadFileIds;
|
||||
if (fileIds.length > 0) {
|
||||
copyStepFileIdsMap.value = await scenarioCopyStepFiles({
|
||||
copyFromStepId: props.step?.copyFromStepId,
|
||||
resourceId: props.step?.resourceId,
|
||||
stepType: props.step?.stepType,
|
||||
refType: props.step?.refType,
|
||||
isTempFile: false, // 复制未保存的步骤时 true
|
||||
fileIds: parseRequestBodyFiles(res.request.body, [], [], []).uploadFileIds,
|
||||
fileIds,
|
||||
});
|
||||
}
|
||||
parseRequestBodyFiles(res.request.body, [], [], [], copyStepFileIdsMap.value);
|
||||
} else {
|
||||
parseRequestBodyResult = parseRequestBodyFiles(res.request.body, [], [], [], copyStepFileIdsMap.value); // 解析请求体中的文件,将详情中的文件 id 集合收集,更新时以判断文件是否删除以及是否新上传的文件
|
||||
|
|
|
@ -269,7 +269,12 @@
|
|||
|
||||
import { getPluginScript, getProtocolList } from '@/api/modules/api-test/common';
|
||||
import { getCaseDetail } from '@/api/modules/api-test/management';
|
||||
import { getTransferOptions, stepTransferFile, uploadTempFile } from '@/api/modules/api-test/scenario';
|
||||
import {
|
||||
getTransferOptions,
|
||||
scenarioCopyStepFiles,
|
||||
stepTransferFile,
|
||||
uploadTempFile,
|
||||
} from '@/api/modules/api-test/scenario';
|
||||
import { useAppStore } from '@/store';
|
||||
import { characterLimit } from '@/utils';
|
||||
import { scrollIntoView } from '@/utils/dom';
|
||||
|
@ -400,6 +405,7 @@
|
|||
errorMessageInfo: {},
|
||||
};
|
||||
const requestVModel = ref<RequestParam>(defaultApiParams);
|
||||
const copyStepFileIdsMap = ref<Record<string, any>>({});
|
||||
const _stepType = computed(() => {
|
||||
if (activeStep.value) {
|
||||
return getStepType(activeStep.value);
|
||||
|
@ -799,7 +805,8 @@
|
|||
requestVModel.value.body,
|
||||
undefined,
|
||||
props.fileParams?.uploadFileIds || requestVModel.value.uploadFileIds, // 外面解析详情的时候传入,或引用 case 在requestVModel内存储
|
||||
props.fileParams?.linkFileIds || requestVModel.value.linkFileIds // 外面解析详情的时候传入,或引用 case 在requestVModel内存储
|
||||
props.fileParams?.linkFileIds || requestVModel.value.linkFileIds, // 外面解析详情的时候传入,或引用 case 在requestVModel内存储
|
||||
copyStepFileIdsMap.value
|
||||
);
|
||||
}
|
||||
requestParams = {
|
||||
|
@ -989,7 +996,26 @@
|
|||
const res = await getCaseDetail(activeStep.value?.resourceId || '');
|
||||
let parseRequestBodyResult;
|
||||
if (res.protocol === 'HTTP') {
|
||||
parseRequestBodyResult = parseRequestBodyFiles(res.request.body); // 解析请求体中的文件,将详情中的文件 id 集合收集,更新时以判断文件是否删除以及是否新上传的文件
|
||||
if (
|
||||
(activeStep.value?.copyFromStepId || activeStep.value?.refType === ScenarioStepRefType.COPY) &&
|
||||
activeStep.value?.isNew
|
||||
) {
|
||||
// 复制的步骤需要复制文件
|
||||
const fileIds = parseRequestBodyFiles(res.request.body, [], [], []).uploadFileIds;
|
||||
if (fileIds.length > 0) {
|
||||
copyStepFileIdsMap.value = await scenarioCopyStepFiles({
|
||||
copyFromStepId: activeStep.value?.copyFromStepId,
|
||||
resourceId: activeStep.value?.resourceId,
|
||||
stepType: activeStep.value?.stepType,
|
||||
refType: activeStep.value?.refType,
|
||||
isTempFile: false, // 复制未保存的步骤时 true
|
||||
fileIds,
|
||||
});
|
||||
}
|
||||
parseRequestBodyFiles(res.request.body, [], [], [], copyStepFileIdsMap.value);
|
||||
} else {
|
||||
parseRequestBodyResult = parseRequestBodyFiles(res.request.body, [], [], [], copyStepFileIdsMap.value); // 解析请求体中的文件,将详情中的文件 id 集合收集,更新时以判断文件是否删除以及是否新上传的文件
|
||||
}
|
||||
}
|
||||
requestVModel.value = {
|
||||
responseActiveTab: ResponseComposition.BODY,
|
||||
|
|
|
@ -289,6 +289,7 @@
|
|||
originProjectId: node.projectId,
|
||||
id: node.isQuoteScenarioStep ? node.id : id, // 引用场景下的步骤 id 不变,其他情况的步骤生成新的 id
|
||||
uniqueId: id,
|
||||
isNew: true,
|
||||
};
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -943,14 +943,17 @@
|
|||
if (node.config.protocol === 'HTTP' && (stepDetail as RequestParam)?.body) {
|
||||
if (node.copyFromStepId || node.refType === ScenarioStepRefType.COPY) {
|
||||
// 复制的步骤需要复制文件
|
||||
const fileIds = parseRequestBodyFiles((stepDetail as RequestParam).body, [], [], []).uploadFileIds;
|
||||
if (fileIds.length > 0) {
|
||||
newFileRes = await scenarioCopyStepFiles({
|
||||
copyFromStepId,
|
||||
resourceId: node.resourceId,
|
||||
stepType: node.stepType,
|
||||
refType: node.refType,
|
||||
isTempFile: !!stepDetail, // 复制未保存的步骤时 true
|
||||
fileIds: parseRequestBodyFiles((stepDetail as RequestParam).body, [], [], []).uploadFileIds,
|
||||
fileIds,
|
||||
});
|
||||
}
|
||||
parseRequestBodyFiles((stepDetail as RequestParam).body, [], [], [], newFileRes);
|
||||
} else {
|
||||
parseRequestBodyResult = parseRequestBodyFiles((stepDetail as RequestParam).body, [], [], [], newFileRes); // 解析请求体中的文件,将详情中的文件 id 集合收集,更新时以判断文件是否删除以及是否新上传的文件
|
||||
|
|
|
@ -68,14 +68,17 @@ export default function useStepOperation({
|
|||
if (step.config.protocol === 'HTTP' && res.body) {
|
||||
if ((step.copyFromStepId || step.refType === ScenarioStepRefType.COPY) && step.isNew) {
|
||||
// 复制的步骤需要复制文件
|
||||
const fileIds = parseRequestBodyFiles((res as RequestParam).body, [], [], []).uploadFileIds;
|
||||
if (fileIds.length > 0) {
|
||||
newFileRes = await scenarioCopyStepFiles({
|
||||
copyFromStepId: step.copyFromStepId,
|
||||
resourceId: step.resourceId,
|
||||
stepType: step.stepType,
|
||||
refType: step.refType,
|
||||
isTempFile: false, // 复制未保存的步骤时 true
|
||||
fileIds: parseRequestBodyFiles((res as RequestParam).body, [], [], []).uploadFileIds,
|
||||
fileIds,
|
||||
});
|
||||
}
|
||||
parseRequestBodyFiles(res.body, [], [], [], newFileRes);
|
||||
} else {
|
||||
parseRequestBodyResult = parseRequestBodyFiles(res.body, [], [], [], newFileRes); // 解析请求体中的文件,将详情中的文件 id 集合收集,更新时以判断文件是否删除以及是否新上传的文件
|
||||
|
|
Loading…
Reference in New Issue