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

@@ -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)
}
}