test(home): 메인 전체 탭 유료 오디오 필터를 검증한다
This commit is contained in:
@@ -68,6 +68,32 @@ class MainContentAllEndToEndTest @Autowired constructor(
|
|||||||
.andExpect(jsonPath("$.data.hasNext").value(false))
|
.andExpect(jsonPath("$.data.hasNext").value(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("전체 탭 AUDIO API는 명시적 AUDIO와 기본 type 조회에서 무료 오디오를 제외한다")
|
||||||
|
fun shouldExcludeFreeAudioContentsForAudioTypeAndDefaultType() {
|
||||||
|
val fixture = createAudioFixture("main-all-audio-paid-e2e", freeControl = true)
|
||||||
|
|
||||||
|
mockMvc.perform(
|
||||||
|
get("/api/v2/audio/contents")
|
||||||
|
.param("type", "AUDIO")
|
||||||
|
.param("sort", "LATEST")
|
||||||
|
)
|
||||||
|
.andExpect(status().isOk)
|
||||||
|
.andExpect(jsonPath("$.data.type").value("AUDIO"))
|
||||||
|
.andExpect(jsonPath("$.data.totalCount").value(1))
|
||||||
|
.andExpect(jsonPath("$.data.audios[0].audioContentId").value(fixture.audioContentId))
|
||||||
|
.andExpect(jsonPath("$.data.audios[0].price").value(100))
|
||||||
|
.andExpect(jsonPath("$.data.audios.length()").value(1))
|
||||||
|
|
||||||
|
mockMvc.perform(get("/api/v2/audio/contents"))
|
||||||
|
.andExpect(status().isOk)
|
||||||
|
.andExpect(jsonPath("$.data.type").value("AUDIO"))
|
||||||
|
.andExpect(jsonPath("$.data.totalCount").value(1))
|
||||||
|
.andExpect(jsonPath("$.data.audios[0].audioContentId").value(fixture.audioContentId))
|
||||||
|
.andExpect(jsonPath("$.data.audios[0].price").value(100))
|
||||||
|
.andExpect(jsonPath("$.data.audios.length()").value(1))
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("전체 탭 SERIES API는 dayOfWeek 조건으로 시리즈 응답과 빈 audios를 반환한다")
|
@DisplayName("전체 탭 SERIES API는 dayOfWeek 조건으로 시리즈 응답과 빈 audios를 반환한다")
|
||||||
fun shouldReturnSeriesContentsFilteredByDayOfWeekThroughControllerServiceAndRepository() {
|
fun shouldReturnSeriesContentsFilteredByDayOfWeekThroughControllerServiceAndRepository() {
|
||||||
@@ -124,7 +150,7 @@ class MainContentAllEndToEndTest @Autowired constructor(
|
|||||||
.andExpect(jsonPath("$.data.hasNext").value(false))
|
.andExpect(jsonPath("$.data.hasNext").value(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createAudioFixture(prefix: String): AudioFixture {
|
private fun createAudioFixture(prefix: String, freeControl: Boolean = false): AudioFixture {
|
||||||
return transactionTemplate.execute {
|
return transactionTemplate.execute {
|
||||||
val creator = saveMember("$prefix-creator", MemberRole.CREATOR)
|
val creator = saveMember("$prefix-creator", MemberRole.CREATOR)
|
||||||
val theme = saveTheme("$prefix-theme")
|
val theme = saveTheme("$prefix-theme")
|
||||||
@@ -136,6 +162,16 @@ class MainContentAllEndToEndTest @Autowired constructor(
|
|||||||
releaseDate = LocalDateTime.now().minusHours(1),
|
releaseDate = LocalDateTime.now().minusHours(1),
|
||||||
price = 100
|
price = 100
|
||||||
)
|
)
|
||||||
|
if (freeControl) {
|
||||||
|
saveAudioContent(
|
||||||
|
creator = creator,
|
||||||
|
theme = theme,
|
||||||
|
title = "$prefix-free-audio",
|
||||||
|
coverImage = "$prefix-free-audio.png",
|
||||||
|
releaseDate = LocalDateTime.now().minusMinutes(30),
|
||||||
|
price = 0
|
||||||
|
)
|
||||||
|
}
|
||||||
entityManager.flush()
|
entityManager.flush()
|
||||||
entityManager.clear()
|
entityManager.clear()
|
||||||
|
|
||||||
|
|||||||
@@ -62,11 +62,14 @@ class DefaultMainContentAllQueryRepositoryTest @Autowired constructor(
|
|||||||
flushAndClear()
|
flushAndClear()
|
||||||
|
|
||||||
val visible = repository.findAudios(viewer.id, canViewAdultContent = false, now, ContentSort.LATEST, 0, 20)
|
val visible = repository.findAudios(viewer.id, canViewAdultContent = false, now, ContentSort.LATEST, 0, 20)
|
||||||
|
val paidAudios = repository.findAudios(viewer.id, false, now, ContentSort.LATEST, 0, 20, onlyPaid = true)
|
||||||
val freeAudios = repository.findAudios(null, false, now, ContentSort.LATEST, 0, 20, onlyFree = true)
|
val freeAudios = repository.findAudios(null, false, now, ContentSort.LATEST, 0, 20, onlyFree = true)
|
||||||
val pointAudios = repository.findAudios(null, false, now, ContentSort.LATEST, 0, 20, onlyPointAvailable = true)
|
val pointAudios = repository.findAudios(null, false, now, ContentSort.LATEST, 0, 20, onlyPointAvailable = true)
|
||||||
|
|
||||||
assertEquals(2, repository.countAudios(viewer.id, canViewAdultContent = false, now))
|
assertEquals(2, repository.countAudios(viewer.id, canViewAdultContent = false, now))
|
||||||
|
assertEquals(1, repository.countAudios(viewer.id, false, now, onlyPaid = true))
|
||||||
assertEquals(listOf(point.id, free.id), visible.map { it.audioContentId })
|
assertEquals(listOf(point.id, free.id), visible.map { it.audioContentId })
|
||||||
|
assertEquals(listOf(point.id), paidAudios.map { it.audioContentId })
|
||||||
assertEquals(listOf(free.id), freeAudios.map { it.audioContentId })
|
assertEquals(listOf(free.id), freeAudios.map { it.audioContentId })
|
||||||
assertEquals(listOf(point.id), pointAudios.map { it.audioContentId })
|
assertEquals(listOf(point.id), pointAudios.map { it.audioContentId })
|
||||||
assertEquals("https://cdn.test/audio.png", visible.first().imageUrl)
|
assertEquals("https://cdn.test/audio.png", visible.first().imageUrl)
|
||||||
|
|||||||
Reference in New Issue
Block a user