fix(接口测试): 测试计划用例单独执行,没有出现在任务中心

--bug=1047999 --user=陈建星 【系统设置】系统-任务中心-用例执行任务/用例执行任务详情列表-在测试计划内单独执行用例/场景-任务列表未显示该任务 https://www.tapd.cn/55049933/s/1597730
This commit is contained in:
AgAngle 2024-10-25 11:47:34 +08:00 committed by Craftsman
parent 182c50fad1
commit 9250df2205
3 changed files with 62 additions and 45 deletions

View File

@ -710,7 +710,13 @@ public class ApiScenarioDataTransferService {
for (ApiScenarioImportDetail importScenario : analysisResult.getInsertApiScenarioData()) { for (ApiScenarioImportDetail importScenario : analysisResult.getInsertApiScenarioData()) {
// 处理步骤里的关联资源文件 // 处理步骤里的关联资源文件
importScenario.getSteps().forEach(item -> { List<ApiScenarioStepRequest> stepList = importScenario.getSteps();
while (CollectionUtils.isNotEmpty(stepList)) {
List<ApiScenarioStepRequest> children = new ArrayList<>();
for (ApiScenarioStepRequest item : stepList) {
if (CollectionUtils.isNotEmpty(item.getChildren())) {
children.addAll(item.getChildren());
}
if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API.name())) { if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API.name())) {
ApiDefinitionDetail apiDetail = replaceScenarioResource.getApi(item.getResourceId()); ApiDefinitionDetail apiDetail = replaceScenarioResource.getApi(item.getResourceId());
if (apiDetail != null) { if (apiDetail != null) {
@ -733,11 +739,19 @@ public class ApiScenarioDataTransferService {
item.setOriginProjectId(newData.getProjectId()); item.setOriginProjectId(newData.getProjectId());
} }
} }
}); }
stepList = children;
}
} }
for (ApiScenarioImportDetail updateScenario : analysisResult.getUpdateApiScenarioData()) { for (ApiScenarioImportDetail updateScenario : analysisResult.getUpdateApiScenarioData()) {
// 处理步骤里的关联资源文件 // 处理步骤里的关联资源文件
updateScenario.getSteps().forEach(item -> { List<ApiScenarioStepRequest> stepList = updateScenario.getSteps();
while (CollectionUtils.isNotEmpty(stepList)) {
List<ApiScenarioStepRequest> children = new ArrayList<>();
for (ApiScenarioStepRequest item : stepList) {
if (CollectionUtils.isNotEmpty(item.getChildren())) {
children.addAll(item.getChildren());
}
if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API.name())) { if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API.name())) {
ApiDefinitionDetail apiDetail = replaceScenarioResource.getApi(item.getResourceId()); ApiDefinitionDetail apiDetail = replaceScenarioResource.getApi(item.getResourceId());
if (apiDetail != null) { if (apiDetail != null) {
@ -760,7 +774,9 @@ public class ApiScenarioDataTransferService {
item.setOriginProjectId(newData.getProjectId()); item.setOriginProjectId(newData.getProjectId());
} }
} }
}); }
stepList = children;
}
} }
return analysisResult; return analysisResult;
} }
@ -852,6 +868,7 @@ public class ApiScenarioDataTransferService {
Map<String, BaseTreeNode> modulePathMap = apiModules.stream().collect(Collectors.toMap(BaseTreeNode::getPath, k -> k, (k1, k2) -> k1)); Map<String, BaseTreeNode> modulePathMap = apiModules.stream().collect(Collectors.toMap(BaseTreeNode::getPath, k -> k, (k1, k2) -> k1));
for (ApiDefinitionDetail apiDefinitionDetail : analysisResult.getInsertApiDefinitions()) { for (ApiDefinitionDetail apiDefinitionDetail : analysisResult.getInsertApiDefinitions()) {
List<BaseTreeNode> insertModuleList = TreeNodeParseUtils.getInsertNodeByPath(modulePathMap, apiDefinitionDetail.getModulePath()); List<BaseTreeNode> insertModuleList = TreeNodeParseUtils.getInsertNodeByPath(modulePathMap, apiDefinitionDetail.getModulePath());
apiDefinitionDetail.setModuleId(modulePathMap.get(apiDefinitionDetail.getModulePath()).getId());
insertModuleList.forEach(item -> item.setProjectId(targetProjectId)); insertModuleList.forEach(item -> item.setProjectId(targetProjectId));
analysisResult.getInsertApiModuleList().addAll(insertModuleList); analysisResult.getInsertApiModuleList().addAll(insertModuleList);
} }

View File

@ -1849,7 +1849,7 @@ public class ApiScenarioService extends MoveNodeService {
returnList.addAll(this.parseConfig(steps, null)); returnList.addAll(this.parseConfig(steps, null));
} }
List<ApiScenarioStepDTO> refScenarioSteps = steps.stream().filter(this::isRefOrPartialScenario).toList(); List<ApiScenarioStepDTO> refScenarioSteps = steps.stream().filter(k -> isScenarioStep(k.getStepType())).toList();
while (CollectionUtils.isNotEmpty(refScenarioSteps)) { while (CollectionUtils.isNotEmpty(refScenarioSteps)) {
List<ApiScenarioStepDTO> childStep = new ArrayList<>(); List<ApiScenarioStepDTO> childStep = new ArrayList<>();
for (ApiScenarioStepDTO step : refScenarioSteps) { for (ApiScenarioStepDTO step : refScenarioSteps) {
@ -1858,7 +1858,7 @@ public class ApiScenarioService extends MoveNodeService {
returnList.addAll(this.parseConfig(childStep, step.getId())); returnList.addAll(this.parseConfig(childStep, step.getId()));
} }
} }
refScenarioSteps = childStep.stream().filter(this::isRefOrPartialScenario).toList(); refScenarioSteps = childStep.stream().filter(k -> isScenarioStep(k.getStepType())).toList();
} }
// 嵌套获取引用的场景步骤 // 嵌套获取引用的场景步骤
return returnList; return returnList;

View File

@ -7,7 +7,7 @@
:width="400" :width="400"
> >
<div class="mb-[16px] flex items-center gap-[8px]"> <div class="mb-[16px] flex items-center gap-[8px]">
<a-switch v-model:model-value="exportTypeRadio" type="line" size="small"></a-switch> <a-switch v-model:model-value="exportTypeRadio" size="small"></a-switch>
{{ t('apiScenario.export.type.all') }} {{ t('apiScenario.export.type.all') }}
<a-tooltip :content="t('apiScenario.export.simple.tooltip')" position="tl"> <a-tooltip :content="t('apiScenario.export.simple.tooltip')" position="tl">
<icon-question-circle <icon-question-circle