diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/creator/channel/home/CreatorChannelHomeEndToEndTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/creator/channel/home/CreatorChannelHomeEndToEndTest.kt index 9970dff6..6f62841b 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/creator/channel/home/CreatorChannelHomeEndToEndTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/creator/channel/home/CreatorChannelHomeEndToEndTest.kt @@ -11,12 +11,14 @@ import kr.co.vividnext.sodalive.creator.admin.content.series.SeriesContent import kr.co.vividnext.sodalive.explorer.profile.CreatorCheers import kr.co.vividnext.sodalive.explorer.profile.channelDonation.ChannelDonationMessage import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.CreatorCommunity +import kr.co.vividnext.sodalive.i18n.translation.SourceTextNormalizer import kr.co.vividnext.sodalive.live.room.LiveRoom import kr.co.vividnext.sodalive.live.room.visit.LiveRoomVisit import kr.co.vividnext.sodalive.member.Member import kr.co.vividnext.sodalive.member.MemberAdapter import kr.co.vividnext.sodalive.member.MemberRole import kr.co.vividnext.sodalive.support.EmbeddedRedisInitializer +import kr.co.vividnext.sodalive.v2.creator.channel.community.translation.adapter.out.persistence.CreatorCommunityTranslation import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test import org.mockito.Mockito @@ -82,6 +84,28 @@ class CreatorChannelHomeEndToEndTest @Autowired constructor( .andExpect(jsonPath("$.data.sns.instagramUrl").value("e2e-instagram")) } + @Test + @DisplayName("크리에이터 채널 홈 API는 고정과 일반 커뮤니티의 저장 번역을 반환한다") + fun shouldUseStoredTranslationsForPinnedAndNormalHomeCommunityPosts() { + Mockito.doReturn("US").`when`(countryContext).countryCode + val fixture = createFixture() + transactionTemplate.execute { + saveCommunityTranslation(fixture.noticeId, "translated notice") + saveCommunityTranslation(fixture.communityId, "translated community") + entityManager.flush() + entityManager.clear() + } + + mockMvc.perform( + get("/api/v2/creator-channels/${fixture.creatorId}/home") + .header("Accept-Language", "ja") + .with(user(MemberAdapter(fixture.viewer))) + ) + .andExpect(status().isOk) + .andExpect(jsonPath("$.data.notices[0].content").value("translated notice")) + .andExpect(jsonPath("$.data.communities[0].content").value("translated community")) + } + private fun createFixture(): Fixture { return transactionTemplate.execute { val now = LocalDateTime.now(ZoneOffset.UTC) @@ -237,6 +261,21 @@ class CreatorChannelHomeEndToEndTest @Autowired constructor( return post } + private fun saveCommunityTranslation(postId: Long, content: String) { + val post = entityManager.find(CreatorCommunity::class.java, postId) + post.languageCode = "ko" + entityManager.persist( + CreatorCommunityTranslation( + creatorCommunityId = postId, + locale = "ja", + content = content, + sourceRevision = post.contentRevision, + sourceHash = SourceTextNormalizer.hash(post.content), + sourceLanguage = "ko" + ) + ) + } + private fun saveCheers(member: Member, creator: Member, cheers: String, createdAt: LocalDateTime): CreatorCheers { val creatorCheers = CreatorCheers(cheers = cheers, languageCode = "ko", isActive = true) creatorCheers.member = member diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/home/application/CreatorChannelHomeQueryServiceTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/home/application/CreatorChannelHomeQueryServiceTest.kt index 362545b3..50fbc451 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/home/application/CreatorChannelHomeQueryServiceTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/creator/channel/home/application/CreatorChannelHomeQueryServiceTest.kt @@ -23,6 +23,7 @@ import kr.co.vividnext.sodalive.v2.creator.channel.community.domain.CreatorChann import kr.co.vividnext.sodalive.v2.creator.channel.community.port.out.CreatorChannelCommunityCreatorRecord import kr.co.vividnext.sodalive.v2.creator.channel.community.port.out.CreatorChannelCommunityPostRecord import kr.co.vividnext.sodalive.v2.creator.channel.community.port.out.CreatorChannelCommunityQueryPort +import kr.co.vividnext.sodalive.v2.creator.channel.community.translation.application.CreatorCommunityTranslationService import kr.co.vividnext.sodalive.v2.creator.channel.home.domain.CreatorChannelActivity import kr.co.vividnext.sodalive.v2.creator.channel.home.domain.CreatorChannelCreator import kr.co.vividnext.sodalive.v2.creator.channel.home.domain.CreatorChannelDonation @@ -505,6 +506,7 @@ class CreatorChannelHomeQueryServiceTest { audioContentCloudFront = audioContentCloudFront, messageSource = messageSource, langContext = langContext, + creatorCommunityTranslationService = Mockito.mock(CreatorCommunityTranslationService::class.java), cloudFrontHost = "https://cdn.test" ), queryPolicy = CreatorChannelHomeQueryPolicy(),