test(creator-channel): 커뮤니티 상세 UI 계약을 검증한다

This commit is contained in:
2026-07-09 00:54:12 +09:00
parent 81537b1e96
commit 536effab40
4 changed files with 133 additions and 0 deletions

View File

@@ -361,6 +361,14 @@
<string name="creator_channel_community_error_message">Could not load community.</string>
<string name="creator_channel_community_retry_button">Retry</string>
<string name="creator_channel_community_notice">Notice</string>
<string name="creator_channel_community_detail_title">Community</string>
<string name="creator_channel_community_reply_title">Replies</string>
<string name="creator_channel_community_comment_placeholder">Enter a comment</string>
<string name="creator_channel_community_reply_placeholder">Enter a reply</string>
<string name="creator_channel_community_comment_header">Comments %1$s</string>
<string name="creator_channel_community_comment_unavailable">Comments are unavailable for this post.</string>
<string name="creator_channel_community_invalid_post">Could not load the post.</string>
<string name="creator_channel_community_purchased_badge">Purchased</string>
<string name="creator_channel_fantalk_summary">%1$s · Total %2$d</string>
<string name="creator_channel_fantalk_empty_title">Be the first\nto cheer them on!</string>
<string name="creator_channel_fantalk_support_action">Leave support</string>

View File

@@ -361,6 +361,14 @@
<string name="creator_channel_community_error_message">コミュニティを読み込めませんでした。</string>
<string name="creator_channel_community_retry_button">再試行</string>
<string name="creator_channel_community_notice">お知らせ</string>
<string name="creator_channel_community_detail_title">コミュニティ</string>
<string name="creator_channel_community_reply_title">返信</string>
<string name="creator_channel_community_comment_placeholder">コメントを入力してください</string>
<string name="creator_channel_community_reply_placeholder">返信を入力してください</string>
<string name="creator_channel_community_comment_header">コメント %1$s</string>
<string name="creator_channel_community_comment_unavailable">この投稿ではコメントを利用できません。</string>
<string name="creator_channel_community_invalid_post">投稿を読み込めません。</string>
<string name="creator_channel_community_purchased_badge">購入済み</string>
<string name="creator_channel_fantalk_summary">%1$s · 全体 %2$d</string>
<string name="creator_channel_fantalk_empty_title">最初の応援を\n待っています</string>
<string name="creator_channel_fantalk_support_action">応援を残す</string>

View File

@@ -360,6 +360,14 @@
<string name="creator_channel_community_error_message">커뮤니티를 불러오지 못했습니다.</string>
<string name="creator_channel_community_retry_button">다시 시도</string>
<string name="creator_channel_community_notice">공지</string>
<string name="creator_channel_community_detail_title">커뮤니티</string>
<string name="creator_channel_community_reply_title">답글</string>
<string name="creator_channel_community_comment_placeholder">댓글을 입력하세요</string>
<string name="creator_channel_community_reply_placeholder">답글을 입력하세요</string>
<string name="creator_channel_community_comment_header">댓글 %1$s</string>
<string name="creator_channel_community_comment_unavailable">댓글을 사용할 수 없는 게시물입니다.</string>
<string name="creator_channel_community_invalid_post">게시물을 불러올 수 없습니다.</string>
<string name="creator_channel_community_purchased_badge">구매 완료</string>
<string name="creator_channel_fantalk_summary">%1$s · 전체 %2$d</string>
<string name="creator_channel_fantalk_empty_title">당신의 첫 응원을\n기다리고 있어요!</string>
<string name="creator_channel_fantalk_support_action">응원 남기기</string>

View File

