diff --git a/src/test/java/com/funeat/acceptance/recipe/RecipeAcceptanceTest.java b/src/test/java/com/funeat/acceptance/recipe/RecipeAcceptanceTest.java index f2eee779..57198ace 100644 --- a/src/test/java/com/funeat/acceptance/recipe/RecipeAcceptanceTest.java +++ b/src/test/java/com/funeat/acceptance/recipe/RecipeAcceptanceTest.java @@ -46,9 +46,16 @@ import static com.funeat.fixture.ProductFixture.상품_애플망고_가격3000원_평점5점_생성; import static com.funeat.fixture.RecipeFixture.레시피; import static com.funeat.fixture.RecipeFixture.레시피1; +import static com.funeat.fixture.RecipeFixture.레시피10; +import static com.funeat.fixture.RecipeFixture.레시피11; import static com.funeat.fixture.RecipeFixture.레시피2; import static com.funeat.fixture.RecipeFixture.레시피3; import static com.funeat.fixture.RecipeFixture.레시피4; +import static com.funeat.fixture.RecipeFixture.레시피5; +import static com.funeat.fixture.RecipeFixture.레시피6; +import static com.funeat.fixture.RecipeFixture.레시피7; +import static com.funeat.fixture.RecipeFixture.레시피8; +import static com.funeat.fixture.RecipeFixture.레시피9; import static com.funeat.fixture.RecipeFixture.레시피_본문; import static com.funeat.fixture.RecipeFixture.레시피_제목; import static com.funeat.fixture.RecipeFixture.레시피좋아요요청_생성; @@ -389,7 +396,7 @@ class getSearchResults_성공_테스트 { // then STATUS_CODE를_검증한다(응답, 정상_처리); - 레시피_검색_결과를_검증한다(응답, List.of(레시피3, 레시피2)); + 레시피_검색_결과를_검증한다(응답, false, List.of(레시피3, 레시피2)); } @Test @@ -407,7 +414,7 @@ class getSearchResults_성공_테스트 { // then STATUS_CODE를_검증한다(응답, 정상_처리); - 레시피_검색_결과를_검증한다(응답, List.of(레시피)); + 레시피_검색_결과를_검증한다(응답, false, List.of(레시피)); } @Test @@ -424,7 +431,23 @@ class getSearchResults_성공_테스트 { // then STATUS_CODE를_검증한다(응답, 정상_처리); - 레시피_검색_결과를_검증한다(응답, Collections.emptyList()); + 레시피_검색_결과를_검증한다(응답, false, Collections.emptyList()); + } + + @Test + void 검색_결과가_10개_이상일_때_해당_페이지_레시피_10개만_반환한다() { + // given + final var 카테고리 = 카테고리_간편식사_생성(); + 단일_카테고리_저장(카테고리); + final var 상품1 = 단일_상품_저장(상품_망고빙수_가격5000원_평점4점_생성(카테고리)); + 반복_레시피_작성_요청(11, 상품1); + + // when + final var 응답 = 레시피_검색_결과_조회_요청("망고", 0L); + + // then + STATUS_CODE를_검증한다(응답, 정상_처리); + 레시피_검색_결과를_검증한다(응답, true, List.of(레시피11, 레시피10, 레시피9, 레시피8, 레시피7, 레시피6, 레시피5, 레시피4, 레시피3, 레시피2)); } } @@ -761,11 +784,14 @@ class getRecipeComment_실패_테스트 { .isEqualTo(recipeIds); } - private void 레시피_검색_결과를_검증한다(final ExtractableResponse response, final List recipeIds) { - final var actual = response.jsonPath() + private void 레시피_검색_결과를_검증한다(final ExtractableResponse response, final boolean hasNext, final List recipeIds) { + final var actualHasNext = response.jsonPath() + .getBoolean("hasNext"); + final var actualRecipes = response.jsonPath() .getList("recipes", SearchRecipeResultDto.class); - assertThat(actual).extracting(SearchRecipeResultDto::getId) + assertThat(actualHasNext).isEqualTo(hasNext); + assertThat(actualRecipes).extracting(SearchRecipeResultDto::getId) .containsExactlyElementsOf(recipeIds); } @@ -794,4 +820,10 @@ class getRecipeComment_실패_테스트 { assertThat(actualComments).hasSize(expectedSize); assertThat(actualHasNext).isEqualTo(expectedHasNext); } + + private void 반복_레시피_작성_요청(final int repeat, final Long productId) { + for (int i = 0; i < repeat; i++) { + 레시피_작성_요청(로그인_쿠키_획득(멤버1), 여러개_사진_명세_요청(이미지1), 레시피추가요청_생성(productId)); + } + } } diff --git a/src/test/java/com/funeat/fixture/RecipeFixture.java b/src/test/java/com/funeat/fixture/RecipeFixture.java index 2d3bb3de..69e90d8a 100644 --- a/src/test/java/com/funeat/fixture/RecipeFixture.java +++ b/src/test/java/com/funeat/fixture/RecipeFixture.java @@ -18,6 +18,13 @@ public class RecipeFixture { public static final Long 레시피2 = 2L; public static final Long 레시피3 = 3L; public static final Long 레시피4 = 4L; + public static final Long 레시피5 = 5L; + public static final Long 레시피6 = 6L; + public static final Long 레시피7 = 7L; + public static final Long 레시피8 = 8L; + public static final Long 레시피9 = 9L; + public static final Long 레시피10 = 10L; + public static final Long 레시피11 = 11L; public static final boolean 좋아요O = true; public static final boolean 좋아요X = false;