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 = ({