X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fuser-notifications.ts;h=36eaceac7b2a1206a1eb89d170a9a98a19e0570d;hb=5b9c965d5aa747f29b081289f930ee215fdc23c8;hp=3ae36ddb325434b87a6ad9edfe684353bca62ed1;hpb=cef534ed53e4518fe0acf581bfe880788d42fc36;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts index 3ae36ddb3..36eaceac7 100644 --- a/server/tests/api/check-params/user-notifications.ts +++ b/server/tests/api/check-params/user-notifications.ts @@ -52,6 +52,18 @@ describe('Test user notifications API validators', function () { await checkBadSortPagination(server.url, path, server.accessToken) }) + it('Should fail with an incorrect unread parameter', async function () { + await makeGetRequest({ + url: server.url, + path, + query: { + unread: 'toto' + }, + token: server.accessToken, + statusCodeExpected: 200 + }) + }) + it('Should fail with a non authenticated user', async function () { await makeGetRequest({ url: server.url, @@ -84,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, @@ -119,13 +141,40 @@ 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 + newVideoFromSubscription: UserNotificationSettingValue.WEB, + newCommentOnMyVideo: UserNotificationSettingValue.WEB, + videoAbuseAsModerator: UserNotificationSettingValue.WEB, + videoAutoBlacklistAsModerator: 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 () { @@ -133,7 +182,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 }) })