test(creator-channel): 채널 홈 커뮤니티 번역을 검증한다
This commit is contained in:
+39
@@ -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.CreatorCheers
|
||||||
import kr.co.vividnext.sodalive.explorer.profile.channelDonation.ChannelDonationMessage
|
import kr.co.vividnext.sodalive.explorer.profile.channelDonation.ChannelDonationMessage
|
||||||
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.CreatorCommunity
|
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.LiveRoom
|
||||||
import kr.co.vividnext.sodalive.live.room.visit.LiveRoomVisit
|
import kr.co.vividnext.sodalive.live.room.visit.LiveRoomVisit
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
import kr.co.vividnext.sodalive.member.MemberAdapter
|
import kr.co.vividnext.sodalive.member.MemberAdapter
|
||||||
import kr.co.vividnext.sodalive.member.MemberRole
|
import kr.co.vividnext.sodalive.member.MemberRole
|
||||||
import kr.co.vividnext.sodalive.support.EmbeddedRedisInitializer
|
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.DisplayName
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
@@ -82,6 +84,28 @@ class CreatorChannelHomeEndToEndTest @Autowired constructor(
|
|||||||
.andExpect(jsonPath("$.data.sns.instagramUrl").value("e2e-instagram"))
|
.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 {
|
private fun createFixture(): Fixture {
|
||||||
return transactionTemplate.execute {
|
return transactionTemplate.execute {
|
||||||
val now = LocalDateTime.now(ZoneOffset.UTC)
|
val now = LocalDateTime.now(ZoneOffset.UTC)
|
||||||
@@ -237,6 +261,21 @@ class CreatorChannelHomeEndToEndTest @Autowired constructor(
|
|||||||
return post
|
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 {
|
private fun saveCheers(member: Member, creator: Member, cheers: String, createdAt: LocalDateTime): CreatorCheers {
|
||||||
val creatorCheers = CreatorCheers(cheers = cheers, languageCode = "ko", isActive = true)
|
val creatorCheers = CreatorCheers(cheers = cheers, languageCode = "ko", isActive = true)
|
||||||
creatorCheers.member = member
|
creatorCheers.member = member
|
||||||
|
|||||||
+2
@@ -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.CreatorChannelCommunityCreatorRecord
|
||||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.port.out.CreatorChannelCommunityPostRecord
|
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.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.CreatorChannelActivity
|
||||||
import kr.co.vividnext.sodalive.v2.creator.channel.home.domain.CreatorChannelCreator
|
import kr.co.vividnext.sodalive.v2.creator.channel.home.domain.CreatorChannelCreator
|
||||||
import kr.co.vividnext.sodalive.v2.creator.channel.home.domain.CreatorChannelDonation
|
import kr.co.vividnext.sodalive.v2.creator.channel.home.domain.CreatorChannelDonation
|
||||||
@@ -505,6 +506,7 @@ class CreatorChannelHomeQueryServiceTest {
|
|||||||
audioContentCloudFront = audioContentCloudFront,
|
audioContentCloudFront = audioContentCloudFront,
|
||||||
messageSource = messageSource,
|
messageSource = messageSource,
|
||||||
langContext = langContext,
|
langContext = langContext,
|
||||||
|
creatorCommunityTranslationService = Mockito.mock(CreatorCommunityTranslationService::class.java),
|
||||||
cloudFrontHost = "https://cdn.test"
|
cloudFrontHost = "https://cdn.test"
|
||||||
),
|
),
|
||||||
queryPolicy = CreatorChannelHomeQueryPolicy(),
|
queryPolicy = CreatorChannelHomeQueryPolicy(),
|
||||||
|
|||||||
Reference in New Issue
Block a user