diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/content/all/adapter/in/web/MainContentAllEndToEndTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/content/all/adapter/in/web/MainContentAllEndToEndTest.kt index 7cfd95bc..41ff9136 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/content/all/adapter/in/web/MainContentAllEndToEndTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/api/content/all/adapter/in/web/MainContentAllEndToEndTest.kt @@ -68,6 +68,32 @@ class MainContentAllEndToEndTest @Autowired constructor( .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 @DisplayName("전체 탭 SERIES API는 dayOfWeek 조건으로 시리즈 응답과 빈 audios를 반환한다") fun shouldReturnSeriesContentsFilteredByDayOfWeekThroughControllerServiceAndRepository() { @@ -124,7 +150,7 @@ class MainContentAllEndToEndTest @Autowired constructor( .andExpect(jsonPath("$.data.hasNext").value(false)) } - private fun createAudioFixture(prefix: String): AudioFixture { + private fun createAudioFixture(prefix: String, freeControl: Boolean = false): AudioFixture { return transactionTemplate.execute { val creator = saveMember("$prefix-creator", MemberRole.CREATOR) val theme = saveTheme("$prefix-theme") @@ -136,6 +162,16 @@ class MainContentAllEndToEndTest @Autowired constructor( releaseDate = LocalDateTime.now().minusHours(1), 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.clear() diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/content/all/adapter/out/persistence/DefaultMainContentAllQueryRepositoryTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/content/all/adapter/out/persistence/DefaultMainContentAllQueryRepositoryTest.kt index a0b6fa43..7b993f70 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/content/all/adapter/out/persistence/DefaultMainContentAllQueryRepositoryTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/content/all/adapter/out/persistence/DefaultMainContentAllQueryRepositoryTest.kt @@ -62,11 +62,14 @@ class DefaultMainContentAllQueryRepositoryTest @Autowired constructor( flushAndClear() 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 pointAudios = repository.findAudios(null, false, now, ContentSort.LATEST, 0, 20, onlyPointAvailable = true) 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), paidAudios.map { it.audioContentId }) assertEquals(listOf(free.id), freeAudios.map { it.audioContentId }) assertEquals(listOf(point.id), pointAudios.map { it.audioContentId }) assertEquals("https://cdn.test/audio.png", visible.first().imageUrl)