Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
643384f
feat: 모달 컴포넌트 DOM 구조 구현
inaemin Apr 8, 2026
b684407
feat: 영화 상세 API 추가
inaemin Apr 8, 2026
6f047d3
feat: MovieItem에 id 필드 추가
inaemin Apr 8, 2026
010613d
chore: TMDB_MAX_PAGE 상수 추출
inaemin Apr 13, 2026
205aaa0
feat: toURLSearchParams 유틸 추가
inaemin Apr 13, 2026
acf32dd
feat: MovieDetail, MovieDetailParams 타입 추가
inaemin Apr 13, 2026
9551cf7
feat: toMovieDetail 변환 함수 추가 및 평점 반올림 처리
inaemin Apr 13, 2026
2312f30
refactor: fetchMovieDetail이 MovieDetail 직접 반환하도록 변경
inaemin Apr 13, 2026
db46b87
refactor: MovieList load/loadMore를 fetchMoviePage로 통합
inaemin Apr 13, 2026
c91bcaf
chore: 미사용 Movie.ts 삭제 및 index에서 export 제거
inaemin Apr 13, 2026
a98654c
feat: 무한 스크롤 컴포넌트 추가
inaemin Apr 13, 2026
e960e31
feat: RatingService 추가
inaemin Apr 13, 2026
5c12a79
feat: MovieService 추가
inaemin Apr 13, 2026
e9e363c
refactor: Modal을 클래스로 전환 및 MovieService/RatingService 연동
inaemin Apr 13, 2026
5e88966
refactor: hero에서 onDetailClick 의존성 제거
inaemin Apr 13, 2026
49bcff2
refactor: movie-card에 data-id 추가 및 movie-list 정리
inaemin Apr 13, 2026
806cae2
feat: mainPage 무한스크롤 및 모달 연동
inaemin Apr 13, 2026
39c5bfc
feat: searchPage 무한스크롤 및 모달 연동
inaemin Apr 13, 2026
161ef45
style: 스켈레톤 shimmer 애니메이션 추가
inaemin Apr 13, 2026
791290b
style: 모달 스타일 구현
inaemin Apr 13, 2026
6a60691
style: 헤더 태블릿/모바일 반응형 레이아웃
inaemin Apr 13, 2026
07c3c9b
style: search-form 반응형 너비 적용
inaemin Apr 13, 2026
df590c8
style: empty/error 스타일 movie-list-message로 통합
inaemin Apr 13, 2026
c4e3ab1
docs: step2 README 업데이트
inaemin Apr 13, 2026
1053ae2
test: e2e 테스트 수정 및 두 번째 페칭 실패 케이스 추가
inaemin Apr 13, 2026
21fbaee
chore: domains/movie index.ts 삭제 및 직접 경로로 import 변경
inaemin Apr 13, 2026
0d92dcd
refactor: domains 폴더를 services로 이동 및 MovieList를 MovieListService로 이름 변경
inaemin Apr 13, 2026
667a847
refactor: e2e 테스트를 step1 폴더로 이동
inaemin Apr 13, 2026
e69af85
test: step2 e2e 테스트 추가
inaemin Apr 13, 2026
3115118
chore: step2 브랜치 배포 트리거 추가
inaemin Apr 13, 2026
038ebdd
style: 별점 star-filled에 will-change 추가
inaemin Apr 13, 2026
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
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- step1
- step2

jobs:
deploy:
Expand Down
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# javascript-movie-review

FE 레벨1 영화 리뷰 미션
## step1

- 영화 목록 조회
- [x] 인기있는 영화 목록을 조회한다.
Expand All @@ -16,3 +16,32 @@ FE 레벨1 영화 리뷰 미션
- [x] 조회/ 검색 시 데이터를 불러오지 못했을 때
- e2e 테스트
- [x] maxPage일 때(e.g. 500) 엣지 케이스

## step2

- [ ] 이벤트 분리하기
- [ ] 로딩 이벤트와 데이터 이벤트를 분리
- [ ] 대표영화를 별도 이벤트로 제공

