Skip to content

test: 그룹 채팅방 생성 및 멤버 강퇴 테스트 추가#482

Open
dh2906 wants to merge 4 commits intodevelopfrom
test/CAM-282-create-group-chat
Open

test: 그룹 채팅방 생성 및 멤버 강퇴 테스트 추가#482
dh2906 wants to merge 4 commits intodevelopfrom
test/CAM-282-create-group-chat

Conversation

@dh2906
Copy link
Copy Markdown
Contributor

@dh2906 dh2906 commented Apr 1, 2026

🔍 개요


🚀 주요 변경 내용


💬 참고 사항


✅ Checklist (완료 조건)

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

@dh2906 dh2906 self-assigned this Apr 1, 2026
@dh2906 dh2906 added the 테스트 테스트 코드 관련 이슈입니다. label Apr 1, 2026
@linear
Copy link
Copy Markdown

linear bot commented Apr 1, 2026

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

Warning

Rate limit exceeded

@dh2906 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 12 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 3 minutes and 12 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ac88dd69-e8a3-416f-8bee-1653d42c3338

📥 Commits

Reviewing files that changed from the base of the PR and between f44f631 and 6f5209d.

📒 Files selected for processing (1)
  • src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java
📝 Walkthrough

Walkthrough

ChatApiTest.java 통합 테스트에서 기존 테스트 픽스처를 ChatRoom.clubGroupOf(club) 방식으로 업데이트하고, 그룹 채팅방 생성 및 멤버 강퇴 API에 대한 새로운 중첩 테스트 케이스들을 추가했습니다.

Changes

단위(Cohort) / 파일(s) 요약
테스트 픽스처 업데이트
src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java
기존 테스트의 클럽 기반 그룹 채팅방 생성 방식을 ChatRoom.clubGroupOf(club)로 일관되게 변경하고, 예상 chatType"CLUB_GROUP"으로 조정
그룹 채팅방 생성 테스트 추가
src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java
POST /chats/rooms/group 엔드포인트의 성공 케이스(소유자 vs 멤버 권한), 입력 검증 오류(자신만 포함, 빈 목록), 누락된 사용자 처리, userIds 중복 제거, 초대된 멤버의 메시지 전송 능력 검증
멤버 강퇴 테스트 추가
src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java
DELETE /chats/rooms/{chatRoomId}/members/{targetUserId} 엔드포인트의 소유자 성공 사례, 권한 실패(비소유자, 외부 요청자, 자신 강퇴, 비그룹방), 잘못된 방 처리, 멤버 퇴장 후 동작, 소유자 강퇴 제약, 강퇴 후 메시지/이름/멤버 접근 제한, 방 목록 제거, 소유자 퇴장 후 강퇴 실패 검증
헬퍼 메서드 추가
src/test/java/gg/agit/konect/integration/domain/chat/ChatApiTest.java
강퇴 테스트에서 사용할 비공개 헬퍼 메서드 createGroupChatRoomWithOwner(User owner, User... members) 구현

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • test: 채팅 관련 통합 테스트 작성  #409: 동일한 ChatApiTest 통합 테스트 클래스를 수정하는 PR로, 이전 PR에서 기초를 마련한 채팅 테스트 위에 클럽-그룹 테스트, 그룹 생성 및 강퇴 시나리오를 확장하고 업데이트합니다.

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 설명은 #477 이슈를 종료하는 것을 명시하고 있으며, 체크리스트를 완료했음을 나타내고 있으나, 주요 변경 내용과 참고 사항 섹션은 비어있습니다. 그러나 PR 제목과 commit 메시지로부터 변경 내용을 파악할 수 있으므로 관련성이 있습니다.
Linked Issues check ✅ Passed PR은 #477에서 요구한 '그룹 채팅방 생성 & 강퇴 통합 테스트'를 구현했으며, 그룹 채팅방 생성(POST /chats/rooms/group)과 멤버 강퇴(DELETE /chats/rooms/{chatRoomId}/members/{targetUserId}) 테스트를 모두 추가했습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 그룹 채팅방 생성 및 멤버 강퇴 테스트 작성의 범위 내에 있으며, 테스트 클래스(ChatApiTest.java)만 수정되었고 공개 API 선언은 변경되지 않았습니다.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/CAM-282-create-group-chat

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
Copy Markdown

@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: 3

