Skip to content

Commit 43b91cd

Browse files
committed
Feat 게시글 상세 페이지 TC 작성
1 parent a8e5445 commit 43b91cd

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

back/src/test/java/com/back/domain/post/post/controller/InformationPostControllerTest.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,4 +530,51 @@ void t17() throws Exception {
530530
.andExpect(jsonPath("$.msg").value("게시글 좋아요 성공"));
531531
}
532532

533+
@Test
534+
@DisplayName("게시글 상세 조회 성공")
535+
void t18() throws Exception {
536+
537+
// 좋아요 추가하여 좋아요 정보도 함께 조회되는지 확인
538+
mvc.perform(post("/post/infor/{post_id}/liked", 1L));
539+
540+
ResultActions resultActions = mvc
541+
.perform(
542+
get("/post/infor/Detail/{post_id}", 1L)
543+
)
544+
.andDo(print());
545+
546+
resultActions
547+
.andExpect(handler().handlerType(InformationPostController.class))
548+
.andExpect(handler().methodName("getPostDetail"))
549+
.andExpect(status().isOk())
550+
.andExpect(jsonPath("$.resultCode").value("200"))
551+
.andExpect(jsonPath("$.msg").value("게시글 상세 조회 성공"))
552+
.andExpect(jsonPath("$.data").exists())
553+
.andExpect(jsonPath("$.data.id").value(1L))
554+
.andExpect(jsonPath("$.data.title").exists())
555+
.andExpect(jsonPath("$.data.content").exists())
556+
.andExpect(jsonPath("$.data.authorName").exists())
557+
.andExpect(jsonPath("$.data.viewCount").exists())
558+
.andExpect(jsonPath("$.data.comments").isArray())
559+
.andExpect(jsonPath("$.data.likeCount").exists())
560+
.andExpect(jsonPath("$.data.dislikeCount").exists())
561+
.andExpect(jsonPath("$.data.userLikeStatus").exists());
562+
}
563+
564+
@Test
565+
@DisplayName("게시글 상세 조회 실패 - 존재하지 않는 게시글")
566+
void t19() throws Exception {
567+
ResultActions resultActions = mvc
568+
.perform(
569+
get("/post/infor/Detail/{post_id}", 999L)
570+
)
571+
.andDo(print());
572+
573+
resultActions
574+
.andExpect(handler().handlerType(InformationPostController.class))
575+
.andExpect(handler().methodName("getPostDetail"))
576+
.andExpect(jsonPath("$.resultCode").value("400"))
577+
.andExpect(jsonPath("$.msg").value("해당 Id의 게시글이 없습니다."));
578+
}
579+
533580
}

0 commit comments

Comments
 (0)