test(content): FIRST 오디오 전체보기 테스트를 정리한다

This commit is contained in:
2026-06-29 17:40:39 +09:00
parent 78573d0e81
commit 3e14cf4320
3 changed files with 8 additions and 50 deletions

View File

@@ -84,17 +84,13 @@ class ContentOverviewActivitySourceTest {
}
@Test
fun `manifest registers ContentOverviewActivity and Phase 7 routing is added`() {
fun `manifest registers ContentOverviewActivity and New Hot routing is added`() {
val manifest = projectFile("app/src/main/AndroidManifest.xml").readText()
val homeSource = projectFile(
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragment.kt"
).readText()
val contentSource = projectFile(
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/content/ContentMainFragment.kt"
).readText()
assertTrue(manifest.contains(".v2.main.content.overview.ContentOverviewActivity"))
assertTrue(homeSource.contains("viewHomeFirstAudioTitle.ivSectionTitleChevron.setOnClickListener"))
assertTrue(contentSource.contains("viewContentNewAndHotTitle.ivSectionTitleChevron.setOnClickListener"))
}

View File

@@ -21,10 +21,6 @@ class ContentOverviewMapperTest {
R.string.content_recommendation_section_new_and_hot,
ContentOverviewType.NEW_AND_HOT_AUDIO.toTitleResId()
)
assertEquals(
R.string.home_recommendation_section_first_audio_contents,
ContentOverviewType.FIRST_AUDIO_CONTENT.toTitleResId()
)
}
@Test
@@ -60,14 +56,14 @@ class ContentOverviewMapperTest {
@Test
fun `page response preserves paging metadata and type`() {
val content = pageResponse(
type = ContentOverviewType.FIRST_AUDIO_CONTENT,
type = ContentOverviewType.NEW_AND_HOT_AUDIO,
page = 2,
size = 20,
hasNext = true,
items = listOf(item(contentId = 7L))
).toContent()
assertEquals(ContentOverviewType.FIRST_AUDIO_CONTENT, content.type)
assertEquals(ContentOverviewType.NEW_AND_HOT_AUDIO, content.type)
assertEquals(2, content.page)
assertEquals(20, content.size)
assertTrue(content.hasNext)

View File

@@ -10,7 +10,6 @@ import io.reactivex.rxjava3.core.Scheduler
import io.reactivex.rxjava3.core.Single
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.SharedPreferenceManager
import kr.co.vividnext.sodalive.v2.main.content.overview.data.ContentOverviewItemResponse
@@ -58,12 +57,12 @@ class ContentOverviewViewModelTest {
@Test
fun `초기 로드는 전달받은 type으로 첫 페이지를 요청하고 Content를 emit한다`() {
stubGetContents(
type = ContentOverviewType.FIRST_AUDIO_CONTENT,
type = ContentOverviewType.NEW_AND_HOT_AUDIO,
response = Single.just(
ApiResponse(
true,
pageResponse(
type = ContentOverviewType.FIRST_AUDIO_CONTENT,
type = ContentOverviewType.NEW_AND_HOT_AUDIO,
items = listOf(item(11L))
),
null
@@ -71,14 +70,14 @@ class ContentOverviewViewModelTest {
)
)
viewModel.loadFirstPage(ContentOverviewType.FIRST_AUDIO_CONTENT)
viewModel.loadFirstPage(ContentOverviewType.NEW_AND_HOT_AUDIO)
val state = viewModel.overviewStateLiveData.requireValue() as ContentOverviewUiState.Content
assertEquals(ContentOverviewType.FIRST_AUDIO_CONTENT, state.type)
assertEquals(ContentOverviewType.NEW_AND_HOT_AUDIO, state.type)
assertEquals(0, state.page)
assertEquals(20, state.size)
assertEquals(listOf(11L), state.items.map { it.contentId })
verifyGetContents(type = ContentOverviewType.FIRST_AUDIO_CONTENT, page = 0)
verifyGetContents(type = ContentOverviewType.NEW_AND_HOT_AUDIO, page = 0)
}
@Test
@@ -200,39 +199,6 @@ class ContentOverviewViewModelTest {
assertEquals("page failed", state.paginationErrorMessage)
}
@Test
fun `새 type 요청 이후 이전 stale response는 현재 상태를 덮어쓰지 않는다`() {
val pending = SingleSubject.create<ApiResponse<ContentOverviewPageResponse>>()
stubGetContents(type = ContentOverviewType.NEW_AND_HOT_AUDIO, response = pending)
stubGetContents(
type = ContentOverviewType.FIRST_AUDIO_CONTENT,
response = Single.just(
ApiResponse(
true,
pageResponse(
type = ContentOverviewType.FIRST_AUDIO_CONTENT,
items = listOf(item(9L))
),
null
)
)
)
viewModel.loadFirstPage(ContentOverviewType.NEW_AND_HOT_AUDIO)
viewModel.loadFirstPage(ContentOverviewType.FIRST_AUDIO_CONTENT)
pending.onSuccess(
ApiResponse(
true,
pageResponse(items = listOf(item(1L))),
null
)
)
val state = viewModel.overviewStateLiveData.requireValue() as ContentOverviewUiState.Content
assertEquals(ContentOverviewType.FIRST_AUDIO_CONTENT, state.type)
assertEquals(listOf(9L), state.items.map { it.contentId })
}
private fun stubGetContents(
type: ContentOverviewType = ContentOverviewType.NEW_AND_HOT_AUDIO,
page: Int = 0,