]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/user-notifications.ts
Add ability to forbid followers
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / user-notifications.ts
index 3ae36ddb325434b87a6ad9edfe684353bca62ed1..36eaceac7b2a1206a1eb89d170a9a98a19e0570d 100644 (file)
@@ -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
       })
     })