test(connect): fetchpostsclient msw 단위 테스트 추가#350
Conversation
fetchPostsClient, toggleConnectLike, deleteConnectLike API 함수에 대한 MSW 기반 단위 테스트를 작성 - 정상 응답 및 500/404 에러 케이스 검증 - server.use()로 에러 핸들러 오버라이드 후 rejects.toThrow 검증
There was a problem hiding this comment.
Code Review
This pull request introduces a new test suite for the fetchPostsClient API using MSW and expands the comment mapper tests to include new fields and edge cases. However, it also removes existing date conversion tests for post mappers. The review feedback suggests adding missing tests for comment-related like functions and recommends restoring the deleted post mapper tests to maintain comprehensive test coverage.
I am having trouble creating individual review comments. Click here to see my feedback.
features/connect/apis/fetchPostsClient.test.ts (3)
fetchPostsClient.ts 파일에 정의된 toggleCommentLike 및 deleteCommentLike 함수에 대한 테스트가 누락되었습니다. API 모듈의 모든 기능이 의도대로 동작하는지 보장하기 위해 해당 함수들을 임포트하고 테스트 케이스를 추가해 주세요.
import { fetchPostsClient, toggleConnectLike, deleteConnectLike, toggleCommentLike, deleteCommentLike } from "./fetchPostsClient";
features/connect/post/mappers.test.ts (88-101)
mapPostToCard 함수 내에 createdAt을 타임스탬프 숫자로 변환하는 로직이 여전히 존재함에도 불구하고, 관련 테스트 코드가 삭제되었습니다. comment/mappers.test.ts에 추가된 테스트와 마찬가지로, 게시글 매퍼에서도 날짜 변환 로직이 올바르게 작동하는지 확인하는 테스트를 유지하는 것이 좋습니다.
|
🧷 Preview: https://reboot-le3qft574-code-base.vercel.app |
🛠️ 설명 (Description)
features/connect/apis/fetchPostsClient.ts의 API 함수 3개에 대한 MSW 기반 단위 테스트를 작성했습니다.실제 네트워크 없이 MSW로 요청을 가로채 정상/에러 응답을 검증합니다.
📝 변경 사항 요약 (Summary)
fetchPostsClient.test.ts파일 신규 작성fetchPostsClient/toggleConnectLike/deleteConnectLike3개 함수 테스트 커버💁 변경 사항 이유 (Why)
BASE_URL환경변수 값과 불일치하면 에러 핸들러 오버라이드가 무시되는 문제 존재BASE_URL을 일관되게 사용해 환경에 상관없이 안정적으로 동작하도록 수정✅ 테스트 계획 (Test Plan)
fetchPostsClient: 정상 응답, 배열 타입, type/keyword 파라미터, 500, 404toggleConnectLike: 정상 응답, 500, 404deleteConnectLike: 정상 응답, 500, 404🔗 관련 이슈 (Related Issues)
☑️ 체크리스트 (Checklist)