Skip to content

test(components): 에러바운더리 및 header/mypage 컴포넌트 테스트 #352

Merged
sohyun0 merged 13 commits into
developfrom
#286-test-components
Apr 30, 2026
Merged

test(components): 에러바운더리 및 header/mypage 컴포넌트 테스트 #352
sohyun0 merged 13 commits into
developfrom
#286-test-components

Conversation

@sohyun0
Copy link
Copy Markdown
Contributor

@sohyun0 sohyun0 commented Apr 30, 2026

🛠️ 설명 (Description)

공통 컴포넌트 내 에러바운더리 및 header 와 mypage 의 컴포넌트 테스트코드 작성 및 접근성 관련 코드 추가

📝 변경 사항 요약 (Summary)

  • components/common
  • features/header/components
  • features/mypage/components
  • 테스트 코드 작성과 더불어 접근성 관련하여 aria-label 을 추가했습니다.
  • 알림 기존 onClick 구조에서 button 태그로 변경

💁 변경 사항 이유 (Why)

  • label 이 없는 버튼일 경우 test하기도 편하고 접근성도 높이기 위하여 aria-label 을 붙였습니다.
  • onClick 에서 Button으로 변경하여 탭으로 탐색하더라도 불편함이 없게끔 개선했습니다.

✅ 테스트 계획 (Test Plan)

  • 컴포넌트 테스트 작성완료

🔗 관련 이슈 (Related Issues)

☑️ 체크리스트 (Checklist)

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

👀 리뷰어를 위한 참고 사항 (Notes for Reviewers)

➕ 추가 정보 (Additional Information)

@sohyun0 sohyun0 self-assigned this Apr 30, 2026
@sohyun0 sohyun0 added refactor 코드 리팩토링 / 코드 수정 test 테스트 코드 추가/수정 labels Apr 30, 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 significantly increases test coverage across multiple components, including ErrorPage, QueryErrorBoundary, Notification components, ProfileModal, and ReviewCard. It also refactors the NotificationCard for improved accessibility and styling, while updating mock data and test descriptions for consistency. The review feedback suggests enhancing test reliability by replacing direct DOM queries and fireEvent with Testing Library's userEvent and more semantic queries.

Comment thread features/mypage/components/ProfileModal/ProfileImage.test.tsx
Comment thread features/mypage/components/ProfileModal/ProfileImage.test.tsx
Comment on lines +93 to +100
test("지원하지 않는 이미지 형식이면 형식 제한 메세지가 보인다", async () => {
renderProfileImage();
const textFile = createImageFile({ name: "profile.txt", type: "text/plain" });
const fileInput = getFileInput();

fireEvent.change(fileInput, {
target: { files: [textFile] },
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

fireEvent 대신 userEvent를 사용하여 실제 사용자의 동작(포커스, 이벤트 발생 순서 등)을 더 정확하게 시뮬레이션하는 것이 좋습니다. 이미 userEvent가 설정되어 있으므로 이를 활용하도록 수정합니다.

	test("지원하지 않는 이미지 형식이면 형식 제한 메세지가 보인다", async () => {
		const { user } = renderProfileImage();
		const textFile = createImageFile({ name: "profile.txt", type: "text/plain" });
		const fileInput = getFileInput();

		await user.upload(fileInput, textFile);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@gemini-code-assist 해당 테스트는 브라우저의 파일 선택 제한을 우회해서 업로드 하는 경우 유효성 검사가 제대로 이루어지는지를 테스트하는 것입니다. 실제컴포넌트는 input의 accept에 이미지 조건이 있기때문에 일반적인 userEvent 사용시 테스트가 불가능합니다.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

제공해주신 상세한 설명 감사합니다. 해당 테스트의 목적이 브라우저의 파일 선택 제한을 우회하여 유효성 검사를 확인하는 것이라면, fireEvent를 사용하여 직접 이벤트를 발생시키는 것이 적절합니다. userEvent는 실제 사용자 동작을 시뮬레이션하므로, inputaccept 속성에 의해 .txt 파일 업로드가 제한될 수 있습니다. 따라서 기존 fireEvent 사용이 올바른 접근입니다.

@github-actions
Copy link
Copy Markdown

🧷 Preview: https://reboot-5m7246u2s-code-base.vercel.app
⏰ 배포 시각: 2026년 04월 30일 18시 16분

@sohyun0 sohyun0 merged commit 5f1a2a7 into develop Apr 30, 2026
1 check passed
@sohyun0 sohyun0 deleted the #286-test-components branch April 30, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor 코드 리팩토링 / 코드 수정 test 테스트 코드 추가/수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TEST] 공통 및 기능 컴포넌트 테스트코드 작성

1 participant