]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/notifications/notifications-api.ts
Implement avatar miniatures (#4639)
[github/Chocobozzz/PeerTube.git] / server / tests / api / notifications / notifications-api.ts
index fa4b53db6c1f678e98ba085783479d71c4d0d5a1..78864c8a04f8f9782e67c80798e14fcc63825ba3 100644 (file)
@@ -5,14 +5,12 @@ import * as chai from 'chai'
 import {
   CheckerBaseParams,
   checkNewVideoFromSubscription,
-  cleanupTests,
   getAllNotificationsSettings,
   MockSmtpServer,
-  PeerTubeServer,
-  prepareNotificationsTest,
-  waitJobs
-} from '@shared/extra-utils'
+  prepareNotificationsTest
+} from '@server/tests/shared'
 import { UserNotification, UserNotificationSettingValue } from '@shared/models'
+import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'
 
 const expect = chai.expect
 
@@ -40,6 +38,16 @@ describe('Test notifications API', function () {
     await waitJobs([ server ])
   })
 
+  describe('Notification list & count', function () {
+
+    it('Should correctly list notifications', async function () {
+      const { data, total } = await server.notifications.list({ token: userToken, start: 0, count: 2 })
+
+      expect(data).to.have.lengthOf(2)
+      expect(total).to.equal(10)
+    })
+  })
+
   describe('Mark as read', function () {
 
     it('Should mark as read some notifications', async function () {
@@ -111,10 +119,10 @@ describe('Test notifications API', function () {
         expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE)
       }
 
-      const { name, uuid } = await server.videos.randomUpload()
+      const { name, shortUUID } = await server.videos.randomUpload()
 
       const check = { web: true, mail: true }
-      await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence')
+      await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'absence' })
     })
 
     it('Should only have web notifications', async function () {
@@ -130,16 +138,16 @@ describe('Test notifications API', function () {
         expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB)
       }
 
-      const { name, uuid } = await server.videos.randomUpload()
+      const { name, shortUUID } = await server.videos.randomUpload()
 
       {
         const check = { mail: true, web: false }
-        await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence')
+        await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'absence' })
       }
 
       {
         const check = { mail: false, web: true }
-        await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'presence')
+        await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'presence' })
       }
     })
 
@@ -156,16 +164,16 @@ describe('Test notifications API', function () {
         expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL)
       }
 
-      const { name, uuid } = await server.videos.randomUpload()
+      const { name, shortUUID } = await server.videos.randomUpload()
 
       {
         const check = { mail: false, web: true }
-        await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence')
+        await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'absence' })
       }
 
       {
         const check = { mail: true, web: false }
-        await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'presence')
+        await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'presence' })
       }
     })
 
@@ -187,9 +195,9 @@ describe('Test notifications API', function () {
         )
       }
 
-      const { name, uuid } = await server.videos.randomUpload()
+      const { name, shortUUID } = await server.videos.randomUpload()
 
-      await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
+      await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' })
     })
   })