test(home): 추천 응답 스키마 검증을 추가한다
This commit is contained in:
@@ -21,6 +21,15 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.test.core.app.ApplicationProvider
|
import androidx.test.core.app.ApplicationProvider
|
||||||
import kr.co.vividnext.sodalive.R
|
import kr.co.vividnext.sodalive.R
|
||||||
|
import kr.co.vividnext.sodalive.settings.event.EventItem
|
||||||
|
import kr.co.vividnext.sodalive.v2.main.home.data.HomeActiveCreatorItem
|
||||||
|
import kr.co.vividnext.sodalive.v2.main.home.data.HomeBannerItem
|
||||||
|
import kr.co.vividnext.sodalive.v2.main.home.data.HomeCreatorItem
|
||||||
|
import kr.co.vividnext.sodalive.v2.main.home.data.HomeFirstAudioContentItem
|
||||||
|
import kr.co.vividnext.sodalive.v2.main.home.data.HomeGenreCreatorGroupItem
|
||||||
|
import kr.co.vividnext.sodalive.v2.main.home.data.HomeLiveItem
|
||||||
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationBannerSection
|
||||||
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationBannerUiModel
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationFirstAudioContentUiModel
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationFirstAudioContentUiModel
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationCreatorUiModel
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationCreatorUiModel
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationGenreCreatorGroupUiModel
|
import kr.co.vividnext.sodalive.v2.main.home.model.HomeRecommendationGenreCreatorGroupUiModel
|
||||||
@@ -33,6 +42,7 @@ import kr.co.vividnext.sodalive.v2.main.home.model.visibleHomePopularCommunityPo
|
|||||||
import kr.co.vividnext.sodalive.v2.main.home.model.visibleHomeGenreCreatorGroups
|
import kr.co.vividnext.sodalive.v2.main.home.model.visibleHomeGenreCreatorGroups
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.data.HomePopularCommunityPostItem
|
import kr.co.vividnext.sodalive.v2.main.home.data.HomePopularCommunityPostItem
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeAiCharacterAdapter
|
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeAiCharacterAdapter
|
||||||
|
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeBannerBinder
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeBusinessInfoBinder
|
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeBusinessInfoBinder
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeCheerCreatorAdapter
|
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeCheerCreatorAdapter
|
||||||
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeFirstAudioAdapter
|
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeFirstAudioAdapter
|
||||||
@@ -719,6 +729,116 @@ class HomeMainFragmentLayoutTest {
|
|||||||
assertEquals("https://example.com/audio.m4a", item.toUiModel().item.audioUrl)
|
assertEquals("https://example.com/audio.m4a", item.toUiModel().item.audioUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `home recommendation mapper uses changed response fields`() {
|
||||||
|
val live = HomeLiveItem(
|
||||||
|
roomId = 10L,
|
||||||
|
creatorNickname = "라이브 크리에이터",
|
||||||
|
creatorProfileImage = "https://example.com/live.png"
|
||||||
|
).toUiModel()
|
||||||
|
val eventItem = EventItem(
|
||||||
|
id = 20L,
|
||||||
|
thumbnailImageUrl = "https://example.com/event.png",
|
||||||
|
link = "sodalive://event/20"
|
||||||
|
)
|
||||||
|
val banner = HomeBannerItem(
|
||||||
|
imageUrl = "https://example.com/banner.png",
|
||||||
|
eventItem = eventItem,
|
||||||
|
creatorId = 30L,
|
||||||
|
seriesId = 40L,
|
||||||
|
link = "https://example.com"
|
||||||
|
).toUiModel()
|
||||||
|
val activeCreator = HomeActiveCreatorItem(
|
||||||
|
creatorNickname = "활동 크리에이터",
|
||||||
|
creatorProfileImage = "https://example.com/active.png",
|
||||||
|
activityType = "AUDIO",
|
||||||
|
activityAt = "방금 전",
|
||||||
|
targetId = 50L
|
||||||
|
).toUiModel()
|
||||||
|
val creator = HomeCreatorItem(
|
||||||
|
creatorId = 60L,
|
||||||
|
creatorNickname = "추천 크리에이터",
|
||||||
|
creatorProfileImage = "https://example.com/creator.png"
|
||||||
|
).toUiModel()
|
||||||
|
val firstAudio = HomeFirstAudioContentItem(
|
||||||
|
contentId = 70L,
|
||||||
|
creatorId = 80L,
|
||||||
|
creatorNickname = "오디오 크리에이터",
|
||||||
|
creatorProfileImage = "https://example.com/audio-creator.png",
|
||||||
|
title = "첫 오디오",
|
||||||
|
price = 0,
|
||||||
|
coverImage = "https://example.com/cover.png",
|
||||||
|
isPointAvailable = true
|
||||||
|
).toUiModel()
|
||||||
|
val genreGroup = HomeGenreCreatorGroupItem(
|
||||||
|
genreName = "로맨스",
|
||||||
|
creators = listOf(
|
||||||
|
HomeCreatorItem(
|
||||||
|
creatorId = 90L,
|
||||||
|
creatorNickname = "장르 크리에이터",
|
||||||
|
creatorProfileImage = "https://example.com/genre.png"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
).toUiModel()
|
||||||
|
|
||||||
|
assertEquals(10L, live.roomId)
|
||||||
|
assertEquals("https://example.com/live.png", live.creatorProfileImage)
|
||||||
|
assertEquals("https://example.com/banner.png", banner.imageUrl)
|
||||||
|
assertEquals(eventItem, banner.eventItem)
|
||||||
|
assertEquals(30L, banner.creatorId)
|
||||||
|
assertEquals(40L, banner.seriesId)
|
||||||
|
assertEquals("https://example.com", banner.link)
|
||||||
|
assertEquals("활동 크리에이터", activeCreator.nickname)
|
||||||
|
assertEquals("https://example.com/active.png", activeCreator.profileImage)
|
||||||
|
assertEquals("방금 전", activeCreator.activityAt)
|
||||||
|
assertEquals(50L, activeCreator.targetId)
|
||||||
|
assertEquals("추천 크리에이터", creator.nickname)
|
||||||
|
assertEquals("https://example.com/creator.png", creator.profileImage)
|
||||||
|
assertEquals("https://example.com/audio-creator.png", firstAudio.creatorProfileImage)
|
||||||
|
assertEquals(setOf(AudioContentTag.First, AudioContentTag.Point, AudioContentTag.Free), firstAudio.tags)
|
||||||
|
assertEquals("로맨스", genreGroup.genre)
|
||||||
|
assertEquals("장르 크리에이터", genreGroup.creators.first().nickname)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `home banner binder matches duplicate image banners by position`() {
|
||||||
|
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||||
|
val bannerView = BannerView(context)
|
||||||
|
val clickedItems = mutableListOf<String?>()
|
||||||
|
val binder = HomeBannerBinder(bannerView).apply {
|
||||||
|
setOnBannerClick { item -> clickedItems.add(item.link) }
|
||||||
|
}
|
||||||
|
|
||||||
|
binder.bind(
|
||||||
|
HomeRecommendationBannerSection(
|
||||||
|
listOf(
|
||||||
|
HomeRecommendationBannerUiModel(
|
||||||
|
imageUrl = "",
|
||||||
|
eventItem = null,
|
||||||
|
creatorId = null,
|
||||||
|
seriesId = null,
|
||||||
|
link = "first"
|
||||||
|
),
|
||||||
|
HomeRecommendationBannerUiModel(
|
||||||
|
imageUrl = "",
|
||||||
|
eventItem = null,
|
||||||
|
creatorId = null,
|
||||||
|
seriesId = null,
|
||||||
|
link = "second"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val recyclerView = bannerView.findViewById<RecyclerView>(R.id.rv_banner)
|
||||||
|
val adapter = requireNotNull(recyclerView.adapter)
|
||||||
|
val viewHolder = adapter.onCreateViewHolder(recyclerView, 0)
|
||||||
|
|
||||||
|
adapter.onBindViewHolder(viewHolder, 1)
|
||||||
|
viewHolder.itemView.performClick()
|
||||||
|
|
||||||
|
assertEquals(listOf("second"), clickedItems)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `home popular community adapter does not load original image for locked paid post`() {
|
fun `home popular community adapter does not load original image for locked paid post`() {
|
||||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||||
@@ -993,12 +1113,9 @@ class HomeMainFragmentLayoutTest {
|
|||||||
|
|
||||||
private fun liveItem(id: Long): HomeRecommendationLiveUiModel {
|
private fun liveItem(id: Long): HomeRecommendationLiveUiModel {
|
||||||
return HomeRecommendationLiveUiModel(
|
return HomeRecommendationLiveUiModel(
|
||||||
liveId = id,
|
roomId = id,
|
||||||
creatorId = id,
|
|
||||||
imageUrl = null,
|
|
||||||
title = "title$id",
|
|
||||||
creatorNickname = "creator$id",
|
creatorNickname = "creator$id",
|
||||||
beginDateTime = null
|
creatorProfileImage = "https://example.com/live$id.png"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1007,11 +1124,10 @@ class HomeMainFragmentLayoutTest {
|
|||||||
contentId = 1L,
|
contentId = 1L,
|
||||||
creatorId = 1L,
|
creatorId = 1L,
|
||||||
creatorNickname = "크리에이터 이름",
|
creatorNickname = "크리에이터 이름",
|
||||||
creatorProfileImage = null,
|
creatorProfileImage = "",
|
||||||
title = "콘텐츠 제목",
|
title = "콘텐츠 제목",
|
||||||
price = 0,
|
price = 0,
|
||||||
coverImage = null,
|
coverImage = null,
|
||||||
releaseDate = "",
|
|
||||||
tags = setOf(AudioContentTag.First, AudioContentTag.Point, AudioContentTag.Free)
|
tags = setOf(AudioContentTag.First, AudioContentTag.Point, AudioContentTag.Free)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1068,7 +1184,7 @@ class HomeMainFragmentLayoutTest {
|
|||||||
HomeRecommendationCreatorUiModel(
|
HomeRecommendationCreatorUiModel(
|
||||||
creatorId = creatorId,
|
creatorId = creatorId,
|
||||||
nickname = "크리에이터$creatorId",
|
nickname = "크리에이터$creatorId",
|
||||||
profileImage = null
|
profileImage = ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user