]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/moderation/blocklist.ts
Adapt CLI to new commands
[github/Chocobozzz/PeerTube.git] / server / tests / api / moderation / blocklist.ts
index 00cb6c65ce77ca26cd460abb6f5576509de5df3d..c38a7dad403f62dc6e877c1ba255b12be99844b4 100644 (file)
@@ -9,16 +9,14 @@ import {
   createUser,
   doubleFollow,
   flushAndRunMultipleServers,
-  getUserNotifications,
   getVideosList,
   getVideosListWithToken,
   ServerInfo,
   setAccessTokensToServers,
   uploadVideo,
-  userLogin,
   waitJobs
 } from '@shared/extra-utils'
-import { UserNotification, UserNotificationType, Video } from '@shared/models'
+import { UserNotificationType, Video } from '@shared/models'
 
 const expect = chai.expect
 
@@ -59,9 +57,8 @@ async function checkCommentNotification (
 
   await waitJobs([ mainServer, comment.server ])
 
-  const res = await getUserNotifications(mainServer.url, mainServer.accessToken, 0, 30)
-  const commentNotifications = (res.body.data as UserNotification[])
-                                  .filter(n => n.comment && n.comment.video.uuid === comment.videoUUID && n.createdAt >= createdAt)
+  const { data } = await mainServer.notificationsCommand.list({ start: 0, count: 30 })
+  const commentNotifications = data.filter(n => n.comment && n.comment.video.uuid === comment.videoUUID && n.createdAt >= createdAt)
 
   if (check === 'presence') expect(commentNotifications).to.have.lengthOf(1)
   else expect(commentNotifications).to.have.lengthOf(0)
@@ -96,7 +93,7 @@ describe('Test blocklist', function () {
       const user = { username: 'user1', password: 'password' }
       await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
 
-      userToken1 = await userLogin(servers[0], user)
+      userToken1 = await servers[0].loginCommand.getAccessToken(user)
       await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' })
     }
 
@@ -104,14 +101,14 @@ describe('Test blocklist', function () {
       const user = { username: 'moderator', password: 'password' }
       await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
 
-      userModeratorToken = await userLogin(servers[0], user)
+      userModeratorToken = await servers[0].loginCommand.getAccessToken(user)
     }
 
     {
       const user = { username: 'user2', password: 'password' }
       await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
 
-      userToken2 = await userLogin(servers[1], user)
+      userToken2 = await servers[1].loginCommand.getAccessToken(user)
       await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' })
     }
 
@@ -710,12 +707,10 @@ describe('Test blocklist', function () {
 
           await waitJobs(servers)
 
-          const res = await getUserNotifications(servers[0].url, servers[0].accessToken, 0, 30)
-          const commentNotifications = (res.body.data as UserNotification[])
-                                          .filter(n => {
-                                            return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER &&
-                                            n.createdAt >= now.toISOString()
-                                          })
+          const { data } = await servers[0].notificationsCommand.list({ start: 0, count: 30 })
+          const commentNotifications = data.filter(n => {
+            return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER && n.createdAt >= now.toISOString()
+          })
 
           expect(commentNotifications).to.have.lengthOf(0)
         }
@@ -773,12 +768,10 @@ describe('Test blocklist', function () {
 
           await waitJobs(servers)
 
-          const res = await getUserNotifications(servers[0].url, servers[0].accessToken, 0, 30)
-          const commentNotifications = (res.body.data as UserNotification[])
-                                          .filter(n => {
-                                            return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER &&
-                                            n.createdAt >= now.toISOString()
-                                          })
+          const { data } = await servers[0].notificationsCommand.list({ start: 0, count: 30 })
+          const commentNotifications = data.filter(n => {
+            return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER && n.createdAt >= now.toISOString()
+          })
 
           expect(commentNotifications).to.have.lengthOf(1)
         }