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