feat(creator): 채널 표시와 상대 시간을 정리한다
This commit is contained in:
+2
-3
@@ -13,7 +13,6 @@ import io.reactivex.rxjava3.plugins.RxJavaPlugins
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.audio_content.comment.ModifyCommentRequest
|
||||
import kr.co.vividnext.sodalive.explorer.profile.creator_community.CreatorCommunityRepository
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.CreatorChannelCommunityDetailUiState
|
||||
@@ -58,7 +57,7 @@ class CreatorChannelCommunityDetailViewModelTest {
|
||||
SharedPreferenceManager.userId = 10L
|
||||
repository = org.mockito.kotlin.mock()
|
||||
legacyRepository = org.mockito.kotlin.mock()
|
||||
viewModel = CreatorChannelCommunityDetailViewModel(repository, legacyRepository, testFormatter)
|
||||
viewModel = CreatorChannelCommunityDetailViewModel(repository, legacyRepository)
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -84,6 +83,7 @@ class CreatorChannelCommunityDetailViewModelTest {
|
||||
|
||||
val state = viewModel.detailStateLiveData.requireValue() as CreatorChannelCommunityDetailUiState.Content
|
||||
assertEquals(POST_ID, state.post.postId)
|
||||
assertEquals("2026-07-08T00:00:00Z", state.post.createdAtUtc)
|
||||
assertEquals("body", state.post.content)
|
||||
assertEquals("image.png", state.post.imageUrl)
|
||||
assertEquals("audio.mp3", state.post.audioUrl)
|
||||
@@ -729,6 +729,5 @@ class CreatorChannelCommunityDetailViewModelTest {
|
||||
const val POST_ID = 200L
|
||||
const val COMMENT_ID = 11L
|
||||
const val AUTH_TOKEN = "Bearer test-token"
|
||||
val testFormatter = UtcRelativeTimeTextFormatter { "방금 전" }
|
||||
}
|
||||
}
|
||||
|
||||
+19
-30
@@ -1,10 +1,6 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.community
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.common.AndroidUtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.data.CreatorChannelCommunityPostResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityImageMode
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityViewMode
|
||||
@@ -14,17 +10,9 @@ import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], application = Application::class)
|
||||
class CreatorChannelCommunityMapperTest {
|
||||
|
||||
private val context: Context = ApplicationProvider.getApplicationContext()
|
||||
private val relativeTimeTextFormatter = AndroidUtcRelativeTimeTextFormatter(context)
|
||||
|
||||
@Test
|
||||
fun `보기 방식은 label과 icon resource를 가진다`() {
|
||||
assertEquals(R.string.creator_channel_community_view_mode_list, CreatorChannelCommunityViewMode.List.labelResId)
|
||||
@@ -34,21 +22,22 @@ class CreatorChannelCommunityMapperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `게시글 기본 필드와 상대 시간 notice 댓글 표시 상태를 매핑한다`() {
|
||||
fun `게시글 기본 필드와 raw UTC notice 댓글 표시 상태를 매핑한다`() {
|
||||
val createdAtUtc = "2026-06-21T00:00:00Z"
|
||||
val item = listOf(
|
||||
communityPost(
|
||||
creatorProfileUrl = "profile.png",
|
||||
createdAtUtc = System.currentTimeMillis().toString(),
|
||||
createdAtUtc = createdAtUtc,
|
||||
isPinned = true,
|
||||
isCommentAvailable = true
|
||||
)
|
||||
).toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L).single()
|
||||
).toCommunityPostUiModels(isOwner = false, currentUserId = 99L).single()
|
||||
|
||||
assertEquals(1L, item.postId)
|
||||
assertEquals(10L, item.creatorId)
|
||||
assertEquals("creator", item.creatorNickname)
|
||||
assertEquals("profile.png", item.creatorProfileUrl)
|
||||
assertEquals(context.getString(R.string.character_comment_time_just_now), item.createdAtText)
|
||||
assertEquals(createdAtUtc, item.createdAtUtc)
|
||||
assertEquals("hello community", item.content)
|
||||
assertEquals(3, item.likeCount)
|
||||
assertEquals(4, item.commentCount)
|
||||
@@ -59,7 +48,7 @@ class CreatorChannelCommunityMapperTest {
|
||||
@Test
|
||||
fun `댓글 불가 게시글은 댓글 표시 상태가 false다`() {
|
||||
val item = listOf(communityPost(isCommentAvailable = false))
|
||||
.toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L)
|
||||
.toCommunityPostUiModels(isOwner = false, currentUserId = 99L)
|
||||
.single()
|
||||
|
||||
assertFalse(item.showComment)
|
||||
@@ -69,7 +58,7 @@ class CreatorChannelCommunityMapperTest {
|
||||
fun `유료 미구매 타인 게시글은 잠금 상태이고 이미지를 숨긴다`() {
|
||||
val item = listOf(
|
||||
communityPost(price = 100, existOrdered = false, imageUrl = "image.png", audioUrl = "audio.mp3")
|
||||
).toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L).single()
|
||||
).toCommunityPostUiModels(isOwner = false, currentUserId = 99L).single()
|
||||
|
||||
assertTrue(item.isLocked)
|
||||
assertNull(item.imageUrl)
|
||||
@@ -84,7 +73,7 @@ class CreatorChannelCommunityMapperTest {
|
||||
existOrdered = false,
|
||||
isCommentAvailable = true
|
||||
)
|
||||
).toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L).single()
|
||||
).toCommunityPostUiModels(isOwner = false, currentUserId = 99L).single()
|
||||
|
||||
assertTrue(item.isLocked)
|
||||
assertFalse(item.showReaction)
|
||||
@@ -94,10 +83,10 @@ class CreatorChannelCommunityMapperTest {
|
||||
@Test
|
||||
fun `고정 게시글 여부는 UI 모델에 보존한다`() {
|
||||
val pinnedItem = listOf(communityPost(isPinned = true))
|
||||
.toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = true, currentUserId = 10L)
|
||||
.toCommunityPostUiModels(isOwner = true, currentUserId = 10L)
|
||||
.single()
|
||||
val normalItem = listOf(communityPost(isPinned = false))
|
||||
.toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = true, currentUserId = 10L)
|
||||
.toCommunityPostUiModels(isOwner = true, currentUserId = 10L)
|
||||
.single()
|
||||
|
||||
assertTrue(pinnedItem.isPinned)
|
||||
@@ -109,16 +98,16 @@ class CreatorChannelCommunityMapperTest {
|
||||
@Test
|
||||
fun `메뉴 권한은 작성자 무료 구매 여부에 따라 계산하고 고정 상태를 보존한다`() {
|
||||
val authorPaidNotOrdered = listOf(communityPost(price = 100, existOrdered = false, isPinned = true))
|
||||
.toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 10L)
|
||||
.toCommunityPostUiModels(isOwner = false, currentUserId = 10L)
|
||||
.single()
|
||||
val visitorFree = listOf(communityPost(price = 0, existOrdered = false))
|
||||
.toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L)
|
||||
.toCommunityPostUiModels(isOwner = false, currentUserId = 99L)
|
||||
.single()
|
||||
val visitorPaidOrdered = listOf(communityPost(price = 100, existOrdered = true))
|
||||
.toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L)
|
||||
.toCommunityPostUiModels(isOwner = false, currentUserId = 99L)
|
||||
.single()
|
||||
val visitorPaidNotOrdered = listOf(communityPost(price = 100, existOrdered = false))
|
||||
.toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L)
|
||||
.toCommunityPostUiModels(isOwner = false, currentUserId = 99L)
|
||||
.single()
|
||||
|
||||
assertTrue(authorPaidNotOrdered.menuItem.isOwner)
|
||||
@@ -134,16 +123,16 @@ class CreatorChannelCommunityMapperTest {
|
||||
@Test
|
||||
fun `본인 채널에 본인이 쓴 유료 게시글에서만 top price를 표시한다`() {
|
||||
val ownerPaid = listOf(communityPost(price = 100, creatorId = 10L))
|
||||
.toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = true, currentUserId = 10L)
|
||||
.toCommunityPostUiModels(isOwner = true, currentUserId = 10L)
|
||||
.single()
|
||||
val ownerFree = listOf(communityPost(price = 0, creatorId = 10L))
|
||||
.toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = true, currentUserId = 10L)
|
||||
.toCommunityPostUiModels(isOwner = true, currentUserId = 10L)
|
||||
.single()
|
||||
val otherCreator = listOf(communityPost(price = 100, creatorId = 11L))
|
||||
.toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = true, currentUserId = 10L)
|
||||
.toCommunityPostUiModels(isOwner = true, currentUserId = 10L)
|
||||
.single()
|
||||
val otherChannel = listOf(communityPost(price = 100, creatorId = 10L))
|
||||
.toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 10L)
|
||||
.toCommunityPostUiModels(isOwner = false, currentUserId = 10L)
|
||||
.single()
|
||||
|
||||
assertTrue(ownerPaid.showOwnerTopPrice)
|
||||
@@ -155,7 +144,7 @@ class CreatorChannelCommunityMapperTest {
|
||||
@Test
|
||||
fun `grid text-only preview는 줄바꿈을 공백으로 바꾸고 trim 후 24자까지만 사용한다`() {
|
||||
val item = listOf(communityPost(content = "\n123456789012345678901234567890\n"))
|
||||
.toCommunityPostUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L)
|
||||
.toCommunityPostUiModels(isOwner = false, currentUserId = 99L)
|
||||
.single()
|
||||
|
||||
assertEquals("123456789012345678901234", item.gridPreviewText)
|
||||
|
||||
+1
-2
@@ -12,7 +12,6 @@ import io.reactivex.rxjava3.plugins.RxJavaPlugins
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import io.reactivex.rxjava3.subjects.SingleSubject
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.AndroidUtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.data.CreatorChannelCommunityPostResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.data.CreatorChannelCommunityTabResponse
|
||||
@@ -45,7 +44,7 @@ class CreatorChannelCommunityPaginationTest {
|
||||
SharedPreferenceManager.init(context)
|
||||
SharedPreferenceManager.token = "test-token"
|
||||
repository = org.mockito.kotlin.mock()
|
||||
viewModel = CreatorChannelCommunityViewModel(repository, AndroidUtcRelativeTimeTextFormatter(context))
|
||||
viewModel = CreatorChannelCommunityViewModel(repository)
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.community
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.common.ImageLoaderProvider
|
||||
import kr.co.vividnext.sodalive.common.formatUtcRelativeTimeText
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.CreatorChannelCommunityCommentUiModel
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.CreatorChannelCommunityReplyUiModel
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.reply.ui.CreatorChannelCommunityReplyAdapter
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.ui.CreatorChannelCommunityCommentAdapter
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityImageMode
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityMenuItem
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityPostUiModel
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.ui.CreatorChannelCommunityListAdapter
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], application = Application::class)
|
||||
class CreatorChannelCommunityRelativeTimeLocaleTest {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
if (!ImageLoaderProvider.isInitialized) {
|
||||
ImageLoaderProvider.init(RuntimeEnvironment.getApplication())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `영어와 일본어 목록 댓글 답글 bind는 raw UTC를 현재 View locale 상대 시간으로 표시한다`() {
|
||||
listOf(Locale.ENGLISH, Locale.JAPANESE).forEach(::assertAdapterRelativeTime)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `영어와 일본어 상세와 답글 화면은 raw UTC를 현재 View locale 상대 시간으로 표시한다`() {
|
||||
val detailSource = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/community/detail/" +
|
||||
"CreatorChannelCommunityDetailActivity.kt"
|
||||
).readText()
|
||||
val replySource = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/community/detail/reply/" +
|
||||
"CreatorChannelCommunityReplyActivity.kt"
|
||||
).readText()
|
||||
|
||||
assertTrue(
|
||||
Regex(
|
||||
"tvCreatorChannelCommunityDetailTime\\.text\\s*=\\s*" +
|
||||
"formatUtcRelativeTimeText\\(tvCreatorChannelCommunityDetailTime\\.context, post\\.createdAtUtc\\)"
|
||||
).containsMatchIn(detailSource)
|
||||
)
|
||||
assertTrue(
|
||||
Regex(
|
||||
"layoutCreatorChannelCommunityReplyParent\\.tvCreatorChannelCommunityCommentTime\\.text\\s*=\\s*" +
|
||||
"formatUtcRelativeTimeText\\(\\s*" +
|
||||
"layoutCreatorChannelCommunityReplyParent\\.tvCreatorChannelCommunityCommentTime\\.context,\\s*" +
|
||||
"content\\.parentComment\\.createdAtUtc\\s*\\)"
|
||||
).containsMatchIn(replySource)
|
||||
)
|
||||
listOf(Locale.ENGLISH, Locale.JAPANESE).forEach { locale ->
|
||||
val context = localizedContext(locale)
|
||||
assertEquals(
|
||||
context.getString(R.string.character_comment_time_just_now),
|
||||
formatUtcRelativeTimeText(context, System.currentTimeMillis().toString())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun assertAdapterRelativeTime(locale: Locale) {
|
||||
val context = localizedContext(locale)
|
||||
val nowUtc = System.currentTimeMillis().toString()
|
||||
val expected = context.getString(R.string.character_comment_time_just_now)
|
||||
|
||||
val listAdapter = CreatorChannelCommunityListAdapter()
|
||||
val listHolder = listAdapter.onCreateViewHolder(FrameLayout(context), 0)
|
||||
listAdapter.submitItems(listOf(post(nowUtc)))
|
||||
listAdapter.onBindViewHolder(listHolder, 0)
|
||||
assertEquals(
|
||||
expected,
|
||||
listHolder.itemView.findViewById<TextView>(R.id.tv_creator_channel_community_list_time).text.toString()
|
||||
)
|
||||
|
||||
val commentAdapter = CreatorChannelCommunityCommentAdapter(onReplyClick = {})
|
||||
val commentHolder = commentAdapter.onCreateViewHolder(FrameLayout(context), 0)
|
||||
commentAdapter.submitItems(listOf(comment(nowUtc)))
|
||||
commentAdapter.onBindViewHolder(commentHolder, 0)
|
||||
assertEquals(
|
||||
expected,
|
||||
commentHolder.itemView.findViewById<TextView>(R.id.tv_creator_channel_community_comment_time).text.toString()
|
||||
)
|
||||
|
||||
val replyAdapter = CreatorChannelCommunityReplyAdapter(onModifyClick = {}, onDeleteClick = {})
|
||||
val replyHolder = replyAdapter.onCreateViewHolder(FrameLayout(context), 0)
|
||||
replyAdapter.submitItems(listOf(reply(nowUtc)))
|
||||
replyAdapter.onBindViewHolder(replyHolder, 0)
|
||||
assertEquals(
|
||||
expected,
|
||||
replyHolder.itemView.findViewById<TextView>(R.id.tv_creator_channel_community_reply_item_time).text.toString()
|
||||
)
|
||||
}
|
||||
|
||||
private fun post(createdAtUtc: String) = CreatorChannelCommunityPostUiModel(
|
||||
postId = 1L,
|
||||
creatorId = 2L,
|
||||
creatorNickname = "creator",
|
||||
creatorProfileUrl = "",
|
||||
createdAtUtc = createdAtUtc,
|
||||
content = "post",
|
||||
imageUrl = null,
|
||||
price = 0,
|
||||
existOrdered = true,
|
||||
likeCount = 0,
|
||||
commentCount = 0,
|
||||
showReaction = true,
|
||||
showComment = true,
|
||||
showNotice = false,
|
||||
isPinned = false,
|
||||
isLocked = false,
|
||||
showOwnerTopPrice = false,
|
||||
gridPreviewText = "post",
|
||||
imageMode = CreatorChannelCommunityImageMode.TextPreview,
|
||||
menuItem = CreatorChannelCommunityMenuItem(1L, 2L, 3L, 0, true, false)
|
||||
)
|
||||
|
||||
private fun comment(createdAtUtc: String) = CreatorChannelCommunityCommentUiModel(
|
||||
commentId = 1L,
|
||||
memberId = 2L,
|
||||
memberNickname = "member",
|
||||
memberProfileUrl = "",
|
||||
createdAtUtc = createdAtUtc,
|
||||
comment = "comment",
|
||||
likeCount = 0,
|
||||
replyCount = 0,
|
||||
isLiked = false,
|
||||
isMine = false,
|
||||
isCreatorOwner = false,
|
||||
latestReply = null
|
||||
)
|
||||
|
||||
private fun reply(createdAtUtc: String) = CreatorChannelCommunityReplyUiModel(
|
||||
replyId = 1L,
|
||||
commentId = 2L,
|
||||
memberId = 3L,
|
||||
memberNickname = "member",
|
||||
memberProfileUrl = "",
|
||||
createdAtUtc = createdAtUtc,
|
||||
comment = "reply",
|
||||
likeCount = 0,
|
||||
isLiked = false,
|
||||
isMine = false,
|
||||
isCreatorOwner = false
|
||||
)
|
||||
|
||||
private fun localizedContext(locale: Locale): Context {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
val configuration = Configuration(context.resources.configuration)
|
||||
configuration.setLocale(locale)
|
||||
return context.createConfigurationContext(configuration)
|
||||
}
|
||||
|
||||
private fun projectFile(path: String): File = File(projectRoot(), path)
|
||||
|
||||
private fun projectRoot(): File {
|
||||
return generateSequence(File(System.getProperty("user.dir") ?: ".").absoluteFile) { it.parentFile }
|
||||
.first { File(it, "settings.gradle").exists() }
|
||||
}
|
||||
}
|
||||
+3
-14
@@ -14,7 +14,6 @@ import io.reactivex.rxjava3.subjects.PublishSubject
|
||||
import kr.co.vividnext.sodalive.audio_content.comment.ModifyCommentRequest
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.explorer.profile.creator_community.CreatorCommunityRepository
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.CreatorChannelCommunityCommentUiModel
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.reply.CreatorChannelCommunityReplyUiState
|
||||
@@ -46,7 +45,6 @@ class CreatorChannelCommunityReplyViewModelTest {
|
||||
private lateinit var repository: CreatorChannelRepository
|
||||
private lateinit var legacyRepository: CreatorCommunityRepository
|
||||
private lateinit var viewModel: CreatorChannelCommunityReplyViewModel
|
||||
private lateinit var formattedInputs: MutableList<String?>
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
@@ -57,15 +55,7 @@ class CreatorChannelCommunityReplyViewModelTest {
|
||||
SharedPreferenceManager.userId = 10L
|
||||
repository = org.mockito.kotlin.mock()
|
||||
legacyRepository = org.mockito.kotlin.mock()
|
||||
formattedInputs = mutableListOf()
|
||||
viewModel = CreatorChannelCommunityReplyViewModel(
|
||||
repository,
|
||||
legacyRepository,
|
||||
UtcRelativeTimeTextFormatter { value ->
|
||||
formattedInputs.add(value)
|
||||
"relative:$value"
|
||||
}
|
||||
)
|
||||
viewModel = CreatorChannelCommunityReplyViewModel(repository, legacyRepository)
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -84,9 +74,9 @@ class CreatorChannelCommunityReplyViewModelTest {
|
||||
val state = viewModel.replyStateLiveData.requireValue() as CreatorChannelCommunityReplyUiState.Content
|
||||
assertEquals(COMMENT_ID, state.parentComment.commentId)
|
||||
assertEquals("부모 댓글", state.parentComment.comment)
|
||||
assertEquals("relative:2026-07-08T00:00:00Z", state.parentComment.createdAtText)
|
||||
assertEquals("2026-07-08T00:00:00Z", state.parentComment.createdAtUtc)
|
||||
assertEquals(listOf(101L, 102L), state.replies.map { it.replyId })
|
||||
assertTrue(formattedInputs.contains("2026-07-08T00:00:00Z"))
|
||||
assertEquals(listOf("2026-07-08T00:00:00Z", "2026-07-08T00:00:00Z"), state.replies.map { it.createdAtUtc })
|
||||
assertEquals(0, state.replyPage)
|
||||
assertTrue(state.hasNextReply)
|
||||
verify(repository).getCommunityCommentReplies(
|
||||
@@ -499,7 +489,6 @@ class CreatorChannelCommunityReplyViewModelTest {
|
||||
memberId = 10L,
|
||||
memberNickname = "member",
|
||||
memberProfileUrl = "member.png",
|
||||
createdAtText = "이미 포맷된 시간",
|
||||
createdAtUtc = "2026-07-08T00:00:00Z",
|
||||
comment = "부모 댓글",
|
||||
likeCount = 1,
|
||||
|
||||
+2
-2
@@ -11,7 +11,6 @@ import io.reactivex.rxjava3.core.Single
|
||||
import io.reactivex.rxjava3.plugins.RxJavaPlugins
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.AndroidUtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.data.CreatorChannelCommunityPostResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.community.data.CreatorChannelCommunityTabResponse
|
||||
@@ -45,7 +44,7 @@ class CreatorChannelCommunityViewModelTest {
|
||||
SharedPreferenceManager.init(context)
|
||||
SharedPreferenceManager.token = "test-token"
|
||||
repository = org.mockito.kotlin.mock()
|
||||
viewModel = CreatorChannelCommunityViewModel(repository, AndroidUtcRelativeTimeTextFormatter(context))
|
||||
viewModel = CreatorChannelCommunityViewModel(repository)
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -66,6 +65,7 @@ class CreatorChannelCommunityViewModelTest {
|
||||
assertEquals(0, state.page)
|
||||
assertEquals(CreatorChannelCommunityViewModel.DEFAULT_PAGE_SIZE, state.size)
|
||||
assertEquals(listOf(1L), state.communityPosts.map { it.postId })
|
||||
assertEquals("2026-06-21T00:00:00Z", state.communityPosts.single().createdAtUtc)
|
||||
verifyGetCommunity()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ class CreatorChannelDonationActionTest {
|
||||
assertTrue(adapter.contains("if (!isOwner) View.OnClickListener { onEmptyDonationClick() } else null"))
|
||||
assertTrue(adapter.contains("bindCreatorChannelDonationCard("))
|
||||
assertTrue(adapter.contains("headerColorResId = item.headerColorResId"))
|
||||
assertTrue(adapter.contains("createdAtText = formatUtcRelativeTimeText(context, item.createdAtText)"))
|
||||
assertTrue(adapter.contains("createdAtText = formatUtcRelativeTimeText(context, item.createdAtUtc)"))
|
||||
assertTrue(adapter.contains("R.string.creator_channel_donation_fallback_message"))
|
||||
assertTrue(adapter.contains("GridLayoutManager(itemView.context, 4)"))
|
||||
assertTrue(rankingAdapter.contains("item.profileImageUrl"))
|
||||
|
||||
+5
-5
@@ -176,9 +176,9 @@ class CreatorChannelDonationFragmentLayoutTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `후원 can binder는 한국어 영어 일본어에서 1,000 단위 표시를 사용한다`() {
|
||||
listOf(Locale.KOREAN to "1,000캔", Locale.ENGLISH to "1,000 cans", Locale.JAPANESE to "1,000CAN")
|
||||
.forEach { (locale, expected) ->
|
||||
fun `후원 can badge는 한국어 영어 일본어에서 단위 없이 포맷된 숫자만 표시한다`() {
|
||||
listOf(Locale.KOREAN, Locale.ENGLISH, Locale.JAPANESE)
|
||||
.forEach { locale ->
|
||||
val application = ApplicationProvider.getApplicationContext<Application>()
|
||||
if (!ImageLoaderProvider.isInitialized) ImageLoaderProvider.init(application)
|
||||
val context = application.createConfigurationContext(
|
||||
@@ -189,7 +189,7 @@ class CreatorChannelDonationFragmentLayoutTest {
|
||||
View(context), ImageView(context), TextView(context), TextView(context), canView,
|
||||
TextView(context), R.color.gray_200, "", "member", "time", 1000, "message"
|
||||
)
|
||||
assertEquals(expected, canView.text.toString())
|
||||
assertEquals("1,000", canView.text.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ class CreatorChannelDonationFragmentLayoutTest {
|
||||
profileImageUrl = "",
|
||||
can = 50,
|
||||
message = "",
|
||||
createdAtText = twoMinutesAgoMillis.toString(),
|
||||
createdAtUtc = twoMinutesAgoMillis.toString(),
|
||||
headerColorResId = R.color.gray_200
|
||||
)
|
||||
)
|
||||
|
||||
+11
-30
@@ -1,29 +1,15 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.donation
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.common.AndroidUtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.donation.data.CreatorChannelDonationResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.donation.data.MemberDonationRankingResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.donation.model.toDonationRankingUiModels
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.donation.model.toDonationUiModels
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import java.util.Locale
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], application = Application::class)
|
||||
class CreatorChannelDonationMapperTest {
|
||||
|
||||
private val context: Context = ApplicationProvider.getApplicationContext()
|
||||
private val relativeTimeTextFormatter = AndroidUtcRelativeTimeTextFormatter(context)
|
||||
|
||||
@Test
|
||||
fun `ranking rank는 응답 순서 기준 1부터 시작하고 profileImage를 profileImageUrl로 매핑한다`() {
|
||||
val rankings = listOf(
|
||||
@@ -39,43 +25,38 @@ class CreatorChannelDonationMapperTest {
|
||||
@Test
|
||||
fun `후원 mapper는 message 원문을 보존한다`() {
|
||||
val item = listOf(donation(can = 50, message = ""))
|
||||
.toDonationUiModels(context, relativeTimeTextFormatter)
|
||||
.toDonationUiModels()
|
||||
.single()
|
||||
|
||||
assertEquals("", item.message)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `message는 한국어 영어 일본어 context와 관계없이 API 원문을 유지한다`() {
|
||||
listOf(Locale.KOREAN, Locale.ENGLISH, Locale.JAPANESE).forEach { locale ->
|
||||
val localizedContext = context.createConfigurationContext(
|
||||
Configuration(context.resources.configuration).apply { setLocale(locale) }
|
||||
)
|
||||
val items = listOf(
|
||||
donation(can = 50, message = ""),
|
||||
donation(can = 50, message = "응원합니다")
|
||||
).toDonationUiModels(localizedContext) { "time" }
|
||||
fun `message는 API 원문을 유지한다`() {
|
||||
val items = listOf(
|
||||
donation(can = 50, message = ""),
|
||||
donation(can = 50, message = "응원합니다")
|
||||
).toDonationUiModels()
|
||||
|
||||
assertEquals("", items[0].message)
|
||||
assertEquals("응원합니다", items[1].message)
|
||||
}
|
||||
assertEquals("", items[0].message)
|
||||
assertEquals("응원합니다", items[1].message)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `후원 mapper는 createdAtUtc 원문을 보존하고 can 기준 header color를 계산한다`() {
|
||||
val createdAtUtc = System.currentTimeMillis().toString()
|
||||
val item = listOf(donation(can = 501, createdAtUtc = createdAtUtc))
|
||||
.toDonationUiModels(context, relativeTimeTextFormatter)
|
||||
.toDonationUiModels()
|
||||
.single()
|
||||
|
||||
assertEquals(createdAtUtc, item.createdAtText)
|
||||
assertEquals(createdAtUtc, item.createdAtUtc)
|
||||
assertEquals(R.color.red_400, item.headerColorResId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `후원 header color는 501캔부터 red_400으로 매핑한다`() {
|
||||
val items = listOf(donation(can = 500), donation(can = 501))
|
||||
.toDonationUiModels(context, relativeTimeTextFormatter)
|
||||
.toDonationUiModels()
|
||||
|
||||
assertEquals(R.color.creator_channel_donation_cyan, items[0].headerColorResId)
|
||||
assertEquals(R.color.red_400, items[1].headerColorResId)
|
||||
|
||||
+1
-2
@@ -12,7 +12,6 @@ import io.reactivex.rxjava3.plugins.RxJavaPlugins
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import io.reactivex.rxjava3.subjects.SingleSubject
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.AndroidUtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.common.SodaLiveApplicationHolder
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
|
||||
@@ -48,7 +47,7 @@ class CreatorChannelDonationPaginationTest {
|
||||
SodaLiveApplicationHolder.init(context as Application)
|
||||
SharedPreferenceManager.token = "test-token"
|
||||
repository = org.mockito.kotlin.mock()
|
||||
viewModel = CreatorChannelDonationViewModel(repository, AndroidUtcRelativeTimeTextFormatter(context))
|
||||
viewModel = CreatorChannelDonationViewModel(repository)
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
+1
-2
@@ -11,7 +11,6 @@ import io.reactivex.rxjava3.core.Single
|
||||
import io.reactivex.rxjava3.plugins.RxJavaPlugins
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.AndroidUtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.common.SodaLiveApplicationHolder
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
|
||||
@@ -48,7 +47,7 @@ class CreatorChannelDonationViewModelTest {
|
||||
SharedPreferenceManager.token = "test-token"
|
||||
SharedPreferenceManager.can = 200
|
||||
repository = org.mockito.kotlin.mock()
|
||||
viewModel = CreatorChannelDonationViewModel(repository, AndroidUtcRelativeTimeTextFormatter(context))
|
||||
viewModel = CreatorChannelDonationViewModel(repository)
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
+1
-2
@@ -13,7 +13,6 @@ import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.common.SodaLiveApplicationHolder
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.AndroidUtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkReplyResponse
|
||||
@@ -47,7 +46,7 @@ class CreatorChannelFanTalkActionTest {
|
||||
SharedPreferenceManager.token = "test-token"
|
||||
SharedPreferenceManager.userId = 10L
|
||||
repository = org.mockito.kotlin.mock()
|
||||
viewModel = CreatorChannelFanTalkViewModel(repository, AndroidUtcRelativeTimeTextFormatter(context))
|
||||
viewModel = CreatorChannelFanTalkViewModel(repository)
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.fantalk
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.common.ImageLoaderProvider
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.CreatorChannelFanTalkReplyUiModel
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.CreatorChannelFanTalkRightAction
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.CreatorChannelFanTalkUiModel
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.ui.CreatorChannelFanTalkAdapter
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
import java.util.Locale
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], application = Application::class)
|
||||
class CreatorChannelFanTalkAdapterLocaleTest {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
if (!ImageLoaderProvider.isInitialized) {
|
||||
ImageLoaderProvider.init(RuntimeEnvironment.getApplication())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `영어와 일본어 bind는 오염된 신고 문구를 현재 locale 문자열로 복원한다`() {
|
||||
assertReportText(Locale.ENGLISH, "Report")
|
||||
assertReportText(Locale.JAPANESE, "通報")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `영어와 일본어 목록 bind는 원글과 답글 raw UTC를 현재 View locale 상대 시간으로 표시한다`() {
|
||||
assertRelativeTimeText(Locale.ENGLISH)
|
||||
assertRelativeTimeText(Locale.JAPANESE)
|
||||
}
|
||||
|
||||
private fun assertRelativeTimeText(locale: Locale) {
|
||||
val context = localizedContext(locale)
|
||||
val parent = FrameLayout(context)
|
||||
val adapter = CreatorChannelFanTalkAdapter()
|
||||
val holder = adapter.onCreateViewHolder(parent, 0)
|
||||
val nowUtc = System.currentTimeMillis().toString()
|
||||
adapter.submitItems(listOf(fanTalk(nowUtc)))
|
||||
|
||||
adapter.onBindViewHolder(holder, 0)
|
||||
|
||||
val expected = context.getString(R.string.character_comment_time_just_now)
|
||||
assertEquals(
|
||||
expected,
|
||||
holder.itemView.findViewById<TextView>(R.id.tv_creator_channel_fantalk_time).text.toString()
|
||||
)
|
||||
assertEquals(
|
||||
expected,
|
||||
holder.itemView.findViewById<TextView>(R.id.tv_creator_channel_fantalk_reply_time).text.toString()
|
||||
)
|
||||
}
|
||||
|
||||
private fun assertReportText(locale: Locale, expected: String) {
|
||||
val context = localizedContext(locale)
|
||||
val parent = FrameLayout(context)
|
||||
val adapter = CreatorChannelFanTalkAdapter()
|
||||
val holder = adapter.onCreateViewHolder(parent, 0)
|
||||
val report = holder.itemView.findViewById<TextView>(R.id.tv_creator_channel_fantalk_report)
|
||||
report.text = "신고"
|
||||
adapter.submitItems(listOf(fanTalk()))
|
||||
|
||||
adapter.onBindViewHolder(holder, 0)
|
||||
|
||||
assertEquals(expected, report.text.toString())
|
||||
}
|
||||
|
||||
private fun localizedContext(locale: Locale): Context {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
val configuration = Configuration(context.resources.configuration)
|
||||
configuration.setLocale(locale)
|
||||
return context.createConfigurationContext(configuration)
|
||||
}
|
||||
|
||||
private fun fanTalk(createdAtUtc: String = "2026-06-21T00:00:00Z") = CreatorChannelFanTalkUiModel(
|
||||
fanTalkId = 1L,
|
||||
writerId = 2L,
|
||||
writerNickname = "writer",
|
||||
writerProfileImageUrl = "",
|
||||
content = "fan talk",
|
||||
createdAtUtc = createdAtUtc,
|
||||
reply = CreatorChannelFanTalkReplyUiModel(
|
||||
fanTalkId = 3L,
|
||||
writerId = 4L,
|
||||
writerNickname = "creator",
|
||||
writerProfileImageUrl = "",
|
||||
content = "reply",
|
||||
createdAtUtc = createdAtUtc
|
||||
),
|
||||
rightAction = CreatorChannelFanTalkRightAction.Report
|
||||
)
|
||||
}
|
||||
+19
-25
@@ -1,10 +1,5 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.fantalk
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.common.AndroidUtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkReplyResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.CreatorChannelFanTalkRightAction
|
||||
@@ -13,35 +8,33 @@ import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], application = Application::class)
|
||||
class CreatorChannelFanTalkMapperTest {
|
||||
|
||||
private val context: Context = ApplicationProvider.getApplicationContext()
|
||||
private val relativeTimeTextFormatter = AndroidUtcRelativeTimeTextFormatter(context)
|
||||
|
||||
@Test
|
||||
fun `기본 필드와 상대 시간을 매핑한다`() {
|
||||
val item = listOf(fanTalk(createdAtUtc = System.currentTimeMillis().toString()))
|
||||
.toFanTalkUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L)
|
||||
fun `기본 필드와 원글 답글 raw UTC를 변경 없이 매핑한다`() {
|
||||
val item = listOf(
|
||||
fanTalk(
|
||||
createdAtUtc = "2026-06-21T00:00:00Z",
|
||||
creatorReplies = listOf(reply(createdAtUtc = "2026-06-21T00:01:00Z"))
|
||||
)
|
||||
)
|
||||
.toFanTalkUiModels(isOwner = false, currentUserId = 99L)
|
||||
.single()
|
||||
|
||||
assertEquals(1L, item.fanTalkId)
|
||||
assertEquals(10L, item.writerId)
|
||||
assertEquals("writer", item.writerNickname)
|
||||
assertEquals("profile.png", item.writerProfileImageUrl)
|
||||
assertEquals(context.getString(R.string.character_comment_time_just_now), item.createdAtText)
|
||||
assertEquals("2026-06-21T00:00:00Z", item.createdAtUtc)
|
||||
assertEquals("2026-06-21T00:01:00Z", item.reply?.createdAtUtc)
|
||||
assertEquals("hello fan talk", item.content)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `creatorReplies가 비어 있으면 reply는 null이다`() {
|
||||
val item = listOf(fanTalk(creatorReplies = emptyList()))
|
||||
.toFanTalkUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L)
|
||||
.toFanTalkUiModels(isOwner = false, currentUserId = 99L)
|
||||
.single()
|
||||
|
||||
assertNull(item.reply)
|
||||
@@ -56,7 +49,7 @@ class CreatorChannelFanTalkMapperTest {
|
||||
reply(fanTalkId = 3L, content = "second reply")
|
||||
)
|
||||
)
|
||||
).toFanTalkUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L).single()
|
||||
).toFanTalkUiModels(isOwner = false, currentUserId = 99L).single()
|
||||
|
||||
assertEquals(2L, item.reply?.fanTalkId)
|
||||
assertEquals("first reply", item.reply?.content)
|
||||
@@ -65,7 +58,7 @@ class CreatorChannelFanTalkMapperTest {
|
||||
@Test
|
||||
fun `내가 쓴 글이면 수정과 삭제 owner more action이다`() {
|
||||
val item = listOf(fanTalk(writerId = 10L))
|
||||
.toFanTalkUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 10L)
|
||||
.toFanTalkUiModels(isOwner = false, currentUserId = 10L)
|
||||
.single()
|
||||
|
||||
val action = item.rightAction as CreatorChannelFanTalkRightAction.OwnerMore
|
||||
@@ -76,7 +69,7 @@ class CreatorChannelFanTalkMapperTest {
|
||||
@Test
|
||||
fun `내 채널의 타인 글이면 삭제만 가능한 owner more action이다`() {
|
||||
val item = listOf(fanTalk(writerId = 11L))
|
||||
.toFanTalkUiModels(relativeTimeTextFormatter, isOwner = true, currentUserId = 10L)
|
||||
.toFanTalkUiModels(isOwner = true, currentUserId = 10L)
|
||||
.single()
|
||||
|
||||
val action = item.rightAction as CreatorChannelFanTalkRightAction.OwnerMore
|
||||
@@ -87,7 +80,7 @@ class CreatorChannelFanTalkMapperTest {
|
||||
@Test
|
||||
fun `내가 쓴 글도 아니고 내 채널도 아니면 신고 action이다`() {
|
||||
val item = listOf(fanTalk(writerId = 11L))
|
||||
.toFanTalkUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 10L)
|
||||
.toFanTalkUiModels(isOwner = false, currentUserId = 10L)
|
||||
.single()
|
||||
|
||||
assertTrue(item.rightAction is CreatorChannelFanTalkRightAction.Report)
|
||||
@@ -96,7 +89,7 @@ class CreatorChannelFanTalkMapperTest {
|
||||
@Test
|
||||
fun `원글과 답글 content가 빈 문자열이어도 item을 유지한다`() {
|
||||
val item = listOf(fanTalk(content = "", creatorReplies = listOf(reply(content = ""))))
|
||||
.toFanTalkUiModels(relativeTimeTextFormatter, isOwner = false, currentUserId = 99L)
|
||||
.toFanTalkUiModels(isOwner = false, currentUserId = 99L)
|
||||
.single()
|
||||
|
||||
assertEquals("", item.content)
|
||||
@@ -123,13 +116,14 @@ class CreatorChannelFanTalkMapperTest {
|
||||
private fun reply(
|
||||
fanTalkId: Long = 2L,
|
||||
writerId: Long = 20L,
|
||||
content: String = "reply"
|
||||
content: String = "reply",
|
||||
createdAtUtc: String = "2026-06-21T00:00:00Z"
|
||||
) = CreatorChannelFanTalkReplyResponse(
|
||||
fanTalkId = fanTalkId,
|
||||
writerId = writerId,
|
||||
writerNickname = "creator",
|
||||
writerProfileImageUrl = "creator.png",
|
||||
content = content,
|
||||
createdAtUtc = "2026-06-21T00:00:00Z"
|
||||
createdAtUtc = createdAtUtc
|
||||
)
|
||||
}
|
||||
|
||||
+1
-2
@@ -12,7 +12,6 @@ import io.reactivex.rxjava3.plugins.RxJavaPlugins
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import io.reactivex.rxjava3.subjects.SingleSubject
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.AndroidUtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkResponse
|
||||
@@ -46,7 +45,7 @@ class CreatorChannelFanTalkPaginationTest {
|
||||
SharedPreferenceManager.token = "test-token"
|
||||
SharedPreferenceManager.userId = 10L
|
||||
repository = org.mockito.kotlin.mock()
|
||||
viewModel = CreatorChannelFanTalkViewModel(repository, AndroidUtcRelativeTimeTextFormatter(context))
|
||||
viewModel = CreatorChannelFanTalkViewModel(repository)
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
+1
-2
@@ -11,7 +11,6 @@ import io.reactivex.rxjava3.core.Single
|
||||
import io.reactivex.rxjava3.plugins.RxJavaPlugins
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.AndroidUtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkResponse
|
||||
@@ -45,7 +44,7 @@ class CreatorChannelFanTalkViewModelTest {
|
||||
SharedPreferenceManager.token = "test-token"
|
||||
SharedPreferenceManager.userId = 10L
|
||||
repository = org.mockito.kotlin.mock()
|
||||
viewModel = CreatorChannelFanTalkViewModel(repository, AndroidUtcRelativeTimeTextFormatter(context))
|
||||
viewModel = CreatorChannelFanTalkViewModel(repository)
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
+46
-1
@@ -1,12 +1,23 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.fantalk.detail
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.common.formatUtcRelativeTimeText
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], application = Application::class)
|
||||
class CreatorChannelFanTalkDetailUiContractTest {
|
||||
|
||||
@Test
|
||||
@@ -50,6 +61,33 @@ class CreatorChannelFanTalkDetailUiContractTest {
|
||||
assertTrue(source.contains("R.drawable.ic_new_arrow_up_gray"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `영어와 일본어 상세 bind는 원글과 답글 raw UTC를 현재 View locale 상대 시간으로 표시한다`() {
|
||||
val source = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/fantalk/detail/CreatorChannelFanTalkDetailActivity.kt"
|
||||
).readText()
|
||||
assertTrue(
|
||||
Regex(
|
||||
"tvCreatorChannelFantalkDetailTime\\.text\\s*=\\s*" +
|
||||
"formatUtcRelativeTimeText\\(tvCreatorChannelFantalkDetailTime\\.context, item\\.createdAtUtc\\)"
|
||||
).containsMatchIn(source)
|
||||
)
|
||||
assertTrue(
|
||||
Regex(
|
||||
"tvCreatorChannelFantalkDetailReplyTime\\.text\\s*=\\s*" +
|
||||
"formatUtcRelativeTimeText\\(tvCreatorChannelFantalkDetailReplyTime\\.context, reply\\.createdAtUtc\\)"
|
||||
).containsMatchIn(source)
|
||||
)
|
||||
|
||||
listOf(Locale.ENGLISH, Locale.JAPANESE).forEach { locale ->
|
||||
val context = localizedContext(locale)
|
||||
assertEquals(
|
||||
context.getString(R.string.character_comment_time_just_now),
|
||||
formatUtcRelativeTimeText(context, System.currentTimeMillis().toString())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `상세 layout은 커뮤니티 답글 구조와 FanTalk 답글 card 토큰을 사용한다`() {
|
||||
val layout = projectFile("app/src/main/res/layout/activity_creator_channel_fantalk_detail.xml").readText()
|
||||
@@ -113,7 +151,7 @@ class CreatorChannelFanTalkDetailUiContractTest {
|
||||
"CreatorChannelFanTalkDetailViewModel"
|
||||
)
|
||||
)
|
||||
assertTrue(appDi.contains("viewModel { CreatorChannelFanTalkDetailViewModel(get(), get()) }"))
|
||||
assertTrue(appDi.contains("viewModel { CreatorChannelFanTalkDetailViewModel(get()) }"))
|
||||
assertTrue(viewModel.contains("fun cancelReplyEdit()"))
|
||||
assertTrue(viewModel.contains("fun consumeReplyChangedEvent()"))
|
||||
}
|
||||
@@ -153,6 +191,13 @@ class CreatorChannelFanTalkDetailUiContractTest {
|
||||
|
||||
private fun projectFile(path: String): File = File(projectRoot(), path)
|
||||
|
||||
private fun localizedContext(locale: Locale): Context {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
val configuration = Configuration(context.resources.configuration)
|
||||
configuration.setLocale(locale)
|
||||
return context.createConfigurationContext(configuration)
|
||||
}
|
||||
|
||||
private fun projectRoot(): File {
|
||||
return generateSequence(File(System.getProperty("user.dir") ?: ".").absoluteFile) { it.parentFile }
|
||||
.first { File(it, "settings.gradle").exists() }
|
||||
|
||||
+4
-8
@@ -15,7 +15,6 @@ import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.common.SodaLiveApplicationHolder
|
||||
import kr.co.vividnext.sodalive.common.ToastMessage
|
||||
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkReplyResponse
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.model.CreatorChannelFanTalkReplyUiModel
|
||||
@@ -52,10 +51,7 @@ class CreatorChannelFanTalkDetailViewModelTest {
|
||||
SharedPreferenceManager.init(context)
|
||||
SharedPreferenceManager.token = "test-token"
|
||||
repository = org.mockito.kotlin.mock()
|
||||
viewModel = CreatorChannelFanTalkDetailViewModel(
|
||||
repository,
|
||||
UtcRelativeTimeTextFormatter { value -> "relative:$value" }
|
||||
)
|
||||
viewModel = CreatorChannelFanTalkDetailViewModel(repository)
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -109,7 +105,7 @@ class CreatorChannelFanTalkDetailViewModelTest {
|
||||
assertEquals("server-creator", state.reply?.writerNickname)
|
||||
assertEquals("server-creator.png", state.reply?.writerProfileImageUrl)
|
||||
assertEquals("새 답글", state.reply?.content)
|
||||
assertEquals("relative:2026-07-09T01:02:03Z", state.reply?.createdAtText)
|
||||
assertEquals("2026-07-09T01:02:03Z", state.reply?.createdAtUtc)
|
||||
assertEquals(null, viewModel.toastLiveData.requireValue()?.consume())
|
||||
assertTrue(viewModel.replyChangedEventLiveData.requireValue() == true)
|
||||
}
|
||||
@@ -292,7 +288,7 @@ class CreatorChannelFanTalkDetailViewModelTest {
|
||||
writerNickname = "fan",
|
||||
writerProfileImageUrl = "fan.png",
|
||||
content = "응원 원문",
|
||||
createdAtText = "방금 전",
|
||||
createdAtUtc = "2026-07-09T00:00:00Z",
|
||||
reply = reply,
|
||||
rightAction = CreatorChannelFanTalkRightAction.OwnerMore(showEdit = false, showDelete = true)
|
||||
)
|
||||
@@ -303,7 +299,7 @@ class CreatorChannelFanTalkDetailViewModelTest {
|
||||
writerNickname = "creator",
|
||||
writerProfileImageUrl = "creator.png",
|
||||
content = content,
|
||||
createdAtText = "방금 전"
|
||||
createdAtUtc = "2026-07-09T00:01:00Z"
|
||||
)
|
||||
|
||||
private fun LiveData<CreatorChannelFanTalkDetailUiState>.requireContent(): CreatorChannelFanTalkDetailUiState.Content {
|
||||
|
||||
Reference in New Issue
Block a user