Skip to content

Commit

Permalink
feat(测试计划): 新增测试计划详情页功能用例脑图接口
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomeinvG authored and fit2-zhao committed May 23, 2024
1 parent 74edb30 commit 41a2a37
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.metersphere.functional.dto.FunctionalMinderTreeDTO;
import io.metersphere.functional.request.FunctionalCaseMindRequest;
import io.metersphere.functional.request.FunctionalCaseMinderEditRequest;
import io.metersphere.functional.request.FunctionalCasePlanMindRequest;
import io.metersphere.functional.request.FunctionalCaseReviewMindRequest;
import io.metersphere.functional.service.FunctionalCaseMinderService;
import io.metersphere.sdk.constants.PermissionConstants;
Expand Down Expand Up @@ -69,4 +70,12 @@ public List<FunctionalMinderTreeDTO> getReviewMindFunctionalCase(@Validated @Req
return functionalCaseMinderService.getReviewMindFunctionalCase(request, false, userId, viewStatusUserId);
}

@PostMapping("/plan/list")
@Operation(summary = "测试计划-功能用例-脑图用例跟根据模块ID查询列表")
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_MINDER)
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
public List<FunctionalMinderTreeDTO> getPlanFunctionalCaseMinderTree(@Validated @RequestBody FunctionalCasePlanMindRequest request) {
return functionalCaseMinderService.getPlanMindFunctionalCase(request, false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import io.metersphere.dto.TestCaseProviderDTO;
import io.metersphere.functional.domain.FunctionalCase;
import io.metersphere.functional.dto.*;
import io.metersphere.functional.request.FunctionalCaseBatchMoveRequest;
import io.metersphere.functional.request.FunctionalCaseMindRequest;
import io.metersphere.functional.request.FunctionalCasePageRequest;
import io.metersphere.functional.request.FunctionalCaseReviewMindRequest;
import io.metersphere.functional.request.*;
import io.metersphere.project.dto.ModuleCountDTO;
import io.metersphere.request.AssociateOtherCaseRequest;
import io.metersphere.request.TestCasePageProviderRequest;
Expand Down Expand Up @@ -90,4 +87,7 @@ public interface ExtFunctionalCaseMapper {
*/
List<FunctionalCaseMindDTO> getMinderCaseReviewList(@Param("request") FunctionalCaseReviewMindRequest request, @Param("deleted") boolean delete, @Param("userId") String userId, @Param("viewStatusUserId") String viewStatusUserId);

List<FunctionalCaseMindDTO> getMinderTestPlanList(@Param("request") FunctionalCasePlanMindRequest request, @Param("deleted") boolean delete);


}
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@

<select id="getMinderCaseReviewList" resultType="io.metersphere.functional.dto.FunctionalCaseMindDTO">
SELECT
crfc.case_id as id,
crfc.id as id,
history.`status` as status,
fc.module_id as moduleId,
fc.name as name,
Expand Down Expand Up @@ -845,4 +845,32 @@
AND cf.internal= true
</select>

<select id="getMinderTestPlanList" resultType="io.metersphere.functional.dto.FunctionalCaseMindDTO">
SELECT
tpfc.id as id,
history.`status` as status,
fc.module_id as moduleId,
fc.name as name,
fcb.steps, fcb.expected_result, fcb.prerequisite, fcb.description, fccf.value as priority
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 functional_case_custom_field fccf ON fccf.case_id = fc.id
LEFT JOIN custom_field cf ON cf.id = fccf.field_id
LEFT JOIN ( SELECT GROUP_CONCAT(DISTINCT tpceh.test_plan_case_id) AS test_plan_case_id, tpceh.`status` from test_plan_case_execute_history tpceh where tpceh.test_plan_id = #{request.planId}
GROUP BY test_plan_case_id order by tpceh.create_time desc ) as history ON history.test_plan_case_id = tpfc.id
WHERE
tpfc.test_plan_id = #{request.planId}
AND fc.deleted = #{deleted}
AND
fc.project_Id = #{request.projectId}
AND
fc.module_id = #{request.moduleId}
AND
cf.name = 'functional_priority'
AND cf.scene = 'FUNCTIONAL'
AND cf.internal= true
</select>

</mapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.metersphere.functional.request;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;

@Data
public class FunctionalCasePlanMindRequest extends FunctionalCaseMindRequest {

@Schema(description = "测试计划id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{test_plan_functional_case.test_plan_id.not_blank}")
private String planId;


}
Original file line number Diff line number Diff line change
Expand Up @@ -782,4 +782,14 @@ public List<FunctionalMinderTreeDTO> getReviewMindFunctionalCase(FunctionalCaseR
}


public List<FunctionalMinderTreeDTO> getPlanMindFunctionalCase(FunctionalCasePlanMindRequest request, boolean deleted) {
List<FunctionalMinderTreeDTO> list = new ArrayList<>();
//查出当前模块下的所有用例
List<FunctionalCaseMindDTO> functionalCaseMindDTOList = extFunctionalCaseMapper.getMinderTestPlanList(request, deleted);
//构造父子级数据
buildList(functionalCaseMindDTOList, list);
return list;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
//评审
public static final String FUNCTIONAL_CASE_REVIEW_LIST_URL = "/functional/mind/case/review/list";

//测试计划
public static final String FUNCTIONAL_CASE_PLAN_LIST_URL = "/functional/mind/case/plan/list";



@Resource
private FunctionalCaseBlobMapper functionalCaseBlobMapper;
Expand Down Expand Up @@ -261,4 +265,20 @@ public void testGetCaseReviewList() throws Exception {
Assertions.assertEquals(1, baseTreeNodes.size());
}

@Test
@Order(4)
public void testGetCasePlanList() throws Exception {
FunctionalCasePlanMindRequest request = new FunctionalCasePlanMindRequest();
request.setProjectId("project-case-minder-test");
request.setModuleId("TEST_MINDER_MODULE_ID_GYQ4");
request.setPlanId("TEST_MINDER_PLAN_ID_1");
MvcResult mvcResultPage = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_PLAN_LIST_URL, request);
String contentAsString = mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
List<FunctionalMinderTreeDTO> baseTreeNodes = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), FunctionalMinderTreeDTO.class);
Assertions.assertNotNull(baseTreeNodes);
Assertions.assertEquals(2, baseTreeNodes.size());
System.out.println(baseTreeNodes);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ VALUES
;


INSERT INTO test_plan(id, num, project_id, group_id, module_id, name, status, type, tags, create_time, create_user, update_time, update_user, planned_start_time, planned_end_time, actual_start_time, actual_end_time, description)
VALUE ('TEST_MINDER_PLAN_ID_1', 1000, 'project-case-minder-test', 'none', 'TEST_MINDER_PLAN_MODULE', '脑图测试计划', 'PREPARED', 'TEST_PLAN', null, 1669174143999, 'admin', 1669174143999, 'admin', null, null, null,null,null);

INSERT INTO test_plan_functional_case(id, test_plan_id, functional_case_id, create_time, create_user, execute_user, last_exec_time, last_exec_result, pos)
VALUES ('test_plan_functional_case_minder_id1', 'TEST_MINDER_PLAN_ID_1', 'TEST_FUNCTIONAL_MINDER_CASE_ID_5', 1669174143999, 'admin', 'admin', 1669174143999, 'SUCCESS', 5000),
('test_plan_functional_case_minder_id2', 'TEST_MINDER_PLAN_ID_1', 'TEST_FUNCTIONAL_MINDER_CASE_ID_5', 1669174143999, 'admin', 'admin', 1669174143999, 'SUCCESS', 10000);

INSERT INTO custom_field (id, name, scene, type, remark, internal, scope_type, create_time, update_time, create_user, scope_id) VALUES
('custom_field_minder_gyq_id_2', 'functional_priority', 'FUNCTIONAL', 'SELECT', '', true, 'ORGANIZATION', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', '100001'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,13 @@
dialogLoading.value = false;
resetSelector();
loadList();
emit('refresh', tableParams.value);
emit('refresh', {
...tableParams.value,
current: propsRes.value.msPagination?.current,
pageSize: propsRes.value.msPagination?.pageSize,
total: propsRes.value.msPagination?.total,
moduleIds: [],
});
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
Expand Down Expand Up @@ -680,7 +686,13 @@
Message.success(t('common.updateSuccess'));
dialogVisible.value = false;
resetSelector();
emit('refresh', tableParams.value);
emit('refresh', {
...tableParams.value,
current: propsRes.value.msPagination?.current,
pageSize: propsRes.value.msPagination?.pageSize,
total: propsRes.value.msPagination?.total,
moduleIds: [],
});
loadList();
} catch (error) {
// eslint-disable-next-line no-console
Expand Down Expand Up @@ -741,7 +753,13 @@
Message.success(t('caseManagement.caseReview.reviewSuccess'));
dialogVisible.value = false;
resetSelector();
emit('refresh', tableParams.value);
emit('refresh', {
...tableParams.value,
current: propsRes.value.msPagination?.current,
pageSize: propsRes.value.msPagination?.pageSize,
total: propsRes.value.msPagination?.total,
moduleIds: [],
});
loadList();
} catch (error) {
// eslint-disable-next-line no-console
Expand Down

0 comments on commit 41a2a37

Please sign in to comment.