- [ ] 📺 영화 상세정보 조회하기
- [ ] 영화 포스터나 제목을 클릭하면 모달을 띄우고 예고편이나 줄거리 등의 정보를 보여준다.
- [ ] API에서 제공하는 항목을 활용하여 상세 정보를 보여주는 모달 창을 구현한다.
- [ ] 키보드의 ESC 키를 누르면 모달 창을 닫을 수 있는 등 사용성을 고려한다.

- [ ] ⭐️ 별점 매기기
- [ ] local storage 로 구현한다.
- [ ] local storage, 서버 API를 쉽고, 안전하게 갈아끼울 수 있는 구조로 개발하여야 한다.
- [ ] 사용자는 영화에 대해 별점을 줄 수 있으며 새로고침하더라도 사용자가 남긴 별점은 유지되어야 한다.
별점은 5개로 구성되어 있으며 한 개당 2점이며 1점 단위는 고려하지 않는다.
- [ ] 2점: 최악이예요
- [ ] 4점: 별로예요
- [ ] 6점: 보통이에요
- [ ] 8점: 재미있어요
- [ ] 10점: 명작이에요

- [ ] UI/UX 개선하기
- [ ] 영화 목록과 영화 상세 정보가 뜨는 모달창에 대한 반응형 레이아웃을 구성한다.
- [ ] 영화 목록에서 더보기 버튼을 눌렀을 때 페이징하는 방식에서 무한 스크롤 방식으로 변경한다.
- [ ] 검색 결과 화면에서 사용자가 브라우저 화면의 끝에 도달하면 그 다음 20개의 목록을 서버에 요청하여 추가로 불러올 수 있다.

- [ ] e2e 테스트 작성하기
35 changes: 34 additions & 1 deletion cypress/e2e/main.cy.ts → cypress/e2e/step1/main.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,46 @@ describe("메인 페이지", () => {
});

it("데이터를 불러오지 못했을 때 에러 메시지를 표시한다", () => {
cy.intercept("GET", "**/movie/popular**", { forceNetworkError: true }).as("networkError");
cy.intercept("GET", "**/movie/popular**", { forceNetworkError: true }).as(
"networkError",
);

cy.visit("/");
cy.wait("@networkError");
cy.contains("데이터를 불러오지 못했습니다.").should("be.visible");
});

it("두 번째 페칭 실패 시 스켈레톤 없이 에러 컴포넌트가 전체 row를 차지한다", () => {
let callCount = 0;
cy.intercept("GET", "**/movie/popular**", (req) => {
callCount++;
if (callCount === 1) {
req.reply({
results: Array.from({ length: 20 }, (_, i) => ({
id: i,
title: `영화 ${i}`,
poster_path: null,
vote_average: 7.0,
})),
page: 1,
total_pages: 5,
});
} else {
req.destroy();
}
}).as("movieFetch");

cy.visit("/");
cy.wait("@movieFetch");
cy.get(".item").should("have.length", 20);
cy.contains("button", "더 보기").click();
cy.get(".skeleton-box").should("not.exist");
cy.get(".item").should("have.length", 20);
cy.get(".movie-list-message-content")
.should("be.visible")
.should("have.css", "grid-column", "1 / -1");
});

