From 964cd6616d2c60d232b68378b04081238a3fe9cb Mon Sep 17 00:00:00 2001 From: BangDori Date: Wed, 8 May 2024 00:51:49 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=ED=94=BC=EB=93=9C=20=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EB=AA=A9=EB=A1=9D=EC=97=90=20=EB=8C=80=ED=95=9C=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/FeedMainList.error.test.tsx | 29 +++++++++ .../feed-main-list/test/feedMainList.test.tsx | 65 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 src/widgets/feed-main-list/test/FeedMainList.error.test.tsx create mode 100644 src/widgets/feed-main-list/test/feedMainList.test.tsx diff --git a/src/widgets/feed-main-list/test/FeedMainList.error.test.tsx b/src/widgets/feed-main-list/test/FeedMainList.error.test.tsx new file mode 100644 index 0000000..92e5eb8 --- /dev/null +++ b/src/widgets/feed-main-list/test/FeedMainList.error.test.tsx @@ -0,0 +1,29 @@ +import { HttpResponse, http } from 'msw'; +import { expect, test } from 'vitest'; + +import { server } from '@/setupTest'; +import { render, screen } from '@/shared/tests/setup'; + +import { FeedMainList } from '..'; + +test('피드 메인 페이지 에러 발생 시, 네트워크 에러 메시지가 화면에 표시된다.', async () => { + // given + server.use( + http.get('/feeds', async () => { + return new HttpResponse(null, { status: 524 }); // 타임아웃 에러 반환 + }), + ); + render(); + + const errorTitle = await screen.findByRole('heading', { + level: 1, + name: '인터넷에 연결되지 않았어요', + }); + const retryButton = await screen.findByRole('button', { + name: '재시도하기', + }); + + // then + expect(errorTitle).toBeInTheDocument(); + expect(retryButton).toBeInTheDocument(); +}); diff --git a/src/widgets/feed-main-list/test/feedMainList.test.tsx b/src/widgets/feed-main-list/test/feedMainList.test.tsx new file mode 100644 index 0000000..0f11ba2 --- /dev/null +++ b/src/widgets/feed-main-list/test/feedMainList.test.tsx @@ -0,0 +1,65 @@ +import { HttpResponse, http } from 'msw'; +import { describe, expect, it } from 'vitest'; + +import { server } from '@/setupTest'; +import { render, screen } from '@/shared/tests/setup'; + +import { FeedMainList } from '..'; + +const mockingFeedData = [ + { + id: 1, + user: { id: 1, profileImage: '', name: '강병준' }, + content: 'Feed Content 1', + images: [], + + likeCount: 0, + commentCount: 0, + + isLiked: false, + isBookmark: false, + + createdAt: '2024-04-16 12:00:00', + updatedAt: '2024-04-16 12:00:00', + }, +]; + +describe('피드 메인 페이지 성공 시나리오', () => { + it('스켈레톤 UI가 화면에 먼저 렌더링된다.', async () => { + // given + render(); + const skeletonFeedMainList = document.querySelector( + '.skeleton-feed-section', + ); + + // then + expect(skeletonFeedMainList).toBeInTheDocument(); + }); + + it('스켈레톤 UI 이후 콘텐츠가 정상적으로 렌더링된다.', async () => { + // given + server.use( + http.get('/feeds', async () => { + return HttpResponse.json( + { + code: '2000', + data: { + feeds: mockingFeedData, + currentPageNumber: 1, + pageSize: 1, + numberOfElements: 1, + hasNextPage: false, + }, + }, + { status: 200 }, + ); + }), + ); + render(); + + const content = await screen.findByText(mockingFeedData[0].content); + + // then + expect(content).toBeInTheDocument(); + }); +}); From 1e5b22d76ce5a0457c6f109abff6ce73dd8c716a Mon Sep 17 00:00:00 2001 From: BangDori Date: Wed, 8 May 2024 01:08:03 +0900 Subject: [PATCH 2/3] =?UTF-8?q?style:=20=ED=94=BC=EB=93=9C=20=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=ED=83=80=EC=9D=B4=ED=8B=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widgets/feed-main-list/test/feedMainList.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/feed-main-list/test/feedMainList.test.tsx b/src/widgets/feed-main-list/test/feedMainList.test.tsx index 0f11ba2..4e5e290 100644 --- a/src/widgets/feed-main-list/test/feedMainList.test.tsx +++ b/src/widgets/feed-main-list/test/feedMainList.test.tsx @@ -24,7 +24,7 @@ const mockingFeedData = [ }, ]; -describe('피드 메인 페이지 성공 시나리오', () => { +describe('피드 메인 페이지에서', () => { it('스켈레톤 UI가 화면에 먼저 렌더링된다.', async () => { // given render(); From 6915298f2cb55e9a8635cd307ba582e8950c8246 Mon Sep 17 00:00:00 2001 From: BangDori <44726494+BangDori@users.noreply.github.com> Date: Wed, 8 May 2024 01:11:01 +0900 Subject: [PATCH 3/3] =?UTF-8?q?style:=20=ED=8C=8C=EC=9D=BC=EB=AA=85=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/{feedMainList.test.tsx => FeedMainList.test.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/widgets/feed-main-list/test/{feedMainList.test.tsx => FeedMainList.test.tsx} (100%) diff --git a/src/widgets/feed-main-list/test/feedMainList.test.tsx b/src/widgets/feed-main-list/test/FeedMainList.test.tsx similarity index 100% rename from src/widgets/feed-main-list/test/feedMainList.test.tsx rename to src/widgets/feed-main-list/test/FeedMainList.test.tsx