@@ -0,0 +1,109 @@
package kr.co.vividnext.sodalive.v2.creator.channel.community
import android.app.Application
import android.view.LayoutInflater
import android.view.View
import android.widget.EditText
import android.widget.ImageButton
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import androidx.test.core.app.ApplicationProvider
import kr.co.vividnext.sodalive.R
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
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
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28], application = Application::class)
class CreatorChannelCommunityDetailReplyUiContractTest {
@Test
fun `상세와 답글 activity layout은 title back content input bar 계약을 제공한다`() {
val detail = inflateView(R.layout.activity_creator_channel_community_detail)
val reply = inflateView(R.layout.activity_creator_channel_community_reply)
assertNotNull(detail.findViewById<ImageButton>(R.id.btn_creator_channel_community_detail_back))
assertNotNull(detail.findViewById<TextView>(R.id.tv_creator_channel_community_detail_title))
assertNotNull(detail.findViewById<TextView>(R.id.tv_creator_channel_community_detail_comment_header))
assertNotNull(detail.findViewById<RecyclerView>(R.id.rv_creator_channel_community_detail_comments))
assertNotNull(detail.findViewById<View>(R.id.layout_creator_channel_community_detail_paywall))
assertNotNull(detail.findViewById<TextView>(R.id.tv_creator_channel_community_detail_paywall_price))
assertNotNull(detail.findViewById<View>(R.id.layout_creator_channel_community_detail_input_bar))
assertNotNull(detail.findViewById<EditText>(R.id.et_creator_channel_community_detail_comment))
assertNotNull(detail.findViewById<ImageButton>(R.id.btn_creator_channel_community_detail_send))
assertRemovedId("tv_creator_channel_community_detail_comment_unavailable")
assertNotNull(reply.findViewById<ImageButton>(R.id.btn_creator_channel_community_reply_back))
assertNotNull(reply.findViewById<TextView>(R.id.tv_creator_channel_community_reply_title))
assertNotNull(reply.findViewById<RecyclerView>(R.id.rv_creator_channel_community_reply))
assertNotNull(reply.findViewById<View>(R.id.layout_creator_channel_community_reply_input_bar))
assertNotNull(reply.findViewById<EditText>(R.id.et_creator_channel_community_reply))
assertNotNull(reply.findViewById<ImageButton>(R.id.btn_creator_channel_community_reply_send))
}
@Test
fun `상세와 답글 item layout은 more latest reply만 제공하고 reaction row를 제거한다`() {
val commentItem = inflateView(R.layout.item_creator_channel_community_comment)
val replyItem = inflateView(R.layout.item_creator_channel_community_reply)
assertNotNull(commentItem.findViewById<ImageView>(R.id.iv_creator_channel_community_comment_more))
assertNotNull(commentItem.findViewById<View>(R.id.layout_creator_channel_community_comment_latest_reply))
assertNotNull(commentItem.findViewById<TextView>(R.id.tv_creator_channel_community_comment_latest_reply_body))
assertRemovedId("iv_creator_channel_community_comment_heart")
assertRemovedId("layout_creator_channel_community_comment_reaction")
assertNotNull(replyItem.findViewById<ImageView>(R.id.iv_creator_channel_community_reply_item_more))
assertRemovedId("iv_creator_channel_community_reply_item_heart")
}
@Test
fun `커뮤니티 상세 답글 문자열은 한국어 영어 일본어에 존재한다`() {
listOf("values", "values-en", "values-ja").forEach { valuesDir ->
val strings = projectFile("app/src/main/res/$valuesDir/strings.xml").readText()
assertTrue(strings.contains("name=\"creator_channel_community_detail_title\""))
assertTrue(strings.contains("name=\"creator_channel_community_reply_title\""))
assertTrue(strings.contains("name=\"creator_channel_community_comment_placeholder\""))
assertTrue(strings.contains("name=\"creator_channel_community_reply_placeholder\""))
assertTrue(strings.contains("name=\"creator_channel_community_comment_header\""))
assertTrue(strings.contains("name=\"creator_channel_community_comment_unavailable\""))
assertTrue(strings.contains("name=\"creator_channel_community_invalid_post\""))
}
}
@Test
fun `AppDI와 manifest는 상세 답글 Activity ViewModel을 등록한다`() {
val appDi = projectFile("app/src/main/java/kr/co/vividnext/sodalive/di/AppDI.kt").readText()
val manifest = projectFile("app/src/main/AndroidManifest.xml").readText()
assertTrue(appDi.contains("CreatorChannelCommunityDetailViewModel"))
assertTrue(appDi.contains("CreatorChannelCommunityReplyViewModel"))
assertTrue(manifest.contains(".v2.creator.channel.community.detail.CreatorChannelCommunityDetailActivity"))
assertTrue(manifest.contains(".v2.creator.channel.community.detail.reply.CreatorChannelCommunityReplyActivity"))
assertTrue(manifest.contains("android:windowSoftInputMode=\"stateAlwaysHidden|adjustResize\""))
}
private fun inflateView(layoutId: Int): View {
val context = ApplicationProvider.getApplicationContext<Application>()
return LayoutInflater.from(context).inflate(layoutId, null, false)
}
private fun assertRemovedId(name: String) {
val context = ApplicationProvider.getApplicationContext<Application>()
assertEquals(0, context.resources.getIdentifier(name, "id", context.packageName))
}
private fun projectFile(path: String): File {
var current = File(checkNotNull(System.getProperty("user.dir"))).absoluteFile
while (current.parentFile != null && !File(current, "settings.gradle").exists()) {
current = checkNotNull(current.parentFile)
}
return File(current, path)
}
}