test(reviews/favorites): 리뷰·찜 서버 API 테스트 추가#349
Merged
Conversation
- MSW 기반 서버 API 테스트를 추가 - 조회 성공, 쿼리 변환, 에러 처리를 검증 Resolves: #348
There was a problem hiding this comment.
Code Review
This pull request introduces unit tests for the favorites and reviews server-side APIs, ensuring correct data retrieval, query parameter serialization, and error handling. The review feedback identifies potential test flakiness due to hardcoded timezone offsets in date string comparisons and suggests refactoring duplicated cookie store mocking logic into a common utility to improve maintainability.
|
🧷 Preview: https://reboot-cuynovxm1-code-base.vercel.app |
|
🧷 Preview: https://reboot-aqgx6ueo5-code-base.vercel.app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🛠️ 설명 (Description)
favorites mock data와 favoritesHandlers 추가하고
MSW 기반으로 리뷰/찜 서버 API 테스트를 추가했습니다.
ApiError로 정상 매핑되는지를 검증했습니다.또한
next/headers의cookies()모킹을mocks/utils/mockHeader.ts로 분리해 리뷰/찜 서버 API 테스트에서 공통으로 재사용하도록 정리했습니다.📝 변경 사항 요약 (Summary)
mocks/data/favorites와mocks/handlers/favorites를 추가해 기존 mock 구조와 동일한 방식으로 재구성했습니다.URLSearchParams입력에 대한 쿼리 변환 검증size파라미터 직렬화 검증serverFetch가 읽는 cookie 상태와 Authorization 헤더 주입 검증mocks/utils/mockHeader.ts추가로next/headersmock 유틸 공통화했습니다.ApiError매핑 및 기본 메시지 fallback 검증💁 변경 사항 이유 (Why)
✅ 테스트 계획 (Test Plan)
pnpm test -- --runInBand features/reviews/apis/server.test.tspnpm test -- --runInBand features/favorites/apis/server.test.tspnpm test -- --runInBand features/reviews/apis/server.test.ts features/favorites/apis/server.test.ts결과:
2개 테스트 스위트,15개 테스트 통과MSW 기반 서버 API 테스트 수행
리뷰/찜 목록 조회 성공 응답 파싱 검증
객체 인자 및
URLSearchParams입력에 대한 쿼리스트링 변환 검증날짜 범위 문자열(
+09:00suffix 포함) 직렬화 검증숫자가 아닌
size값 제외 처리 검증cookie 기반 Authorization 헤더 주입 검증
에러 응답 시
ApiError변환 및 기본 메시지 처리 검증리뷰 통계 API 성공/실패 케이스 검증
🔗 관련 이슈 (Related Issues)
☑️ 체크리스트 (Checklist)
👀 리뷰어를 위한 참고 사항 (Notes for Reviewers)
mocks/utils/mockHeader.ts는next/headers의cookies()를 공통으로 mock 하기 위한 유틸입니다.+09:00고정 문자열을 append하는 구조라toBe(...)로 전체 문자열을 엄격히 검증했습니다.➕ 추가 정보 (Additional Information)