fix(接口测试): 修复接口场景中引用的场景更新了但是报告却没有变化的问题

--bug=1022856 --user=宋天阳
【接口测试】github#21635,A场景中引用方式导入B场景,如B场景内容发送修改,批量执行或测试计划执行A场景时,测试报告中的B场景还是老内容
https://www.tapd.cn/55049933/s/1334688
This commit is contained in:
song-tianyang 2023-02-13 16:56:18 +08:00 committed by 建国
parent 003a329cb4
commit d0b468071b
1 changed files with 6 additions and 1 deletions

View File

@ -16,6 +16,8 @@ import io.metersphere.constants.RunModeConstants;
import io.metersphere.dto.RequestResult;
import io.metersphere.dto.RunModeConfigDTO;
import io.metersphere.service.BaseTestResourcePoolService;
import io.metersphere.service.MsHashTreeService;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.BooleanUtils;
@ -26,7 +28,6 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
@ -159,6 +160,10 @@ public class ApiScenarioReportStructureService {
public static StepTreeDTO dataFormatting(String id, String name, String scenarioDefinition, String reportType) {
JSONObject element = JSONUtil.parseObject(scenarioDefinition);
if (element != null && element.getBoolean(ENABLE)) {
//保证场景的步骤是最新的比如场景中包含引用场景
MsHashTreeService hashTreeService = CommonBeanFactory.getBean(MsHashTreeService.class);
assert hashTreeService != null;
hashTreeService.dataFormatting(element);
String resourceId = combinationResourceId(element, reportType, id);
StepTreeDTO dto = new StepTreeDTO(name, resourceId, element.optString(TYPE), resourceId, 1);
dto.setAllIndex(null);