From 4f2d3ee4742dcfff24d8e0d4cd0530372f7e12a5 Mon Sep 17 00:00:00 2001 From: rockpell Date: Mon, 25 Jul 2022 21:48:13 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Test:=20Guest=20role=EC=9D=B4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=EB=90=98=EB=A9=B4=EC=84=9C=20=EC=8B=A4=ED=8C=A8?= =?UTF-8?q?=ED=95=98=EB=8D=98=20=EC=9C=A0=EB=8B=9B=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/utils/src/utils.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/utils/src/utils.spec.ts b/libs/utils/src/utils.spec.ts index 5159dff3..04397ac8 100644 --- a/libs/utils/src/utils.spec.ts +++ b/libs/utils/src/utils.spec.ts @@ -5,18 +5,18 @@ describe('includeRole', () => { test('ADMIN 권한을 확인하는 경우', () => { const result = includeRole(UserRole.ADMIN); - expect(result.sort()).toStrictEqual([UserRole.ADMIN, UserRole.CADET, UserRole.NOVICE]); + expect(result.sort()).toStrictEqual([UserRole.ADMIN, UserRole.CADET, UserRole.GUEST, UserRole.NOVICE]); }); test('CADET 권한을 확인하는 경우', () => { const result = includeRole(UserRole.CADET); - expect(result.sort()).toStrictEqual([UserRole.CADET, UserRole.NOVICE]); + expect(result.sort()).toStrictEqual([UserRole.CADET, UserRole.GUEST, UserRole.NOVICE]); }); test('NOVICE 권한을 확인하는 경우', () => { const result = includeRole(UserRole.NOVICE); - expect(result.sort()).toStrictEqual([UserRole.NOVICE]); + expect(result.sort()).toStrictEqual([UserRole.GUEST, UserRole.NOVICE]); }); }); From bf576fcbb20ca20f407e999cba638789a52f5283 Mon Sep 17 00:00:00 2001 From: rockpell Date: Mon, 25 Jul 2022 21:48:42 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Chore:=20=EC=9C=A0=EB=8B=9B=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EB=8F=84=20makefile=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index cd996acc..a7fb8965 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,7 @@ test: test-api .PHONY: test-api test-api: test-ready + yarn test yarn test:e2e ./apps/api/test/e2e/*.e2e-spec.ts # Alpha & Production ================================================= From c924a14f26e353b27c16ba9ffbd896f9cf6dbda1 Mon Sep 17 00:00:00 2001 From: huni Date: Sat, 6 Aug 2022 22:48:52 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=EC=95=8C=EB=A6=BC=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/notification/notification.service.ts | 2 +- apps/api/test/e2e/notification.e2e-spec.ts | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/api/src/notification/notification.service.ts b/apps/api/src/notification/notification.service.ts index 1b4ea8bf..6f46cf0c 100644 --- a/apps/api/src/notification/notification.service.ts +++ b/apps/api/src/notification/notification.service.ts @@ -25,7 +25,7 @@ export class NotificationService { } async findByUserId(userId: number): Promise { - return this.notificationRepository.find({ where: { userId } }); + return this.notificationRepository.find({ where: { userId }, order: { createdAt: 'DESC' } }); } async updateIsReadByUserId(userId: number): Promise { diff --git a/apps/api/test/e2e/notification.e2e-spec.ts b/apps/api/test/e2e/notification.e2e-spec.ts index 01d3c2eb..04aed79f 100644 --- a/apps/api/test/e2e/notification.e2e-spec.ts +++ b/apps/api/test/e2e/notification.e2e-spec.ts @@ -65,7 +65,7 @@ describe('Notification', () => { describe('/notifications', () => { let dummyUser: User; let dummyArticle: Article; - let dummyNotification: Notification; + let dummyNotification: Notification[]; beforeEach(async () => { users = await dummy.createDummyUsers(userRepository); @@ -73,12 +73,10 @@ describe('Notification', () => { categories = await dummy.createDummyCategories(categoryRepository); articles = await dummy.createDummyArticles(articleRepository, users, categories); dummyArticle = articles.first; - dummyNotification = dummy.notification( - NotificationType.NEW_COMMENT, - dummyUser.id, - dummyArticle.id, - 'notification content', - ); + dummyNotification = [ + dummy.notification(NotificationType.NEW_COMMENT, dummyUser.id, dummyArticle.id, 'notification content'), + dummy.notification(NotificationType.NEW_COMMENT, dummyUser.id, dummyArticle.id, 'notification content 2'), + ]; await notificationRepository.save(dummyNotification); JWT = dummy.jwt(dummyUser, authService); }); @@ -88,9 +86,12 @@ describe('Notification', () => { .get('/notifications') .set('Cookie', `${process.env.ACCESS_TOKEN_KEY}=${JWT}`); expect(res.status).toEqual(HttpStatus.OK); - expect(res.body[0].articleId).toEqual(dummyArticle.id); - expect(res.body[0].type).toEqual(dummyNotification.type); - expect(res.body[0].content).toEqual(dummyNotification.content); + expect(res.body[0].articleId).toEqual(dummyNotification[1].articleId); + expect(res.body[0].type).toEqual(dummyNotification[1].type); + expect(res.body[0].content).toEqual(dummyNotification[1].content); + expect(res.body[1].articleId).toEqual(dummyNotification[0].articleId); + expect(res.body[1].type).toEqual(dummyNotification[0].type); + expect(res.body[1].content).toEqual(dummyNotification[0].content); }); test('[실패] GET - 로그인하지 않고 호출', async () => {