🤖 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 988-989: The test is unstable because it re-fetches a room ID via
chatRoomRepository.findGroupRoomsByMemberUserId(...).stream().findFirst(), which
can pick the wrong room; instead capture and reuse the created room ID returned
in the room-creation response (e.g., response.getChatRoomId() or
createdRoom.getChatRoomId()) wherever roomId is later computed; replace usages
that call findGroupRoomsByMemberUserId (including the other occurrences
referenced) to use the saved response chatRoomId for assertions and subsequent
calls.
- Around line 991-1005: The test currently only asserts membership/ownership;
also assert the created room's type is ChatType.GROUP to prevent false positives
when GROUP vs CLUB_GROUP are mixed; locate ChatApiTest near the existing roomId
usage, load the ChatRoom (e.g., via
chatRoomRepository.findById(roomId).orElseThrow()) and add an assertion that its
type equals ChatType.GROUP (reference ChatType.GROUP and the ChatApiTest test
method to place the check).
- Around line 1294-1343: Add a new test in ChatApiTest that mirrors the other
"kicked member" tests to verify a kicked user cannot read the room details:
after removing the member with performDelete("/chats/rooms/" + groupRoom.getId()
+ "/members/" + memberUser.getId()) and confirming NoContent,
mockLoginUser(memberUser.getId()) and call performGet("/chats/rooms/" +
groupRoom.getId()) (or the existing room detail endpoint) and assert
status().isForbidden() and
jsonPath("$.code").value("FORBIDDEN_CHAT_ROOM_ACCESS"); name the test similarly
(e.g., kickedMemberCannotViewRoom or kickedMemberCannotGetRoomDetails) so it
sits with kickedMemberCannotUpdateRoomName and kickedMemberCannotSendMessage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c773ae2e-8de2-4343-b1e6-fc27827d8e3b

📥 Commits

Reviewing files that changed from the base of the PR and between f28a0c4 and f44f631.

📒 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

Comment on lines +1294 to +1343
@Test
@DisplayName("강퇴된 멤버는 채팅방 이름을 수정할 수 없다")
void kickedMemberCannotUpdateRoomName() throws Exception {
// given
mockLoginUser(ownerUser.getId());
performDelete("/chats/rooms/" + groupRoom.getId() + "/members/" + memberUser.getId())
.andExpect(status().isNoContent());

// when & then
mockLoginUser(memberUser.getId());
performPatch(
"/chats/rooms/" + groupRoom.getId() + "/name",
new ChatRoomNameUpdateRequest("강퇴 후 이름")
)
.andExpect(status().isForbidden())
.andExpect(jsonPath("$.code").value("FORBIDDEN_CHAT_ROOM_ACCESS"));
}

@Test
@DisplayName("강퇴된 멤버는 메시지를 보낼 수 없다")
void kickedMemberCannotSendMessage() throws Exception {
// given
mockLoginUser(ownerUser.getId());
performDelete("/chats/rooms/" + groupRoom.getId() + "/members/" + memberUser.getId())
.andExpect(status().isNoContent());

// when & then
mockLoginUser(memberUser.getId());
performPost(
"/chats/rooms/" + groupRoom.getId() + "/messages",
new ChatMessageSendRequest("강퇴 후 메시지")
)
.andExpect(status().isForbidden())
.andExpect(jsonPath("$.code").value("FORBIDDEN_CHAT_ROOM_ACCESS"));
}

@Test
@DisplayName("강퇴된 멤버의 방 목록에서 해당 방이 제거된다")
void kickedMemberRoomRemovedFromList() throws Exception {
// given
mockLoginUser(ownerUser.getId());
performDelete("/chats/rooms/" + groupRoom.getId() + "/members/" + memberUser.getId())
.andExpect(status().isNoContent());

// when & then
mockLoginUser(memberUser.getId());
performGet("/chats/rooms")
.andExpect(status().isOk())
.andExpect(jsonPath("$.rooms[?(@.roomId==" + groupRoom.getId() + ")]").doesNotExist());
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

[LEVEL: high] 강퇴 후 메시지 조회 차단 케이스가 빠져 있습니다.

현재는 강퇴 후 PATCH, POST, 목록 제거만 확인합니다. GET /chats/rooms/{chatRoomId}가 계속 열려 있으면 강퇴된 사용자가 대화 이력을 읽을 수 있는데, 이 스위트는 그 회귀를 잡지 못합니다. 같은 흐름으로 FORBIDDEN_CHAT_ROOM_ACCESS까지 고정해 두는 편이 좋습니다.

최소 수정 예시
+        `@Test`
+        `@DisplayName`("강퇴된 멤버는 메시지를 조회할 수 없다")
+        void kickedMemberCannotGetMessages() throws Exception {
+            mockLoginUser(ownerUser.getId());
+            performDelete("/chats/rooms/" + groupRoom.getId() + "/members/" + memberUser.getId())
+                .andExpect(status().isNoContent());
+
+            mockLoginUser(memberUser.getId());
+            performGet("/chats/rooms/" + groupRoom.getId() + "?page=1&limit=20")
+                .andExpect(status().isForbidden())
+                .andExpect(jsonPath("$.code").value("FORBIDDEN_CHAT_ROOM_ACCESS"));
+        }
🤖 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 1294 - 1343, Add a new test in ChatApiTest that mirrors the other "kicked
member" tests to verify a kicked user cannot read the room details: after
removing the member with performDelete("/chats/rooms/" + groupRoom.getId() +
"/members/" + memberUser.getId()) and confirming NoContent,
mockLoginUser(memberUser.getId()) and call performGet("/chats/rooms/" +
groupRoom.getId()) (or the existing room detail endpoint) and assert
status().isForbidden() and
jsonPath("$.code").value("FORBIDDEN_CHAT_ROOM_ACCESS"); name the test similarly
(e.g., kickedMemberCannotViewRoom or kickedMemberCannotGetRoomDetails) so it
sits with kickedMemberCannotUpdateRoomName and kickedMemberCannotSendMessage.

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