feat(用例管理): 测试计划脑图最终结果节点

This commit is contained in:
guoyuqi 2024-08-08 19:55:44 +08:00 committed by Craftsman
parent 455a85e98e
commit d7d10f5f05
6 changed files with 23 additions and 13 deletions

View File

@ -21,6 +21,8 @@ public class FunctionalCaseManageInterceptor {
configList.add(new MybatisInterceptorConfig(FunctionalCaseMindDTO.class, "expectedResult", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(FunctionalCaseMindDTO.class, "prerequisite", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(FunctionalCaseMindDTO.class, "description", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(FunctionalCaseMindDTO.class, "content", CompressUtils.class, "zip", "unzip"));
return configList;
}

View File

@ -78,5 +78,6 @@ public class FunctionalCaseMindDTO {
@Schema(description = "备注")
private byte[] description;
@Schema(description = "执行评论")
private byte[] content;
}

View File

@ -880,12 +880,12 @@
fc.name as name,
fc.id as caseId,
fc.project_id, fc.template_id, fc.pos, fc.case_edit_type,
IFNULL(history.`steps`, fcb.steps) as steps, execute_history.`steps` as executeSteps, fcb.text_description, fcb.expected_result, fcb.prerequisite, fcb.description
IFNULL(history.`steps`, fcb.steps) as steps, execute_history.`steps` as executeSteps, fcb.text_description, fcb.expected_result, fcb.prerequisite, fcb.description, history.`content`
FROM
test_plan_functional_case tpfc
LEFT JOIN functional_case fc ON tpfc.functional_case_id = fc.id
LEFT JOIN functional_case_blob fcb ON fcb.id = fc.id
LEFT JOIN (select * from (SELECT tpceh.test_plan_case_id, tpceh.`status`,tpceh.`steps`, ROW_NUMBER() OVER (PARTITION BY tpceh.test_plan_case_id ORDER BY tpceh.create_time DESC) as rn from test_plan_case_execute_history tpceh where tpceh.test_plan_id = #{request.planId} and tpceh.deleted = false
LEFT JOIN (select * from (SELECT tpceh.test_plan_case_id, tpceh.`status`,tpceh.`steps`, tpceh.`content`, ROW_NUMBER() OVER (PARTITION BY tpceh.test_plan_case_id ORDER BY tpceh.create_time DESC) as rn from test_plan_case_execute_history tpceh where tpceh.test_plan_id = #{request.planId} and tpceh.deleted = false
order by tpceh.create_time desc ) as history_filter WHERE rn = 1 ) as history ON history.test_plan_case_id = tpfc.id
LEFT JOIN (select * from (SELECT tpceh.test_plan_case_id, tpceh.`status`,tpceh.`steps`, ROW_NUMBER() OVER (PARTITION BY tpceh.test_plan_case_id ORDER BY tpceh.create_time DESC) as rn from test_plan_case_execute_history tpceh where tpceh.test_plan_id = #{request.planId} and tpceh.deleted = false and tpceh.steps IS NOT NULL

View File

@ -310,16 +310,15 @@ public class FunctionalCaseFileService {
if (StringUtils.isEmpty(request.getVersionId())) {
request.setVersionId(extBaseProjectVersionMapper.getDefaultVersion(request.getProjectId()));
}
Long nextPos = functionalCaseService.getNextOrder(request.getProjectId());
Long lasePos = nextPos + ((long) ServiceUtils.POS_STEP * Integer.parseInt(request.getCount()));
Long lasePos = 0L;
//获取当前项目默认模板的自定义字段
List<TemplateCustomFieldDTO> customFields = getCustomFields(request.getProjectId());
XMindCaseParser xMindParser = new XMindCaseParser(request, customFields, user, lasePos);
errList = xMindParser.parse(multipartFile);
xMindParser.clear();
response.setErrorMessages(errList);
response.setSuccessCount(xMindParser.getList().size() + xMindParser.getUpdateList().size());
response.setFailCount(errList.size());
xMindParser.clear();
return response;
} catch (Exception e) {
LogUtils.error("checkImportExcel error", e);
@ -393,10 +392,10 @@ public class FunctionalCaseFileService {
errList.add(excelErrData);
}
xmindParser.saveData();
xmindParser.clear();
response.setErrorMessages(errList);
response.setSuccessCount(xmindParser.getList().size() + xmindParser.getUpdateList().size());
response.setFailCount(errList.size());
xmindParser.clear();
return response;
} catch (Exception e) {
LogUtils.error("checkImportExcel error", e);

View File

@ -252,6 +252,16 @@ public class FunctionalCaseMinderService {
children.add(descriptionFunctionalMinderTreeDTO);
}
}
if (addActualResult) {
String contentText = StringUtils.EMPTY;
if (functionalCaseMindDTO.getContent() != null ) {
contentText = new String(functionalCaseMindDTO.getContent(), StandardCharsets.UTF_8);
}
FunctionalMinderTreeDTO contentFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(StringUtils.isBlank(contentText) ? StringUtils.EMPTY : contentText, Translator.get("minder_extra_node.steps_actual_result"), (long) (i + 1));
children.add(contentFunctionalMinderTreeDTO);
}
return children;
}

View File

@ -1,10 +1,7 @@
package io.metersphere.functional.controller;
import io.metersphere.functional.domain.*;
import io.metersphere.functional.dto.CaseCustomFieldDTO;
import io.metersphere.functional.dto.FunctionalCaseStepDTO;
import io.metersphere.functional.dto.FunctionalMinderTreeDTO;
import io.metersphere.functional.dto.MinderOptionDTO;
import io.metersphere.functional.dto.*;
import io.metersphere.functional.mapper.*;
import io.metersphere.functional.request.*;
import io.metersphere.plan.domain.TestPlanCaseExecuteHistory;
@ -413,6 +410,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
@Test
@Order(5)
public void testGetCasePlanList() throws Exception {
String content = "执行评论";
FunctionalCasePlanMindRequest request = new FunctionalCasePlanMindRequest();
request.setProjectId("project-case-minder-test");
request.setModuleId("TEST_MINDER_MODULE_ID_GYQ4");
@ -443,6 +441,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
functionalCaseStepDTO.setExecuteResult("BLOCKED");
list.add(functionalCaseStepDTO);
executeHistory.setSteps(JSON.toJSONString(list).getBytes(StandardCharsets.UTF_8));
executeHistory.setContent(content.getBytes());
executeHistory.setDeleted(false);
executeHistory.setNotifier("admin");
executeHistory.setCreateUser("admin");
@ -450,14 +449,13 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
testPlanCaseExecuteHistoryMapper.insert(executeHistory);
TestPlanCaseExecuteHistory testPlanCaseExecuteHistory = testPlanCaseExecuteHistoryMapper.selectByPrimaryKey(nextStr);
Assertions.assertNotNull(testPlanCaseExecuteHistory);
String prerequisiteText = new String(testPlanCaseExecuteHistory.getSteps(), StandardCharsets.UTF_8);
MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_PLAN_LIST_URL, request);
Pager<List<FunctionalMinderTreeDTO>> tableData = JSON.parseObject(JSON.toJSONString(
JSON.parseObject(mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
Pager.class);
Assertions.assertNotNull(tableData.getList());
Assertions.assertEquals(2, tableData.getList().size());
// System.out.println(JSON.toJSONString(tableData.getList()));
//System.out.println(JSON.toJSONString(tableData.getList()));
}
}