]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/moderation/blocklist-notification.ts
Introduce import command
[github/Chocobozzz/PeerTube.git] / server / tests / api / moderation / blocklist-notification.ts
index 4fb3c95f2ef18eca8326f609b0ef81862ab2f2c2..5b9699816630610b7ebfb1f62f93bfbb3f727896 100644 (file)
@@ -2,30 +2,21 @@
 
 import 'mocha'
 import * as chai from 'chai'
-import { getUserNotifications, markAsReadAllNotifications } from '@shared/extra-utils/users/user-notifications'
-import { addUserSubscription, removeUserSubscription } from '@shared/extra-utils/users/user-subscriptions'
-import { UserNotification, UserNotificationType } from '@shared/models'
 import {
+  addVideoCommentThread,
   cleanupTests,
   createUser,
   doubleFollow,
   flushAndRunMultipleServers,
+  getUserNotifications,
+  markAsReadAllNotifications,
   ServerInfo,
+  setAccessTokensToServers,
   uploadVideo,
-  userLogin
-} from '../../../../shared/extra-utils/index'
-import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
-import {
-  addAccountToAccountBlocklist,
-  addAccountToServerBlocklist,
-  addServerToAccountBlocklist,
-  addServerToServerBlocklist,
-  removeAccountFromAccountBlocklist,
-  removeAccountFromServerBlocklist,
-  removeServerFromAccountBlocklist
-} from '../../../../shared/extra-utils/users/blocklist'
-import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
-import { addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments'
+  userLogin,
+  waitJobs
+} from '@shared/extra-utils'
+import { UserNotification, UserNotificationType } from '@shared/models'
 
 const expect = chai.expect
 
@@ -51,8 +42,8 @@ describe('Test blocklist', function () {
 
   async function resetState () {
     try {
-      await removeUserSubscription(servers[1].url, remoteUserToken, 'user1_channel@' + servers[0].host)
-      await removeUserSubscription(servers[1].url, remoteUserToken, 'user2_channel@' + servers[0].host)
+      await servers[1].subscriptionsCommand.remove({ token: remoteUserToken, uri: 'user1_channel@' + servers[0].host })
+      await servers[1].subscriptionsCommand.remove({ token: remoteUserToken, uri: 'user2_channel@' + servers[0].host })
     } catch {}
 
     await waitJobs(servers)
@@ -73,8 +64,8 @@ describe('Test blocklist', function () {
 
     {
 
-      await addUserSubscription(servers[1].url, remoteUserToken, 'user1_channel@' + servers[0].host)
-      await addUserSubscription(servers[1].url, remoteUserToken, 'user2_channel@' + servers[0].host)
+      await servers[1].subscriptionsCommand.add({ token: remoteUserToken, targetUri: 'user1_channel@' + servers[0].host })
+      await servers[1].subscriptionsCommand.add({ token: remoteUserToken, targetUri: 'user2_channel@' + servers[0].host })
     }
 
     await waitJobs(servers)
@@ -134,7 +125,7 @@ describe('Test blocklist', function () {
     it('Should block an account', async function () {
       this.timeout(10000)
 
-      await addAccountToAccountBlocklist(servers[0].url, userToken1, 'user3@' + servers[1].host)
+      await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host })
       await waitJobs(servers)
     })
 
@@ -147,7 +138,7 @@ describe('Test blocklist', function () {
 
       await checkNotifications(servers[0].url, userToken2, notifs)
 
-      await removeAccountFromAccountBlocklist(servers[0].url, userToken1, 'user3@' + servers[1].host)
+      await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host })
     })
   })
 
@@ -167,7 +158,7 @@ describe('Test blocklist', function () {
     it('Should block an account', async function () {
       this.timeout(10000)
 
-      await addServerToAccountBlocklist(servers[0].url, userToken1, servers[1].host)
+      await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken1, server: servers[1].host })
       await waitJobs(servers)
     })
 
@@ -180,7 +171,7 @@ describe('Test blocklist', function () {
 
       await checkNotifications(servers[0].url, userToken2, notifs)
 
-      await removeServerFromAccountBlocklist(servers[0].url, userToken1, servers[1].host)
+      await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken1, server: servers[1].host })
     })
   })
 
@@ -207,7 +198,7 @@ describe('Test blocklist', function () {
     it('Should block an account', async function () {
       this.timeout(10000)
 
-      await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'user3@' + servers[1].host)
+      await servers[0].blocklistCommand.addToServerBlocklist({ account: 'user3@' + servers[1].host })
       await waitJobs(servers)
     })
 
@@ -215,7 +206,7 @@ describe('Test blocklist', function () {
       await checkNotifications(servers[0].url, userToken1, [])
       await checkNotifications(servers[0].url, userToken2, [])
 
-      await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, 'user3@' + servers[1].host)
+      await servers[0].blocklistCommand.removeFromServerBlocklist({ account: 'user3@' + servers[1].host })
     })
   })
 
@@ -242,7 +233,7 @@ describe('Test blocklist', function () {
     it('Should block an account', async function () {
       this.timeout(10000)
 
-      await addServerToServerBlocklist(servers[0].url, servers[0].accessToken, servers[1].host)
+      await servers[0].blocklistCommand.addToServerBlocklist({ server: servers[1].host })
       await waitJobs(servers)
     })