Skip to content

test: 채팅 관련 통합 테스트 작성 #409

Merged
dh2906 merged 5 commits intodevelopfrom
test/407-chat-api-integration-test
Mar 18, 2026
Merged

test: 채팅 관련 통합 테스트 작성 #409
dh2906 merged 5 commits intodevelopfrom
test/407-chat-api-integration-test

Conversation

@dh2906
Copy link
Contributor

@dh2906 dh2906 commented Mar 18, 2026

🔍 개요


🚀 주요 변경 내용


💬 참고 사항


✅ Checklist (완료 조건)

  • 코드 스타일 가이드 준수
  • 테스트 코드 포함됨
  • Reviewers / Assignees / Labels 지정 완료
  • 보안 및 민감 정보 검증 (API 키, 환경 변수, 개인정보 등)

@dh2906 dh2906 self-assigned this Mar 18, 2026
@dh2906 dh2906 added the 테스트 테스트 코드 관련 이슈입니다. label Mar 18, 2026
@dh2906 dh2906 changed the title test: 업로드 관련 통합 테스트 작성 test: 채팅 관련 통합 테스트 작성 Mar 18, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

📝 Walkthrough

Walkthrough

채팅 API용 통합 테스트 클래스 ChatApiTest를 추가하여 채팅방 생성(일반·관리자), 메시지 전송/검증, 메시지 조회 실패 시나리오, 음소거 토글 및 관련 저장소 상태를 검증합니다. 픽스처와 목 서비스를 사용해 테스트 데이터를 초기화합니다. (≈50단어)

Changes

