]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/notifications/moderation-notifications.ts
Introduce config command
[github/Chocobozzz/PeerTube.git] / server / tests / api / notifications / moderation-notifications.ts
index c4f63200a41097ca489271fd600719a832943149..3e66e7517e4243c8bdf25e9f25fb9bf7ad007c36 100644 (file)
@@ -21,10 +21,8 @@ import {
   checkVideoIsPublished,
   cleanupTests,
   createUser,
-  follow,
   generateUserAccessToken,
   getAccount,
-  getCustomConfig,
   getVideoCommentThreads,
   getVideoIdFromUUID,
   immutableAssign,
@@ -35,9 +33,6 @@ import {
   removeUserSubscription,
   removeVideoFromBlacklist,
   ServerInfo,
-  unfollow,
-  updateCustomConfig,
-  updateCustomSubConfig,
   uploadVideo,
   wait,
   waitJobs
@@ -386,7 +381,7 @@ describe('Test moderation notifications', function () {
     it('Should send a notification only to admin when there is a new instance follower', async function () {
       this.timeout(20000)
 
-      await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken)
+      await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
 
       await waitJobs(servers)
 
@@ -399,7 +394,7 @@ describe('Test moderation notifications', function () {
     it('Should send a notification on auto follow back', async function () {
       this.timeout(40000)
 
-      await unfollow(servers[2].url, servers[2].accessToken, servers[0])
+      await servers[2].followsCommand.unfollow({ target: servers[0] })
       await waitJobs(servers)
 
       const config = {
@@ -409,9 +404,9 @@ describe('Test moderation notifications', function () {
           }
         }
       }
-      await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
+      await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
 
-      await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken)
+      await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
 
       await waitJobs(servers)
 
@@ -423,16 +418,16 @@ describe('Test moderation notifications', function () {
       await checkAutoInstanceFollowing(immutableAssign(baseParams, userOverride), followerHost, followingHost, 'absence')
 
       config.followings.instance.autoFollowBack.enabled = false
-      await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
-      await unfollow(servers[0].url, servers[0].accessToken, servers[2])
-      await unfollow(servers[2].url, servers[2].accessToken, servers[0])
+      await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+      await servers[0].followsCommand.unfollow({ target: servers[2] })
+      await servers[2].followsCommand.unfollow({ target: servers[0] })
     })
 
     it('Should send a notification on auto instances index follow', async function () {
       this.timeout(30000)
-      await unfollow(servers[0].url, servers[0].accessToken, servers[1])
+      await servers[0].followsCommand.unfollow({ target: servers[1] })
 
-      await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
+      await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
 
       await wait(5000)
       await waitJobs(servers)
@@ -442,8 +437,8 @@ describe('Test moderation notifications', function () {
       await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence')
 
       config.followings.instance.autoFollowIndex.enabled = false
-      await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
-      await unfollow(servers[0].url, servers[0].accessToken, servers[1])
+      await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+      await servers[0].followsCommand.unfollow({ target: servers[1] })
     })
   })
 
@@ -478,8 +473,8 @@ describe('Test moderation notifications', function () {
         token: userAccessToken
       }
 
-      const resCustomConfig = await getCustomConfig(servers[0].url, servers[0].accessToken)
-      currentCustomConfig = resCustomConfig.body
+      currentCustomConfig = await servers[0].configCommand.getCustomConfig()
+
       const autoBlacklistTestsCustomConfig = immutableAssign(currentCustomConfig, {
         autoBlacklist: {
           videos: {
@@ -489,9 +484,10 @@ describe('Test moderation notifications', function () {
           }
         }
       })
+
       // enable transcoding otherwise own publish notification after transcoding not expected
       autoBlacklistTestsCustomConfig.transcoding.enabled = true
-      await updateCustomConfig(servers[0].url, servers[0].accessToken, autoBlacklistTestsCustomConfig)
+      await servers[0].configCommand.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig })
 
       await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port)
       await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)
@@ -614,7 +610,7 @@ describe('Test moderation notifications', function () {
     })
 
     after(async () => {
-      await updateCustomConfig(servers[0].url, servers[0].accessToken, currentCustomConfig)
+      await servers[0].configCommand.updateCustomConfig({ newCustomConfig: currentCustomConfig })
 
       await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port)
       await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)