Skip to content

test(connect): fetchpostsclient msw 단위 테스트 추가#350

Merged
aabyess merged 1 commit into
developfrom
#277-connect-test-msw
Apr 21, 2026
Merged

test(connect): fetchpostsclient msw 단위 테스트 추가#350
aabyess merged 1 commit into
developfrom
#277-connect-test-msw

Conversation

@aabyess
Copy link
Copy Markdown
Collaborator

@aabyess aabyess commented Apr 21, 2026

🛠️ 설명 (Description)

features/connect/apis/fetchPostsClient.ts의 API 함수 3개에 대한 MSW 기반 단위 테스트를 작성했습니다.
실제 네트워크 없이 MSW로 요청을 가로채 정상/에러 응답을 검증합니다.

📝 변경 사항 요약 (Summary)

  • fetchPostsClient.test.ts 파일 신규 작성
  • fetchPostsClient / toggleConnectLike / deleteConnectLike 3개 함수 테스트 커버
  • 각 함수별 정상 응답, 500 에러, 404 에러 케이스 검증

💁 변경 사항 이유 (Why)

  • API 함수가 에러 응답 시 올바르게 throw하는지 검증 필요
  • 테스트 내 경로 하드코딩 시 BASE_URL 환경변수 값과 불일치하면 에러 핸들러 오버라이드가 무시되는 문제 존재
  • BASE_URL을 일관되게 사용해 환경에 상관없이 안정적으로 동작하도록 수정

✅ 테스트 계획 (Test Plan)

  • MSW + Jest로 단위 테스트 수행
  • 전체 9개 케이스 모두 통과 확인
    • fetchPostsClient: 정상 응답, 배열 타입, type/keyword 파라미터, 500, 404
    • toggleConnectLike: 정상 응답, 500, 404
    • deleteConnectLike: 정상 응답, 500, 404

🔗 관련 이슈 (Related Issues)

☑️ 체크리스트 (Checklist)

  • 코드가 프로젝트 코딩 컨벤션을 따릅니다.
  • 테스트 코드가 작성되었고, 통과했습니다.
  • 변경 사항에 대한 문서화가 완료되었습니다.
  • 필요한 경우, 다른 팀원에게 리뷰를 요청했습니다.
  • CI/CD 파이프라인이 성공했습니다.

fetchPostsClient, toggleConnectLike, deleteConnectLike API 함수에 대한
MSW 기반 단위 테스트를 작성

- 정상 응답 및 500/404 에러 케이스 검증
- server.use()로 에러 핸들러 오버라이드 후 rejects.toThrow 검증
@aabyess aabyess self-assigned this Apr 21, 2026
@aabyess aabyess added the test 테스트 코드 추가/수정 label Apr 21, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

medium

fetchPostsClient.ts 파일에 정의된 toggleCommentLike 및 deleteCommentLike 함수에 대한 테스트가 누락되었습니다. API 모듈의 모든 기능이 의도대로 동작하는지 보장하기 위해 해당 함수들을 임포트하고 테스트 케이스를 추가해 주세요.

import { fetchPostsClient, toggleConnectLike, deleteConnectLike, toggleCommentLike, deleteCommentLike } from "./fetchPostsClient";

features/connect/post/mappers.test.ts (88-101)

medium

mapPostToCard 함수 내에 createdAt을 타임스탬프 숫자로 변환하는 로직이 여전히 존재함에도 불구하고, 관련 테스트 코드가 삭제되었습니다. comment/mappers.test.ts에 추가된 테스트와 마찬가지로, 게시글 매퍼에서도 날짜 변환 로직이 올바르게 작동하는지 확인하는 테스트를 유지하는 것이 좋습니다.

@github-actions
Copy link
Copy Markdown

🧷 Preview: https://reboot-le3qft574-code-base.vercel.app
⏰ 배포 시각: 2026년 04월 21일 17시 51분

@aabyess aabyess merged commit 464a139 into develop Apr 21, 2026
1 check passed
@aabyess aabyess deleted the #277-connect-test-msw branch April 21, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test 테스트 코드 추가/수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TEST] features/connect API 함수 MSW 테스트

1 participant