Cohort / File(s) Summary
Chat Integration Tests
src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java
새로운 통합 테스트 클래스 추가. POST /chats/rooms, POST /chats/rooms/admin, GET /chats/rooms, POST /chats/rooms/{chatRoomId}/messages, GET /chats/rooms/{chatRoomId}, POST /chats/rooms/{chatRoomId}/mute 엔드포인트의 성공·실패 시나리오, 음소거 상태 영속성, 기존 방 반환 동작 등을 픽스처와 Mockito 목 서비스를 통해 검증합니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 테스트 깃발을 세우네, 방과 메시지 사이,
픽스처로 뿌린 씨앗들 반짝이고,
오류도 성공도 한 바구니에 담아,
음소거도 두 번 눌러 확인했네,
토끼가 축하해, 통합 테스트 완수! 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목은 주요 변경 내용인 채팅 관련 통합 테스트 작성을 명확하게 설명합니다.
Description check ✅ Passed PR 설명이 이슈 #407을 언급하고 체크리스트를 포함하여 변경 사항과 관련이 있습니다.
Linked Issues check ✅ Passed PR의 코드 변경이 이슈 #407의 모든 핵심 요구사항을 충족합니다: 채팅방 생성/조회/메시지 전송/뮤트 토글 테스트 및 실패 케이스 검증 포함.
Out of Scope Changes check ✅ Passed PR의 모든 변경 사항이 채팅 통합 테스트 추가로 이슈 #407의 범위 내에 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/407-chat-api-integration-test
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java`:
- Around line 64-75: setUp() currently creates broad fixtures
(UniversityFixture, UserFixture, ClubFixture, ClubMemberFixture and persists
adminUser, normalUser, targetUser, outsiderUser, club) for every test which
hides true dependencies; narrow the fixture scope by removing club and club
member creation from the global setUp() and instead create helper methods (e.g.,
createClubWithMembers(ClubFixture, ClubMemberFixture)) or move club/member
persists into the specific tests or nested test classes that require them (use
`@Nested` or individual `@BeforeEach` for chat/message vs admin-room scenarios),
while keeping shared user/university persists (UniversityFixture, UserFixture,
adminUser, normalUser, outsiderUser) in setUp(); ensure clear references to
setUp(), ClubFixture, ClubMemberFixture, and any new helper methods so tests
only prepare the data they actually depend on.
- Around line 153-163: The test currently assumes the admin room is at rooms[0],
which is brittle; change it to capture the chatRoomId returned by
performPost("/chats/rooms/admin") (inspect its JSON response for "chatRoomId")
and then use that id to locate the correct room in the
performGet("/chats/rooms") response (or alternatively assert the response
contains the expected number of rooms before indexing). Concretely: after
calling performPost("/chats/rooms/admin") extract the chatRoomId from the
response, then in the performGet("/chats/rooms") assertions locate the room
whose chatRoomId equals that value and assert its chatType, roomName,
lastMessage absence, and isMuted flag instead of hardcoding rooms[0].
- Around line 92-94: The test in ChatApiTest currently only asserts presence of
a chat room via chatRoomRepository.findByTwoUsers(normalUser.getId(),
targetUser.getId()) after creation; update both affected test blocks (including
the one around lines 132-139) to also assert that no duplicate room was created
by recording the count or ensuring exactly one room exists for that user pair
before and after the create flow—e.g., query the repository for rooms between
normalUser and targetUser (using chatRoomRepository.findByTwoUsers or a count
method) before the operation, perform the creation, call
clearPersistenceContext(), then re-query and assert the result is present and
that the total count for that pair is unchanged/equals one so the contract
“exactly one room for the pair” is enforced.
- Around line 272-284: The test is too tightly coupled to an internal storage
representation by insisting a NotificationMuteSetting row exists with isMuted ==
false; update the assertion around
notificationMuteSettingRepository.findByTargetTypeAndTargetIdAndUserId(NotificationTargetType.CHAT_ROOM,
chatRoom.getId(), normalUser.getId()) to allow either the row to be absent or,
if present, to have getIsMuted() == false (e.g., assert that Optional.isEmpty()
OR Optional.get().getIsMuted() == false); keep the earlier performPost and
jsonPath assertions unchanged and only change the repository verification to the
permissive OR check so the test will pass whether unmute is implemented as
deletion or flag flip.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: caa77b7b-8b68-412c-8ee9-a6ad7e3d0d32

📥 Commits

Reviewing files that changed from the base of the PR and between ad4cf2f and afec05d.

📒 Files selected for processing (1)
  • src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*

⚙️ CodeRabbit configuration file

**/*: 공통 리뷰 톤 가이드:

  • 모든 코멘트는 첫 줄에 [LEVEL: ...] 태그를 포함한다.
  • 과장된 표현 없이 사실 기반으로 작성한다.
  • 한 코멘트에는 하나의 이슈만 다룬다.
  • 코드 예시가 필요하면 최소 수정 예시를 제시한다.
  • 가독성/단순화/확장성 이슈를 발견하면 우선순위를 높여 코멘트한다.

Files:

  • src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java (1)

161-171: ⚠️ Potential issue | 🟡 Minor

[LEVEL: MEDIUM] 목록 검증을 rooms[0]에 고정하지 마세요.

정렬 기준이 바뀌거나 기본 데이터가 추가되면 기능은 정상이더라도 이 테스트만 깨집니다. POST /chats/rooms/admin 응답의 chatRoomId를 받아 그 ID로 목록에서 대상을 찾아 검증하는 방식이 더 안전합니다. As per coding guidelines, '가독성/단순화/확장성 이슈를 발견하면 우선순위를 높여 코멘트한다.'

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java` around
lines 161 - 171, The test currently assumes the new room is at rooms[0], which
is brittle; instead capture the chatRoomId returned by
performPost("/chats/rooms/admin") and use that ID to locate the matching room in
the GET /chats/rooms response before asserting its fields. Concretely: call
performPost("/chats/rooms/admin") and extract the chatRoomId from the response,
then call performGet("/chats/rooms"), find the room whose chatRoomId equals that
extracted ID, and assert that its chatType is "DIRECT", roomName equals
adminUser.getName(), lastMessage does not exist, and isMuted is false (use
performPost, performGet, adminUser, and the chatRoomId value to find the correct
room instead of hardcoding rooms[0]).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java`:
- Around line 154-172: Update the test createAdminChatRoomAndGetRoomsSuccess to
also exercise the "existing room returned" branch by calling the POST
/chats/rooms/admin endpoint twice: capture the chatRoomId from the first
performPost response, call performPost a second time and assert the returned
chatRoomId equals the first one, then performGet("/chats/rooms") and assert the
rooms list size did not increase (e.g., still one room) and other expectations
(chatType, roomName, no lastMessage, isMuted false) still hold; use the existing
performPost/performGet helpers and JSON path extraction from the responses to
compare IDs and verify room count.

---

Duplicate comments:
In `@src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java`:
- Around line 161-171: The test currently assumes the new room is at rooms[0],
which is brittle; instead capture the chatRoomId returned by
performPost("/chats/rooms/admin") and use that ID to locate the matching room in
the GET /chats/rooms response before asserting its fields. Concretely: call
performPost("/chats/rooms/admin") and extract the chatRoomId from the response,
then call performGet("/chats/rooms"), find the room whose chatRoomId equals that
extracted ID, and assert that its chatType is "DIRECT", roomName equals
adminUser.getName(), lastMessage does not exist, and isMuted is false (use
performPost, performGet, adminUser, and the chatRoomId value to find the correct
room instead of hardcoding rooms[0]).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c55c8a67-adac-4ddb-80ef-2ac4a001d1f3

📥 Commits

Reviewing files that changed from the base of the PR and between afec05d and 239891b.

📒 Files selected for processing (1)
  • src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*

⚙️ CodeRabbit configuration file

**/*: 공통 리뷰 톤 가이드:

  • 모든 코멘트는 첫 줄에 [LEVEL: ...] 태그를 포함한다.
  • 과장된 표현 없이 사실 기반으로 작성한다.
  • 한 코멘트에는 하나의 이슈만 다룬다.
  • 코드 예시가 필요하면 최소 수정 예시를 제시한다.
  • 가독성/단순화/확장성 이슈를 발견하면 우선순위를 높여 코멘트한다.

Files:

  • src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java

@dh2906 dh2906 merged commit 696bf3a into develop Mar 18, 2026
3 checks passed
@dh2906 dh2906 deleted the test/407-chat-api-integration-test branch March 18, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

테스트 테스트 코드 관련 이슈입니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

채팅 관련 통합 테스트 작성

1 participant