Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public MeetingHomeResponse getMeetingHome(Long meetingId) {
Meeting meeting = meetingRepository.findById(meetingId)
.orElseThrow(() -> new CustomException(CustomErrorCode.MEETING_NOT_FOUND));

participantRepository.findByMeetingIdAndUserIdAndLeftAtIsNull(meetingId, currentUserId)
Participant me = participantRepository.findByMeetingIdAndUserIdAndLeftAtIsNull(meetingId, currentUserId)
.orElseThrow(() -> new CustomException(CustomErrorCode.NOT_A_PARTICIPANT));

MeetingPurpose purpose = meetingPurposeRepository.findByMeetingId(meetingId)
Expand Down Expand Up @@ -91,7 +91,9 @@ public MeetingHomeResponse getMeetingHome(Long meetingId) {
recommendationRunRepository.findTopByMeetingIdAndStatusOrderByCreatedAtDesc(
meetingId, RecommendationStatus.COMPLETED).isPresent();

HomeAction action = resolveHomeAction(status, recommendationCompleted);
boolean isNewRestricted = me.getState() == ParticipantState.NEW_RESTRICTED;

HomeAction action = resolveHomeAction(status, recommendationCompleted, isNewRestricted);

boolean hasSchedule = meeting.hasSchedule();
String scheduledDate = hasSchedule && meeting.getScheduledDate() != null
Expand All @@ -117,10 +119,14 @@ public MeetingHomeResponse getMeetingHome(Long meetingId) {
);
}

private HomeAction resolveHomeAction(MeetingStatus status, boolean recommendationCompleted) {
private HomeAction resolveHomeAction(MeetingStatus status, boolean recommendationCompleted, boolean isNewRestricted) {
return switch (status) {
case CONDITION_INPUT -> new HomeAction("아직 조건 입력 중이에요!", "추천 장소 확인", false);
case VOTING -> new HomeAction("이미 조건 입력이 완료된 모임이에요!", "추천 장소 확인 및 투표", recommendationCompleted);
case VOTING -> new HomeAction(
isNewRestricted ? "이미 투표가 시작된 모임이에요!" : "이미 조건 입력이 완료된 모임이에요!",
"추천 장소 확인 및 투표",
recommendationCompleted && !isNewRestricted
);
case CONFIRMED -> new HomeAction("모임이 확정됐어요. 모임 정보를 확인해보세요!", "확정된 모임 보러 가기", true);
case COMPLETED -> new HomeAction(null, null, false);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,33 @@ void tearDown() {
assertThat(response.primaryActionEnabled()).isTrue();
}

@Test
void VOTING이고_추천완료_있어도_신규_참여자면_homeMessage가_다르고_primaryActionEnabled가_false이다() {
RecommendationRun run = mock(RecommendationRun.class);
when(recommendationRunRepository.findTopByMeetingIdAndStatusOrderByCreatedAtDesc(
MEETING_ID, RecommendationStatus.COMPLETED)).thenReturn(Optional.of(run));

MeetingHomeResponse response = setupAndCallGetMeetingHome(MeetingStatus.VOTING, ParticipantState.NEW_RESTRICTED);

assertThat(response.homeMessage()).isEqualTo("이미 투표가 시작된 모임이에요!");
assertThat(response.primaryActionLabel()).isEqualTo("추천 장소 확인 및 투표");
assertThat(response.primaryActionEnabled()).isFalse();
}

@Test
void CONFIRMED이면_신규_참여자여도_primaryActionEnabled가_true이다() {
MeetingHomeResponse response = setupAndCallGetMeetingHome(MeetingStatus.CONFIRMED, ParticipantState.NEW_RESTRICTED);

assertThat(response.primaryActionEnabled()).isTrue();
}

private MeetingHomeResponse setupAndCallGetMeetingHome(MeetingStatus status) {
return setupAndCallGetMeetingHome(status, ParticipantState.COND_PENDING);
}

private MeetingHomeResponse setupAndCallGetMeetingHome(MeetingStatus status, ParticipantState myState) {
Meeting meeting = mockMeeting(MEETING_ID, status, null);
Participant me = mockParticipant(1L, CURRENT_USER_ID, ParticipantState.COND_PENDING);
Participant me = mockParticipant(1L, CURRENT_USER_ID, myState);
MeetingPurpose purpose = mockPurpose(PurposeType.NETWORKING);
User user = mockUser(CURRENT_USER_ID, "나");

Expand Down
Loading