fix(home-following): 최근 대화를 팔로우 크리에이터로 제한한다

This commit is contained in:
2026-08-19 12:23:33 +09:00
parent b18e40d4fc
commit b1be87b46f
9 changed files with 570 additions and 20 deletions
@@ -39,7 +39,9 @@ class ChatRoomListServiceTest {
val member = member(1L)
val aiLastAt = LocalDateTime.of(2026, 5, 14, 11, 0)
val dmLastAt = LocalDateTime.of(2026, 5, 14, 12, 0)
Mockito.`when`(aiRoomRepository.findAiChatListRooms(1L, null, null, null, PageRequest.of(0, 31))).thenReturn(
Mockito.`when`(
aiRoomRepository.findAiChatListRooms(1L, null, null, null, false, PageRequest.of(0, 31))
).thenReturn(
listOf(
ChatRoomListQueryDto(
roomId = 10L,
@@ -52,7 +54,9 @@ class ChatRoomListServiceTest {
)
)
)
Mockito.`when`(dmRoomRepository.findDmChatListRooms(1L, null, null, null, PageRequest.of(0, 31))).thenReturn(
Mockito.`when`(
dmRoomRepository.findDmChatListRooms(1L, null, null, null, false, PageRequest.of(0, 31))
).thenReturn(
listOf(
ChatRoomListQueryDto(
roomId = 20L,
@@ -80,7 +84,9 @@ class ChatRoomListServiceTest {
@DisplayName("DM 필터는 DM 방만 조회하고 음성 메시지 요약 문구를 사용한다")
fun shouldReturnOnlyDmRoomsWithVoicePreview() {
val member = member(1L)
Mockito.`when`(dmRoomRepository.findDmChatListRooms(1L, null, null, null, PageRequest.of(0, 31))).thenReturn(
Mockito.`when`(
dmRoomRepository.findDmChatListRooms(1L, null, null, null, false, PageRequest.of(0, 31))
).thenReturn(
listOf(
ChatRoomListQueryDto(
roomId = 20L,
@@ -118,7 +124,9 @@ class ChatRoomListServiceTest {
lastMessageAt = LocalDateTime.of(2026, 5, 14, 12, 0).minusMinutes(index)
)
}
Mockito.`when`(aiRoomRepository.findAiChatListRooms(1L, null, null, null, PageRequest.of(0, 31))).thenReturn(rows)
Mockito.`when`(
aiRoomRepository.findAiChatListRooms(1L, null, null, null, false, PageRequest.of(0, 31))
).thenReturn(rows)
val response = service.getRooms(member, filter = "AI", cursor = null, limit = 30)
@@ -133,7 +141,9 @@ class ChatRoomListServiceTest {
fun shouldKeepRoomsWithSameTimestampAfterCursor() {
val member = member(1L)
val cursorAt = LocalDateTime.of(2026, 5, 14, 12, 0)
Mockito.`when`(aiRoomRepository.findAiChatListRooms(1L, cursorAt, "DM", 20L, PageRequest.of(0, 31))).thenReturn(
Mockito.`when`(
aiRoomRepository.findAiChatListRooms(1L, cursorAt, "DM", 20L, false, PageRequest.of(0, 31))
).thenReturn(
listOf(
ChatRoomListQueryDto(
roomId = 30L,
@@ -146,7 +156,9 @@ class ChatRoomListServiceTest {
)
)
)
Mockito.`when`(dmRoomRepository.findDmChatListRooms(1L, cursorAt, "DM", 20L, PageRequest.of(0, 31))).thenReturn(
Mockito.`when`(
dmRoomRepository.findDmChatListRooms(1L, cursorAt, "DM", 20L, false, PageRequest.of(0, 31))
).thenReturn(
listOf(
ChatRoomListQueryDto(
roomId = 20L,
@@ -175,5 +187,21 @@ class ChatRoomListServiceTest {
assertEquals("https://cdn.test/profile/default-profile.png", response.rooms[0].targetImageUrl)
}
@Test
@DisplayName("팔로우 크리에이터 필터는 AI와 DM 저장소에 전달한다")
fun shouldPassFollowedCreatorsOnlyToBothRepositories() {
val member = member(1L)
val pageable = PageRequest.of(0, 11)
Mockito.`when`(aiRoomRepository.findAiChatListRooms(1L, null, null, null, true, pageable))
.thenReturn(emptyList())
Mockito.`when`(dmRoomRepository.findDmChatListRooms(1L, null, null, null, true, pageable))
.thenReturn(emptyList())
service.getRooms(member, filter = "ALL", cursor = null, limit = 10, followedCreatorsOnly = true)
Mockito.verify(aiRoomRepository).findAiChatListRooms(1L, null, null, null, true, pageable)
Mockito.verify(dmRoomRepository).findDmChatListRooms(1L, null, null, null, true, pageable)
}
private fun member(id: Long) = Member(password = "pw", nickname = "user").apply { this.id = id }
}