feat(community): 채널 커뮤니티 좋아요 조회를 추가한다
This commit is contained in:
+16
-3
@@ -153,22 +153,33 @@ class DefaultCreatorChannelCommunityQueryRepositoryTest @Autowired constructor(
|
||||
val inactiveLiker = saveMember("inactive-liker", MemberRole.USER)
|
||||
val commenter = saveMember("unavailable-commenter", MemberRole.USER)
|
||||
val post = saveCommunity(creator, isFixed = false, price = 0, isCommentAvailable = false)
|
||||
val otherMemberOnlyLikedPost = saveCommunity(creator, isFixed = false, price = 0, isCommentAvailable = false)
|
||||
val inactiveViewerLikedPost = saveCommunity(creator, isFixed = false, price = 0, isCommentAvailable = false)
|
||||
saveCommunityLike(activeLiker, post, isActive = true)
|
||||
saveCommunityLike(viewer, post, isActive = true)
|
||||
saveCommunityLike(activeLiker, otherMemberOnlyLikedPost, isActive = true)
|
||||
saveCommunityLike(inactiveLiker, post, isActive = false)
|
||||
saveCommunityLike(viewer, inactiveViewerLikedPost, isActive = false)
|
||||
saveCommunityComment(commenter, post, isActive = true)
|
||||
flushAndClear()
|
||||
|
||||
val record = repository.findCommunityPosts(
|
||||
val records = repository.findCommunityPosts(
|
||||
creatorId = creator.id!!,
|
||||
viewerId = viewer.id!!,
|
||||
canViewAdultContent = true,
|
||||
offset = 0,
|
||||
limit = 10
|
||||
).single()
|
||||
)
|
||||
val record = records.single { it.postId == post.id }
|
||||
val otherMemberOnlyLikedRecord = records.single { it.postId == otherMemberOnlyLikedPost.id }
|
||||
val inactiveViewerLikedRecord = records.single { it.postId == inactiveViewerLikedPost.id }
|
||||
|
||||
assertEquals(1, record.likeCount)
|
||||
assertEquals(2, record.likeCount)
|
||||
assertEquals(0, record.commentCount)
|
||||
assertFalse(record.isCommentAvailable)
|
||||
assertTrue(record.isLiked)
|
||||
assertFalse(otherMemberOnlyLikedRecord.isLiked)
|
||||
assertFalse(inactiveViewerLikedRecord.isLiked)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -276,6 +287,7 @@ class DefaultCreatorChannelCommunityQueryRepositoryTest @Autowired constructor(
|
||||
val pinned = saveCommunity(creator, isFixed = true, fixedAt = now.minusHours(1), price = 0)
|
||||
val normal = saveCommunity(creator, isFixed = false, price = 0)
|
||||
val adultPinned = saveCommunity(creator, isFixed = true, fixedAt = now, price = 0, isAdult = true)
|
||||
saveCommunityLike(viewer, normal, isActive = true)
|
||||
flushAndClear()
|
||||
updateCreatedAt("CreatorCommunity", normal.id!!, now.minusDays(1))
|
||||
flushAndClear()
|
||||
@@ -300,6 +312,7 @@ class DefaultCreatorChannelCommunityQueryRepositoryTest @Autowired constructor(
|
||||
assertFalse(adultPinned.id in pinnedPosts.map { it.postId })
|
||||
assertTrue(pinnedPosts.single().isPinned)
|
||||
assertFalse(normalPosts.single().isPinned)
|
||||
assertTrue(normalPosts.single().isLiked)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user