Skip to content

Commit

Permalink
🩹 관심강좌 제거 시 모달 안 닫히는 이슈 픽스 (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
woohm402 authored May 26, 2024
1 parent d3e9c40 commit 56cb238
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 6 deletions.
33 changes: 33 additions & 0 deletions apps/snutt-webclient/e2e/main/lecture-section.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
]);
});
2 changes: 1 addition & 1 deletion apps/snutt-webclient/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const config: PlaywrightTestConfig = {
testDir: './e2e',
timeout: 5000,

expect: { timeout: 2000 },
expect: { timeout: 5000 },

fullyParallel: true,
forbidOnly: !!process.env.CI,
Expand Down
2 changes: 1 addition & 1 deletion apps/snutt-webclient/src/mocks/fixtures/bookmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down
12 changes: 11 additions & 1 deletion apps/snutt-webclient/src/mocks/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {} })),
),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ export const MainLectureListitem = ({
</div>
<div className={styles.bookmarkWrapper}>
{vm.header.bookmark.isShow && (
<button onClick={vm.header.bookmark.onClick} className={styles.bookmarkButton}>
<button
onClick={vm.header.bookmark.onClick}
className={styles.bookmarkButton}
data-testid="main-lecture-listitem-bookmark"
>
{
{
'bookmark-fill': <IcBookmarkFill className={styles.bookmarkIcon} />,
Expand Down Expand Up @@ -118,7 +122,12 @@ export const MainLectureListitem = ({
<Button color="gray" size="small" onClick={vm.deleteBookmarkDialog.onClose}>
취소
</Button>
<Button color="red" size="small" onClick={vm.deleteBookmarkDialog.onClick}>
<Button
color="red"
size="small"
onClick={vm.deleteBookmarkDialog.onClick}
data-testid="bookmark-delete-confirm"
>
제거하기
</Button>
</Dialog.Actions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},
}),
},
};
Expand Down

0 comments on commit 56cb238

Please sign in to comment.