fix(接口测试): 场景请求步骤另存为新接口修复

This commit is contained in:
baiqi 2024-08-19 11:40:18 +08:00 committed by 刘瑞斌
parent b6d56982c4
commit 12a9508283
2 changed files with 79 additions and 68 deletions

View File

@ -148,7 +148,6 @@
/**
* 保存请求
* @param isSaveCase 是否需要保存用例
*/
async function realSaveAsApi() {
try {

View File

@ -903,75 +903,83 @@
}
}
function handleStepMoreActionSelect(item: ActionsItem, node: MsTreeNodeData) {
/**
* 复制步骤
* @param node 复制的节点
*/
function copyStep(node: MsTreeNodeData) {
const id = getGenerateId();
const stepDetail = stepDetails.value[node.id];
const stepFileParam = scenario.value.stepFileParam[node.id];
const { isQuoteScenario } = getStepType(node as ScenarioStepItem);
if (stepDetail) {
//
stepDetails.value[id] = cloneDeep({
...stepDetail,
stepId: id,
uniqueId: id,
});
}
if (stepFileParam) {
//
scenario.value.stepFileParam[id] = cloneDeep(stepFileParam);
}
insertNodes<ScenarioStepItem>(
steps.value,
node.uniqueId,
{
...cloneDeep(
mapTree<ScenarioStepItem>(node, (childNode) => {
const childId = getGenerateId();
const childStepDetail = stepDetails.value[childNode.id];
const childStepFileParam = scenario.value.stepFileParam[childNode.id];
let childCopyFromStepId = childNode.id;
if (childStepDetail) {
//
stepDetails.value[childId] = cloneDeep(childStepDetail);
}
if (childStepFileParam) {
//
scenario.value.stepFileParam[childNode.id] = cloneDeep(childStepFileParam);
}
if (!isQuoteScenario) {
// id
if (childStepDetail || (childNode.isNew && childNode.stepRefType === ScenarioStepRefType.REF)) {
// id
// id
childCopyFromStepId = childNode.id;
} else if (childNode.isNew && childNode.stepRefType === ScenarioStepRefType.COPY) {
// id
childCopyFromStepId = childNode.copyFromStepId;
}
}
return {
...cloneDeep(childNode),
executeStatus: undefined,
copyFromStepId: childCopyFromStepId,
id: childId,
uniqueId: childId,
};
})[0]
),
name: `copy_${node.name}`.substring(0, 255),
copyFromStepId: stepDetail || node.isNew !== true ? node.id : node.copyFromStepId,
sort: node.sort + 1,
isNew: true,
id,
uniqueId: id,
},
'after',
selectedIfNeed,
'uniqueId'
);
scenario.value.unSaved = true;
}
async function handleStepMoreActionSelect(item: ActionsItem, node: MsTreeNodeData) {
switch (item.eventTag) {
case 'copy':
const id = getGenerateId();
const stepDetail = stepDetails.value[node.id];
const stepFileParam = scenario.value.stepFileParam[node.id];
const { isQuoteScenario } = getStepType(node as ScenarioStepItem);
if (stepDetail) {
//
stepDetails.value[id] = cloneDeep({
...stepDetail,
stepId: id,
uniqueId: id,
});
}
if (stepFileParam) {
//
scenario.value.stepFileParam[id] = cloneDeep(stepFileParam);
}
insertNodes<ScenarioStepItem>(
steps.value,
node.uniqueId,
{
...cloneDeep(
mapTree<ScenarioStepItem>(node, (childNode) => {
const childId = getGenerateId();
const childStepDetail = stepDetails.value[childNode.id];
const childStepFileParam = scenario.value.stepFileParam[childNode.id];
let childCopyFromStepId = childNode.id;
if (childStepDetail) {
//
stepDetails.value[childId] = cloneDeep(childStepDetail);
}
if (childStepFileParam) {
//
scenario.value.stepFileParam[childNode.id] = cloneDeep(childStepFileParam);
}
if (!isQuoteScenario) {
// id
if (childStepDetail || (childNode.isNew && childNode.stepRefType === ScenarioStepRefType.REF)) {
// id
// id
childCopyFromStepId = childNode.id;
} else if (childNode.isNew && childNode.stepRefType === ScenarioStepRefType.COPY) {
// id
childCopyFromStepId = childNode.copyFromStepId;
}
}
return {
...cloneDeep(childNode),
executeStatus: undefined,
copyFromStepId: childCopyFromStepId,
id: childId,
uniqueId: childId,
};
})[0]
),
name: `copy_${node.name}`.substring(0, 255),
copyFromStepId: stepDetail || node.isNew !== true ? node.id : node.copyFromStepId,
sort: node.sort + 1,
isNew: true,
id,
uniqueId: id,
},
'after',
selectedIfNeed,
'uniqueId'
);
scenario.value.unSaved = true;
copyStep(node);
break;
case 'config':
activeStep.value = node as ScenarioStepItem;
@ -1005,6 +1013,10 @@
break;
case 'saveAsApi':
activeStep.value = node as ScenarioStepItem;
if (!stepDetails.value[activeStep.value.id]) {
//
await getStepDetail(activeStep.value);
}
const detail = stepDetails.value[activeStep.value.id] as RequestParam;
const fileParams = scenario.value.stepFileParam[activeStep.value.id];
tempApiDetail.value = {