fix(channel-donation): 후원 메시지 캔 수량을 천단위 콤마로 표시한다

This commit is contained in:
2026-02-25 20:40:54 +09:00
parent d398d4780a
commit 4e12eaddfe
4 changed files with 65 additions and 3 deletions

View File

@@ -117,7 +117,8 @@ class ChannelDonationService(
} else {
"explorer.channel_donation.message.default.public"
}
val defaultMessage = getMessage(key, can)
val formattedCan = String.format("%,d", can)
val defaultMessage = getMessage(key, formattedCan)
return if (additionalMessage.isNullOrBlank()) {
defaultMessage

View File

@@ -59,9 +59,9 @@ class ChannelDonationControllerTest {
memberId = member.id!!,
nickname = member.nickname,
profileUrl = "https://cdn.test/profile/default-profile.png",
can = 3,
can = 1000,
isSecret = false,
message = "3캔을 후원하셨습니다.",
message = "1,000캔을 후원하셨습니다.",
createdAt = "2026-02-23T09:30:00"
)
val response = GetChannelDonationListResponse(totalCount = 1, items = listOf(item))

View File

@@ -110,6 +110,46 @@ class ChannelDonationServiceTest {
)
}
@Test
fun shouldFormatCanWithCommaInDonationMessage() {
val creator = createMember(id = 1L, role = MemberRole.CREATOR, nickname = "creator")
val viewer = createMember(id = 2L, role = MemberRole.USER, nickname = "viewer")
val message = ChannelDonationMessage(can = 1000, isSecret = true, additionalMessage = "응원합니다")
message.id = 1001L
message.member = viewer
message.creator = creator
message.createdAt = LocalDateTime.of(2026, 2, 20, 12, 0, 0)
Mockito.`when`(memberRepository.findCreatorByIdOrNull(creator.id!!)).thenReturn(creator)
Mockito.`when`(
channelDonationMessageRepository.getChannelDonationMessageTotalCount(
Mockito.eq(creator.id!!),
Mockito.eq(viewer.id!!),
Mockito.eq(false),
anyLocalDateTime()
)
).thenReturn(1)
Mockito.`when`(
channelDonationMessageRepository.getChannelDonationMessageList(
Mockito.eq(creator.id!!),
Mockito.eq(viewer.id!!),
Mockito.eq(false),
Mockito.eq(0L),
Mockito.eq(5L),
anyLocalDateTime()
)
).thenReturn(listOf(message))
val result = service.getChannelDonationList(
creatorId = creator.id!!,
member = viewer,
offset = 0,
limit = 5
)
assertEquals("1,000캔을 비밀후원하셨습니다.\n\"응원합니다\"", result.items[0].message)
}
@Test
fun shouldPassCreatorVisibilityFlagToRepositoryWhenRequesterIsCreatorSelf() {
val creator = createMember(id = 1L, role = MemberRole.CREATOR, nickname = "creator")