From 2f1548fda32c3ba9e53913270394eedfacd55986 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 8 Jan 2019 11:26:41 +0100 Subject: Add notifications in the client --- .../tests/api/check-params/user-notifications.ts | 51 +++++++++++++++++----- server/tests/api/check-params/users.ts | 3 +- 2 files changed, 42 insertions(+), 12 deletions(-) (limited to 'server/tests/api/check-params') diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts index 635f5c9a3..714f481e9 100644 --- a/server/tests/api/check-params/user-notifications.ts +++ b/server/tests/api/check-params/user-notifications.ts @@ -96,6 +96,16 @@ describe('Test user notifications API validators', function () { statusCodeExpected: 400 }) + await makePostBodyRequest({ + url: server.url, + path, + fields: { + ids: [ ] + }, + token: server.accessToken, + statusCodeExpected: 400 + }) + await makePostBodyRequest({ url: server.url, path, @@ -131,18 +141,39 @@ describe('Test user notifications API validators', function () { }) }) + describe('When marking as read my notifications', function () { + const path = '/api/v1/users/me/notifications/read-all' + + it('Should fail with a non authenticated user', async function () { + await makePostBodyRequest({ + url: server.url, + path, + statusCodeExpected: 401 + }) + }) + + it('Should succeed with the correct parameters', async function () { + await makePostBodyRequest({ + url: server.url, + path, + token: server.accessToken, + statusCodeExpected: 204 + }) + }) + }) + describe('When updating my notification settings', function () { const path = '/api/v1/users/me/notification-settings' const correctFields: UserNotificationSetting = { - newVideoFromSubscription: UserNotificationSettingValue.WEB_NOTIFICATION, - newCommentOnMyVideo: UserNotificationSettingValue.WEB_NOTIFICATION, - videoAbuseAsModerator: UserNotificationSettingValue.WEB_NOTIFICATION, - blacklistOnMyVideo: UserNotificationSettingValue.WEB_NOTIFICATION, - myVideoImportFinished: UserNotificationSettingValue.WEB_NOTIFICATION, - myVideoPublished: UserNotificationSettingValue.WEB_NOTIFICATION, - commentMention: UserNotificationSettingValue.WEB_NOTIFICATION, - newFollow: UserNotificationSettingValue.WEB_NOTIFICATION, - newUserRegistration: UserNotificationSettingValue.WEB_NOTIFICATION + newVideoFromSubscription: UserNotificationSettingValue.WEB, + newCommentOnMyVideo: UserNotificationSettingValue.WEB, + videoAbuseAsModerator: UserNotificationSettingValue.WEB, + blacklistOnMyVideo: UserNotificationSettingValue.WEB, + myVideoImportFinished: UserNotificationSettingValue.WEB, + myVideoPublished: UserNotificationSettingValue.WEB, + commentMention: UserNotificationSettingValue.WEB, + newFollow: UserNotificationSettingValue.WEB, + newUserRegistration: UserNotificationSettingValue.WEB } it('Should fail with missing fields', async function () { @@ -150,7 +181,7 @@ describe('Test user notifications API validators', function () { url: server.url, path, token: server.accessToken, - fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB_NOTIFICATION }, + fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB }, statusCodeExpected: 400 }) }) diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index f8044cbd4..a3e8e2e9c 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -485,11 +485,10 @@ describe('Test users API validators', function () { email: 'email@example.com', emailVerified: true, videoQuota: 42, - role: UserRole.MODERATOR + role: UserRole.USER } await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields, statusCodeExpected: 204 }) - userAccessToken = await userLogin(server, user) }) }) -- cgit v1.2.3