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,57 +710,73 @@ public class ApiScenarioDataTransferService {
for (ApiScenarioImportDetail importScenario : analysisResult.getInsertApiScenarioData()) {
// 处理步骤里的关联资源文件
importScenario.getSteps().forEach(item -> {
if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API.name())) {
ApiDefinitionDetail apiDetail = replaceScenarioResource.getApi(item.getResourceId());
if (apiDetail != null) {
item.setResourceId(apiDetail.getId());
item.setProjectId(importScenario.getProjectId());
item.setOriginProjectId(apiDetail.getProjectId());
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());
}
} else if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API_CASE.name())) {
ApiTestCaseDTO newData = replaceScenarioResource.getApiCase(item.getResourceId());
if (newData != null) {
item.setResourceId(newData.getId());
item.setProjectId(importScenario.getProjectId());
item.setOriginProjectId(newData.getProjectId());
}
} else if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API_SCENARIO.name())) {
ApiScenarioImportDetail newData = replaceScenarioResource.getApiScenario(item.getResourceId());
if (newData != null) {
item.setResourceId(newData.getId());
item.setProjectId(importScenario.getProjectId());
item.setOriginProjectId(newData.getProjectId());
if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API.name())) {
ApiDefinitionDetail apiDetail = replaceScenarioResource.getApi(item.getResourceId());
if (apiDetail != null) {
item.setResourceId(apiDetail.getId());
item.setProjectId(importScenario.getProjectId());
item.setOriginProjectId(apiDetail.getProjectId());
}
} else if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API_CASE.name())) {
ApiTestCaseDTO newData = replaceScenarioResource.getApiCase(item.getResourceId());
if (newData != null) {
item.setResourceId(newData.getId());
item.setProjectId(importScenario.getProjectId());
item.setOriginProjectId(newData.getProjectId());
}
} else if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API_SCENARIO.name())) {
ApiScenarioImportDetail newData = replaceScenarioResource.getApiScenario(item.getResourceId());
if (newData != null) {
item.setResourceId(newData.getId());
item.setProjectId(importScenario.getProjectId());
item.setOriginProjectId(newData.getProjectId());
}
}
}
});
stepList = children;
}
}
for (ApiScenarioImportDetail updateScenario : analysisResult.getUpdateApiScenarioData()) {
// 处理步骤里的关联资源文件
updateScenario.getSteps().forEach(item -> {
if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API.name())) {
ApiDefinitionDetail apiDetail = replaceScenarioResource.getApi(item.getResourceId());
if (apiDetail != null) {
item.setResourceId(apiDetail.getId());
item.setProjectId(updateScenario.getProjectId());
item.setOriginProjectId(apiDetail.getProjectId());
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());
}
} else if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API_CASE.name())) {
ApiTestCaseDTO newData = replaceScenarioResource.getApiCase(item.getResourceId());
if (newData != null) {
item.setResourceId(newData.getId());
item.setProjectId(updateScenario.getProjectId());
item.setOriginProjectId(newData.getProjectId());
}
} else if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API_SCENARIO.name())) {
ApiScenarioImportDetail newData = replaceScenarioResource.getApiScenario(item.getResourceId());
if (newData != null) {
item.setResourceId(newData.getId());
item.setProjectId(updateScenario.getProjectId());
item.setOriginProjectId(newData.getProjectId());
if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API.name())) {
ApiDefinitionDetail apiDetail = replaceScenarioResource.getApi(item.getResourceId());
if (apiDetail != null) {
item.setResourceId(apiDetail.getId());
item.setProjectId(updateScenario.getProjectId());
item.setOriginProjectId(apiDetail.getProjectId());
}
} else if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API_CASE.name())) {
ApiTestCaseDTO newData = replaceScenarioResource.getApiCase(item.getResourceId());
if (newData != null) {
item.setResourceId(newData.getId());
item.setProjectId(updateScenario.getProjectId());
item.setOriginProjectId(newData.getProjectId());
}
} else if (StringUtils.equalsIgnoreCase(item.getStepType(), ApiScenarioStepType.API_SCENARIO.name())) {
ApiScenarioImportDetail newData = replaceScenarioResource.getApiScenario(item.getResourceId());
if (newData != null) {
item.setResourceId(newData.getId());
item.setProjectId(updateScenario.getProjectId());
item.setOriginProjectId(newData.getProjectId());
}
}
}
});
stepList = children;
}
}
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));
for (ApiDefinitionDetail apiDefinitionDetail : analysisResult.getInsertApiDefinitions()) {
List<BaseTreeNode> insertModuleList = TreeNodeParseUtils.getInsertNodeByPath(modulePathMap, apiDefinitionDetail.getModulePath());
apiDefinitionDetail.setModuleId(modulePathMap.get(apiDefinitionDetail.getModulePath()).getId());
insertModuleList.forEach(item -> item.setProjectId(targetProjectId));
analysisResult.getInsertApiModuleList().addAll(insertModuleList);
}

View File

@ -1849,7 +1849,7 @@ public class ApiScenarioService extends MoveNodeService {
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)) {
List<ApiScenarioStepDTO> childStep = new ArrayList<>();
for (ApiScenarioStepDTO step : refScenarioSteps) {
@ -1858,7 +1858,7 @@ public class ApiScenarioService extends MoveNodeService {
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;

View File

@ -7,7 +7,7 @@
:width="400"
>
<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') }}
<a-tooltip :content="t('apiScenario.export.simple.tooltip')" position="tl">
<icon-question-circle