feat(home): 추천 상태 observe를 연결한다

This commit is contained in:
2026-06-05 16:01:37 +09:00
parent 6679808a18
commit c6680d0bd2
2 changed files with 163 additions and 153 deletions

View File

@@ -51,6 +51,7 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertSame
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@@ -927,6 +928,27 @@ class HomeMainFragmentLayoutTest {
}
}
@Test
fun `home main fragment phase9 replaces sample content with viewmodel state binding`() {
val source = homeMainFragmentSource()
assertFalse(source.contains("phase6SampleContent"))
assertTrue(source.contains("HomeRecommendationViewModel"))
assertTrue(source.contains("recommendationStateLiveData.observe(viewLifecycleOwner)"))
assertTrue(source.contains("homeRecommendationViewModel.loadRecommendations()"))
}
@Test
fun `home main fragment phase9 connects loading toast and follow all callbacks`() {
val source = homeMainFragmentSource()
assertTrue(source.contains("isLoading.observe(viewLifecycleOwner)"))
assertTrue(source.contains("toastLiveData.observe(viewLifecycleOwner)"))
assertTrue(source.contains("showToast"))
assertTrue(source.contains("followCreators(SECTION_KEY_CHEER_CREATORS"))
assertTrue(source.contains("followCreators(genreSectionKey"))
}
private fun TextView.clickableSpanCount(): Int {
val spanned = text as? Spanned ?: return 0
return spanned.getSpans(0, spanned.length, ClickableSpan::class.java).size
@@ -937,6 +959,14 @@ class HomeMainFragmentLayoutTest {
spanned.getSpans(0, spanned.length, ClickableSpan::class.java).last().onClick(this)
}
private fun homeMainFragmentSource(): String {
val projectRoot = java.io.File("..").canonicalFile
return java.io.File(
projectRoot,
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/HomeMainFragment.kt"
).readText()
}
private fun inflateView(layoutResId: Int): View {
val context = ApplicationProvider.getApplicationContext<Context>()
return LayoutInflater.from(context).inflate(layoutResId, null, false)