Skip to content

Commit

Permalink
test: 콜라보레이터 관련 테스트 비활성화 (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdkdhoho committed Jan 10, 2025
1 parent fd681bb commit 37401a7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import static jakarta.persistence.TemporalType.TIMESTAMP;
import static lombok.AccessLevel.PROTECTED;

import com.listywave.collaborator.application.domain.Collaborators;
import com.listywave.common.exception.CustomException;
import com.listywave.list.application.domain.category.CategoryType;
import com.listywave.list.application.domain.item.Item;
Expand Down Expand Up @@ -247,16 +246,10 @@ public void validateOwnerIsNotDeleted() {
}
}

public void validateUpdateAuthority(User loginUser, Collaborators beforeCollaborators) {
public void validateUpdateAuthority(User loginUser) {
if (this.user.equals(loginUser)) {
return;
}
if (beforeCollaborators.isEmpty()) {
return;
}
if (beforeCollaborators.contains(loginUser)) {
return;
}
throw new CustomException(INVALID_ACCESS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public void update(Long listId, Long loginUserId, ListUpdateRequest request) {
ListEntity list = listRepository.getById(listId);

Collaborators beforeCollaborators = collaboratorService.findAllByList(list);
list.validateUpdateAuthority(loginUser, beforeCollaborators);
list.validateUpdateAuthority(loginUser);
Collaborators newCollaborators = collaboratorService.createCollaborators(request.collaboratorIds(), list);
collaboratorService.updateCollaborators(beforeCollaborators, newCollaborators);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
import static com.listywave.acceptance.list.ListAcceptanceTestHelper.비회원_리스트_상세_조회_API_호출;
import static com.listywave.acceptance.list.ListAcceptanceTestHelper.비회원_피드_리스트_조회_API_호출;
import static com.listywave.acceptance.list.ListAcceptanceTestHelper.비회원_히스토리_조회_API_호출;
import static com.listywave.acceptance.list.ListAcceptanceTestHelper.비회원이_피드_리스트_조회_카테고리_콜라보레이터_필터링_요청;
import static com.listywave.acceptance.list.ListAcceptanceTestHelper.비회원이_피드_리스트_조회_카테고리_필터링_요청;
import static com.listywave.acceptance.list.ListAcceptanceTestHelper.비회원이_피드_리스트_조회_콜라보레이터_필터링_요청;
import static com.listywave.acceptance.list.ListAcceptanceTestHelper.아이템_순위와_라벨을_바꾼_좋아하는_견종_TOP3_요청_데이터;
import static com.listywave.acceptance.list.ListAcceptanceTestHelper.정렬기준을_포함한_검색_API_호출;
import static com.listywave.acceptance.list.ListAcceptanceTestHelper.좋아하는_라면_TOP3_생성_요청_데이터;
Expand Down Expand Up @@ -380,6 +378,7 @@ class 리스트_수정 {
}

@Test
@Disabled
void 리스트의_작성자와_콜라보레이터만_수정할_수_있다() {
// given
var 동호 = 회원을_저장한다(동호());
Expand Down Expand Up @@ -583,47 +582,6 @@ class 피드_리스트_조회 {
.ignoringFields("id")
.isEqualTo(기대값);
}

@Test
@Disabled
void 콜라보레이터로_필터링한다() {
// given
var 동호 = 회원을_저장한다(동호());
var 정수 = 회원을_저장한다(정수());
var 동호_액세스_토큰 = 액세스_토큰을_발급한다(동호);
var 정수_액세스_토큰 = 액세스_토큰을_발급한다(정수);
var 리스트_1_ID = 리스트_저장_API_호출(가장_좋아하는_견종_TOP3_생성_요청_데이터(List.of(정수.getId())), 동호_액세스_토큰)
.as(ListCreateResponse.class)
.listId();
var 리스트_2_ID = 리스트_저장_API_호출(가장_좋아하는_견종_TOP3_생성_요청_데이터(List.of(동호.getId())), 정수_액세스_토큰)
.as(ListCreateResponse.class)
.listId();

// when
var 결과 = 비회원이_피드_리스트_조회_콜라보레이터_필터링_요청(동호).as(FindFeedListResponse.class);

// then
assertThat(결과.feedLists()).hasSize(2);
assertThat(결과.feedLists().get(0).id()).isEqualTo(리스트_2_ID);
assertThat(결과.feedLists().get(1).id()).isEqualTo(리스트_1_ID);
}

@Test
void 콜라보레이터와_카테고리로_필터링한다() {
// given
var 동호 = 회원을_저장한다(동호());
var 정수 = 회원을_저장한다(정수());
var 동호_액세스_토큰 = 액세스_토큰을_발급한다(동호);
리스트_저장_API_호출(가장_좋아하는_견종_TOP3_생성_요청_데이터(List.of()), 동호_액세스_토큰).as(ListCreateResponse.class);
var 동호_리스트_2 = 리스트_저장_API_호출(좋아하는_라면_TOP3_생성_요청_데이터(List.of(정수.getId())), 동호_액세스_토큰).as(ListCreateResponse.class);

// when
var 결과 = 비회원이_피드_리스트_조회_카테고리_콜라보레이터_필터링_요청(동호, "etc").as(FindFeedListResponse.class);

// then
assertThat(결과.feedLists()).hasSize(1);
assertThat(결과.feedLists().get(0).id()).isEqualTo(동호_리스트_2.listId());
}
}

@Nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public abstract class ListAcceptanceTestHelper {
.extract();
}

public static ExtractableResponse<Response> 비회원이_피드_리스트_조회_카테고리_콜라보레이터_필터링_요청(User targetUser, String category) {
public static ExtractableResponse<Response> 비회원이_사용자_피드에서_콜라보리스트를_카테고리로_필터링하여_요청한다(User targetUser, String category) {
return given()
.when().get("/users/{userId}/lists?type=collabo&category={category}", targetUser.getId(), category)
.then().log().all()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
import java.util.List;
import java.util.stream.LongStream;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

@Disabled
@DisplayName("Collaboratros는 ")
class CollaboratorsTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
import static com.listywave.user.fixture.UserFixture.정수;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertThrows;

import com.listywave.collaborator.application.domain.Collaborator;
import com.listywave.collaborator.application.domain.Collaborators;
import com.listywave.common.exception.CustomException;
import com.listywave.list.application.domain.category.CategoryType;
import com.listywave.list.application.domain.item.Item;
Expand All @@ -29,6 +28,7 @@
import com.listywave.list.application.domain.label.Labels;
import com.listywave.user.application.domain.User;
import java.util.List;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -225,23 +225,31 @@ class ListEntityTest {
}

@Test
@Disabled
void 리스트는_작성자_또는_콜라보레이터에_포함된_유저만이_수정할_수_있다() {
// given
User collaboratorUser = 정수();
Collaborator collaborator = Collaborator.init(collaboratorUser, list);
User notCollaborator = 유진();

Collaborators collaborators = new Collaborators(List.of(collaborator));

// when
// then
assertAll(
() -> assertThatNoException().isThrownBy(() -> list.validateUpdateAuthority(user, collaborators)),
() -> assertThatNoException().isThrownBy(() -> list.validateUpdateAuthority(collaboratorUser, collaborators)),
() -> assertThatNoException().isThrownBy(() -> list.validateUpdateAuthority(user)),
() -> assertThatNoException().isThrownBy(() -> list.validateUpdateAuthority(collaboratorUser)),
() -> {
CustomException exception = assertThrows(CustomException.class, () -> list.validateUpdateAuthority(notCollaborator, collaborators));
CustomException exception = assertThrows(CustomException.class, () -> list.validateUpdateAuthority(notCollaborator));
assertThat(exception.getErrorCode()).isEqualTo(INVALID_ACCESS);
}
);
}

@Test
void 리스트는_작성자만이_수정할_수_있다() {
// given
User otherUser = 정수();

// expect
assertThatThrownBy(() -> list.validateUpdateAuthority(otherUser));
assertThatNoException().isThrownBy(() -> list.validateUpdateAuthority(user));
}
}

0 comments on commit 37401a7

Please sign in to comment.