it("더보기 버튼이 마지막 페이지에서 숨겨진다", () => {
cy.intercept("GET", "**/movie/popular**", (req) => {
req.reply({
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions cypress/e2e/search.cy.ts → cypress/e2e/step1/search.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ describe("검색", () => {

it("검색 결과가 없을 때 empty 상태를 표시한다", () => {
cy.visit("/search?query=zzzzzzzzzzzzzzzzzzz");
cy.get(".empty").should("exist");
cy.get(".movie-list-message-content").should("exist");
cy.contains("검색 결과가 없습니다.").should("be.visible");
});

it("검색 결과가 없을 때 그리드 레이아웃이 적용되지 않는다", () => {
it("검색 결과가 없을 때 아이템 없이 안내 메시지만 표시한다", () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

생각해보니 위의 테스트와 분리해주신 이유가 있을까요?

cy.visit("/search?query=zzzzzzzzzzzzzzzzzzz");
cy.get(".movie-list-empty").should("exist");
cy.get(".movie-list").should("not.exist");
cy.get(".item").should("not.exist");
cy.get(".movie-list-message-content").should("exist");
});

it("포스터가 없는 영화는 fallback을 표시한다", () => {
Expand Down
11 changes: 11 additions & 0 deletions cypress/e2e/step2/fixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const MOVIE_DETAIL_FIXTURE = {
id: 1,
title: "인터스텔라",
overview: "우주를 탐험하는 이야기",
poster_path: null,
release_date: "2014-11-06",
vote_average: 8.6,
genres: [{ id: 878, name: "SF" }],
runtime: 169,
tagline: "우주의 끝으로",
};
62 changes: 62 additions & 0 deletions cypress/e2e/step2/infinite-scroll.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
describe("무한 스크롤", () => {
beforeEach(() => {
cy.intercept("GET", "**/movie/popular**", (req) => {
const url = new URL(req.url);
const page = Number(url.searchParams.get("page")) || 1;
req.reply({
results: Array.from({ length: 20 }, (_, i) => ({
id: (page - 1) * 20 + i + 1,
title: `영화 ${(page - 1) * 20 + i + 1}`,
poster_path: null,
vote_average: 7.0,
})),
page,
total_pages: 3,
});
}).as("popularMovies");

cy.visit("/");
cy.wait("@popularMovies");
});

it("스크롤 하단 도달 시 다음 페이지가 로드된다", () => {
cy.get(".item").should("have.length", 20);
cy.scrollTo("bottom");
cy.wait("@popularMovies");
cy.get(".item").should("have.length", 40);
});

it("마지막 페이지 도달 시 더 이상 로드되지 않는다", () => {
cy.scrollTo("bottom");
cy.wait("@popularMovies");
cy.scrollTo("bottom");
cy.wait("@popularMovies");
cy.get(".item").should("have.length", 60);
cy.scrollTo("bottom");
cy.get(".item").should("have.length", 60);
});

it("검색 페이지에서도 무한 스크롤이 동작한다", () => {
cy.intercept("GET", "**/search/movie**", (req) => {
const url = new URL(req.url);
const page = Number(url.searchParams.get("page")) || 1;
req.reply({
results: Array.from({ length: 20 }, (_, i) => ({
id: (page - 1) * 20 + i + 1,
title: `검색결과 ${(page - 1) * 20 + i + 1}`,
poster_path: null,
vote_average: 7.0,
})),
page,
total_pages: 3,
});
}).as("searchMovies");

cy.visit(`/search?query=${encodeURIComponent("영화")}`);
cy.wait("@searchMovies");
cy.get(".item").should("have.length", 20);
cy.scrollTo("bottom");
cy.wait("@searchMovies");
cy.get(".item").should("have.length", 40);
});
});
80 changes: 80 additions & 0 deletions cypress/e2e/step2/modal.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { MOVIE_DETAIL_FIXTURE } from "./fixtures";

describe("모달", () => {
beforeEach(() => {
cy.intercept("GET", "**/movie/popular**", (req) => {
req.reply({
results: Array.from({ length: 20 }, (_, i) => ({
id: i + 1,
title: `영화 ${i + 1}`,
poster_path: null,
vote_average: 7.0,
})),
page: 1,
total_pages: 5,
});
}).as("popularMovies");

cy.intercept("GET", "**/movie/1**", (req) => {
req.reply(MOVIE_DETAIL_FIXTURE);
}).as("movieDetail");

cy.visit("/");
cy.wait("@popularMovies");
});

it("영화 카드 클릭 시 모달이 열린다", () => {
cy.get(".item").first().click();
cy.get("dialog.modal").should("be.visible");
});

it("모달에 영화 정보가 표시된다", () => {
cy.get(".item").first().click();
cy.wait("@movieDetail");
cy.get("dialog.modal").within(() => {
cy.get("h2").should("contain.text", "인터스텔라");
cy.get(".overview").should("contain.text", "우주를 탐험하는 이야기");
cy.get(".rate-value").should("contain.text", "8.6");
cy.get(".category").should("contain.text", "2014");
});
});

it("닫기 버튼 클릭 시 모달이 닫힌다", () => {
cy.get(".item").first().click();
cy.get("dialog.modal").should("be.visible");
cy.get("dialog.modal .close-modal").click({ force: true });
cy.get("dialog.modal").should("not.be.visible");
});

it("backdrop 클릭 시 모달이 닫힌다", () => {
cy.get(".item").first().click();
cy.get("dialog.modal").should("be.visible");
cy.get("dialog.modal").click("topLeft", { force: true });
cy.get("dialog.modal").should("not.be.visible");
});

it("API 실패 시 에러 메시지가 표시된다", () => {
cy.intercept("GET", "**/movie/1**", { forceNetworkError: true }).as(
"movieDetailError",
);
cy.get(".item").first().click();
cy.wait("@movieDetailError");
cy.get("dialog.modal").within(() => {
cy.get("h2").should("contain.text", "오류가 발생했습니다");
});
});

it("로딩 중 스켈레톤이 표시된다", () => {
cy.intercept("GET", "**/movie/1**", (req) => {
req.on("response", (res) => {
res.setDelay(500);
});
req.reply(MOVIE_DETAIL_FIXTURE);
}).as("slowMovieDetail");

cy.get(".item").first().click();
cy.get("dialog.modal .skeleton-box").should("exist");
cy.wait("@slowMovieDetail");
cy.get("dialog.modal .skeleton-box").should("not.exist");
});
});
63 changes: 63 additions & 0 deletions cypress/e2e/step2/rating.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { MOVIE_DETAIL_FIXTURE } from "./fixtures";

describe("별점", () => {
beforeEach(() => {
cy.clearLocalStorage();

cy.intercept("GET", "**/movie/popular**", (req) => {
req.reply({
results: [
{ id: 1, title: "인터스텔라", poster_path: null, vote_average: 8.6 },
],
page: 1,
total_pages: 1,
});
}).as("popularMovies");

cy.intercept("GET", "**/movie/1**", (req) => {
req.reply(MOVIE_DETAIL_FIXTURE);
}).as("movieDetail");

cy.visit("/");
cy.wait("@popularMovies");
cy.get(".item").first().click();
cy.wait("@movieDetail");
});

it("별점 클릭 시 점수와 라벨이 표시된다", () => {
cy.get(".my-rating-star").eq(3).click();
cy.get(".my-rating-score").should("contain.text", "(8/10)");
cy.get(".my-rating-text").should("contain.text", "재미있어요");
});

it("별점이 localStorage에 저장된다", () => {
cy.get(".my-rating-star").eq(4).click();
cy.window().then((win) => {
const stored = win.localStorage.getItem("ratings");
expect(stored).to.include("10");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

"10"이라는 문자열 포함 여부만 체크하면 movieId가 10인 경우에도 통과할 것 같은데요. JSON.parse 후 직접 rating을 확인해야 더 정확할 것 같아요ㅎㅎ

});
});

it("모달 재오픈 시 별점이 유지된다", () => {
cy.get(".my-rating-star").eq(2).click();
cy.get("dialog.modal .close-modal").click({ force: true });
cy.get(".item").first().click();
cy.wait("@movieDetail");
cy.get(".my-rating-score").should("contain.text", "(6/10)");
});

it("별점 hover 시 해당 별까지 채워진다", () => {
cy.get(".my-rating-star").eq(2).trigger("mouseenter");
cy.get(".my-rating-star").eq(0).should("have.class", "filled");
cy.get(".my-rating-star").eq(1).should("have.class", "filled");
cy.get(".my-rating-star").eq(2).should("have.class", "filled");
cy.get(".my-rating-star").eq(3).should("not.have.class", "filled");
});

it("별점 hover 해제 시 저장된 별점으로 돌아온다", () => {
cy.get(".my-rating-star").eq(1).click();
cy.get(".my-rating-star").eq(4).trigger("mouseenter");
cy.get(".my-rating-star").eq(4).trigger("mouseleave");
cy.get(".my-rating-score").should("contain.text", "(4/10)");
});
});
3 changes: 3 additions & 0 deletions src/api/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ export const TMDB_IMAGE_BASE_URL = "https://image.tmdb.org/t/p";
export const ENDPOINTS = {
POPULAR: `${TMDB_BASE_URL}/movie/popular`,
SEARCH: `${TMDB_BASE_URL}/search/movie`,
MOVIE_DETAIL: (id: number) => `${TMDB_BASE_URL}/movie/${id}`,
} as const;

export const TMDB_MAX_PAGE = 500;

export const DEFAULT_PARAMS = {
language: "ko-KR",
include_adult: false,
Expand Down
Loading