From 97c4b1ed1f3d17cdc084188e3c0ccc863993b607 Mon Sep 17 00:00:00 2001 From: Klaus Date: Fri, 10 Jul 2026 10:16:52 +0900 Subject: [PATCH] =?UTF-8?q?test(home):=20=EB=A9=94=EC=9D=B8=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20=ED=83=AD=20=EC=9C=A0=EB=A3=8C=20=EC=98=A4=EB=94=94?= =?UTF-8?q?=EC=98=A4=20=ED=95=84=ED=84=B0=EB=A5=BC=20=EA=B2=80=EC=A6=9D?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../in/web/MainContentAllEndToEndTest.kt | 38 ++++++++++++++++++- ...efaultMainContentAllQueryRepositoryTest.kt | 3 ++ 2 files changed, 40 insertions(+), 1 deletion(-) 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)