From 56cb238684e32fda1a8d851a5e1c006626011994 Mon Sep 17 00:00:00 2001 From: "Hyunmin Woo (Hanul)" Date: Sun, 26 May 2024 22:05:41 +0900 Subject: [PATCH] =?UTF-8?q?:adhesive=5Fbandage:=20=EA=B4=80=EC=8B=AC?= =?UTF-8?q?=EA=B0=95=EC=A2=8C=20=EC=A0=9C=EA=B1=B0=20=EC=8B=9C=20=EB=AA=A8?= =?UTF-8?q?=EB=8B=AC=20=EC=95=88=20=EB=8B=AB=ED=9E=88=EB=8A=94=20=EC=9D=B4?= =?UTF-8?q?=EC=8A=88=20=ED=94=BD=EC=8A=A4=20(#155)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://wafflestudio.slack.com/archives/C0PAVPS5T/p1716724965976609?thread_ts=1716399538.928789&cid=C0PAVPS5T --- .../e2e/main/lecture-section.spec.ts | 33 +++++++++++++++++++ apps/snutt-webclient/playwright.config.ts | 2 +- .../src/mocks/fixtures/bookmark.ts | 2 +- .../src/mocks/handlers/index.ts | 12 ++++++- .../main-lecture-listitem/index.component.tsx | 13 ++++++-- .../main-lecture-listitem/index.presenter.ts | 7 +++- 6 files changed, 63 insertions(+), 6 deletions(-) diff --git a/apps/snutt-webclient/e2e/main/lecture-section.spec.ts b/apps/snutt-webclient/e2e/main/lecture-section.spec.ts index 1194cc5..96da0b2 100644 --- a/apps/snutt-webclient/e2e/main/lecture-section.spec.ts +++ b/apps/snutt-webclient/e2e/main/lecture-section.spec.ts @@ -149,3 +149,36 @@ test('검색 결과 탭에서 추가 기능이 정상 동작한다 (실패)', as await page.getByTestId('main-lecture-listitem').nth(0).getByText('추가').click(); await expect(page.getByTestId('error-dialog-message')).toHaveText('강의 시간이 서로 겹칩니다.'); }); + +test('검색 결과 탭에서 관심강좌를 제거할 수 있다', async ({ page }) => { + await page.goto('/'); + await givenUser(page, { login: true }); + await page.getByTestId('main-searchbar-search').click(); + await page.getByTestId('main-lecture-listitem').nth(0).getByTestId('main-lecture-listitem-bookmark').click(); + await Promise.all([ + page.waitForRequest( + (req) => + req.method() === 'DELETE' && + req.url().includes('/v1/bookmarks/lecture') && + req.postDataJSON().lecture_id === '6329ab4ecb360c002b6eec57', + ), + await page.getByTestId('bookmark-delete-confirm').click(), + ]); + await expect(page.getByTestId('bookmark-delete-confirm')).toHaveCount(0); +}); + +test('검색 결과 탭에서 관심강좌를 추가할 수 있다', async ({ page }) => { + await page.goto('/'); + await givenUser(page, { login: true }); + await page.getByTestId('main-searchbar-search').click(); + + await Promise.all([ + page.waitForRequest( + (req) => + req.method() === 'POST' && + req.url().includes('/v1/bookmarks/lecture') && + req.postDataJSON().lecture_id === '6329ab4ecb360c002b6ee9b6', + ), + await page.getByTestId('main-lecture-listitem').nth(1).getByTestId('main-lecture-listitem-bookmark').click(), + ]); +}); diff --git a/apps/snutt-webclient/playwright.config.ts b/apps/snutt-webclient/playwright.config.ts index 1cdfc07..fcf2c25 100644 --- a/apps/snutt-webclient/playwright.config.ts +++ b/apps/snutt-webclient/playwright.config.ts @@ -6,7 +6,7 @@ const config: PlaywrightTestConfig = { testDir: './e2e', timeout: 5000, - expect: { timeout: 2000 }, + expect: { timeout: 5000 }, fullyParallel: true, forbidOnly: !!process.env.CI, diff --git a/apps/snutt-webclient/src/mocks/fixtures/bookmark.ts b/apps/snutt-webclient/src/mocks/fixtures/bookmark.ts index 4d69d38..e8e0419 100644 --- a/apps/snutt-webclient/src/mocks/fixtures/bookmark.ts +++ b/apps/snutt-webclient/src/mocks/fixtures/bookmark.ts @@ -5,7 +5,7 @@ export const mockBookmarks: SnuttApiSuccessResponseData<'GET /v1/bookmarks'> = { semester: 1, lectures: [ { - _id: '60b3b3b3b3b3b3b3b3b3b3b3', + _id: '6329ab4ecb360c002b6eec57', course_title: '관심강의1', class_time_json: [], class_time_mask: [], diff --git a/apps/snutt-webclient/src/mocks/handlers/index.ts b/apps/snutt-webclient/src/mocks/handlers/index.ts index bd9e079..d2bb2eb 100644 --- a/apps/snutt-webclient/src/mocks/handlers/index.ts +++ b/apps/snutt-webclient/src/mocks/handlers/index.ts @@ -385,7 +385,17 @@ export const handlers = [ http.get( `*/v1/bookmarks`, - withValidateAccess(() => ({ type: 'success', body: mockBookmarks }), { token: false }), + withValidateAccess(() => ({ type: 'success', body: mockBookmarks })), + ), + + http.post( + `*/v1/bookmarks/lecture`, + withValidateAccess(() => ({ type: 'success', body: {} })), + ), + + http.delete( + `*/v1/bookmarks/lecture`, + withValidateAccess(() => ({ type: 'success', body: {} })), ), ]; diff --git a/apps/snutt-webclient/src/pages/main/main-lecture-section/common/main-lecture-listitem/index.component.tsx b/apps/snutt-webclient/src/pages/main/main-lecture-section/common/main-lecture-listitem/index.component.tsx index 9de3271..f347da6 100644 --- a/apps/snutt-webclient/src/pages/main/main-lecture-section/common/main-lecture-listitem/index.component.tsx +++ b/apps/snutt-webclient/src/pages/main/main-lecture-section/common/main-lecture-listitem/index.component.tsx @@ -44,7 +44,11 @@ export const MainLectureListitem = ({
{vm.header.bookmark.isShow && ( - - diff --git a/apps/snutt-webclient/src/pages/main/main-lecture-section/common/main-lecture-listitem/index.presenter.ts b/apps/snutt-webclient/src/pages/main/main-lecture-section/common/main-lecture-listitem/index.presenter.ts index 26597db..868b62d 100644 --- a/apps/snutt-webclient/src/pages/main/main-lecture-section/common/main-lecture-listitem/index.presenter.ts +++ b/apps/snutt-webclient/src/pages/main/main-lecture-section/common/main-lecture-listitem/index.presenter.ts @@ -171,7 +171,12 @@ export const mainLectureListitemPresenter = { onClose: () => setDeleteBookmarkDialogOpen(false), onClick: () => deleteBookmarkMutation.mutate(undefined, { - onSuccess: (data) => data.type === 'success' && onMouseLeave?.(), + onSuccess: (data) => { + if (data.type === 'success') { + onMouseLeave?.(); + setDeleteBookmarkDialogOpen(false); + } + }, }), }, };