]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/notifications/notifications-api.ts
Fix CI
[github/Chocobozzz/PeerTube.git] / server / tests / api / notifications / notifications-api.ts
index fa4b53db6c1f678e98ba085783479d71c4d0d5a1..1fc86116047eabdad1606a9912886e2bbd9743b7 100644 (file)
@@ -1,20 +1,15 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import 'mocha'
-import * as chai from 'chai'
+import { expect } 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'
-
-const expect = chai.expect
+import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'
 
 describe('Test notifications API', function () {
   let server: PeerTubeServer
@@ -31,7 +26,7 @@ describe('Test notifications API', function () {
     userNotifications = res.userNotifications
     server = res.servers[0]
 
-    await server.subscriptions.add({ token: userToken, targetUri: 'root_channel@localhost:' + server.port })
+    await server.subscriptions.add({ token: userToken, targetUri: 'root_channel@' + server.host })
 
     for (let i = 0; i < 10; i++) {
       await server.videos.randomUpload({ wait: false })
@@ -40,6 +35,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 () {
@@ -91,7 +96,7 @@ describe('Test notifications API', function () {
 
     before(() => {
       baseParams = {
-        server: server,
+        server,
         emails,
         socketNotifications: userNotifications,
         token: userToken
@@ -111,10 +116,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 +135,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 +161,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 +192,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' })
     })
   })