]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/follows.ts
Fix reverse proxy test
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / follows.ts
index a19b47509792d6fb359c0f3be3b6b816e28d44e2..b0fc5d2939e7d7773db31799d5fd7b87ab80e1bf 100644 (file)
@@ -4,7 +4,7 @@ import * as chai from 'chai'
 import 'mocha'
 import { Video, VideoPrivacy } from '../../../../shared/models/videos'
 import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
-import { completeVideoCheck } from '../../utils'
+import { completeVideoCheck } from '../../../../shared/utils'
 import {
   flushAndRunMultipleServers,
   getVideosList,
@@ -12,22 +12,27 @@ import {
   ServerInfo,
   setAccessTokensToServers,
   uploadVideo
-} from '../../utils/index'
-import { dateIsValid } from '../../utils/miscs/miscs'
-import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../../utils/server/follows'
-import { expectAccountFollows } from '../../utils/users/accounts'
-import { userLogin } from '../../utils/users/login'
-import { createUser } from '../../utils/users/users'
+} from '../../../../shared/utils/index'
+import { dateIsValid } from '../../../../shared/utils/miscs/miscs'
+import {
+  follow,
+  getFollowersListPaginationAndSort,
+  getFollowingListPaginationAndSort,
+  unfollow
+} from '../../../../shared/utils/server/follows'
+import { expectAccountFollows } from '../../../../shared/utils/users/accounts'
+import { userLogin } from '../../../../shared/utils/users/login'
+import { createUser } from '../../../../shared/utils/users/users'
 import {
   addVideoCommentReply,
   addVideoCommentThread,
   getVideoCommentThreads,
   getVideoThreadComments
-} from '../../utils/videos/video-comments'
-import { rateVideo } from '../../utils/videos/videos'
-import { waitJobs } from '../../utils/server/jobs'
-import { createVideoCaption, listVideoCaptions, testCaptionFile } from '../../utils/videos/video-captions'
-import { VideoCaption } from '../../../../shared/models/videos/video-caption.model'
+} from '../../../../shared/utils/videos/video-comments'
+import { rateVideo } from '../../../../shared/utils/videos/videos'
+import { waitJobs } from '../../../../shared/utils/server/jobs'
+import { createVideoCaption, listVideoCaptions, testCaptionFile } from '../../../../shared/utils/videos/video-captions'
+import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model'
 
 const expect = chai.expect
 
@@ -66,7 +71,7 @@ describe('Test follows', function () {
   })
 
   it('Should have server 1 following server 2 and 3', async function () {
-    this.timeout(10000)
+    this.timeout(30000)
 
     await follow(servers[0].url, [ servers[1].url, servers[2].url ], servers[0].accessToken)
 
@@ -93,7 +98,26 @@ describe('Test follows', function () {
     expect(server3Follow.state).to.equal('accepted')
   })
 
-  it('Should have 0 followings on server 1 and 2', async function () {
+  it('Should search followings on server 1', async function () {
+    {
+      const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 1, 'createdAt', ':9002')
+      const follows = res.body.data
+
+      expect(res.body.total).to.equal(1)
+      expect(follows.length).to.equal(1)
+      expect(follows[ 0 ].following.host).to.equal('localhost:9002')
+    }
+
+    {
+      const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 1, 'createdAt', 'bla')
+      const follows = res.body.data
+
+      expect(res.body.total).to.equal(0)
+      expect(follows.length).to.equal(0)
+    }
+  })
+
+  it('Should have 0 followings on server 2 and 3', async function () {
     for (const server of [ servers[1], servers[2] ]) {
       const res = await getFollowingListPaginationAndSort(server.url, 0, 5, 'createdAt')
       const follows = res.body.data
@@ -116,6 +140,25 @@ describe('Test follows', function () {
     }
   })
 
+  it('Should search followers on server 2', async function () {
+    {
+      const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', '9001')
+      const follows = res.body.data
+
+      expect(res.body.total).to.equal(1)
+      expect(follows.length).to.equal(1)
+      expect(follows[ 0 ].following.host).to.equal('localhost:9003')
+    }
+
+    {
+      const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', 'bla')
+      const follows = res.body.data
+
+      expect(res.body.total).to.equal(0)
+      expect(follows.length).to.equal(0)
+    }
+  })
+
   it('Should have 0 followers on server 1', async function () {
     const res = await getFollowersListPaginationAndSort(servers[0].url, 0, 5, 'createdAt')
     const follows = res.body.data
@@ -178,7 +221,7 @@ describe('Test follows', function () {
   })
 
   it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () {
-    this.timeout(10000)
+    this.timeout(35000)
 
     await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'server2' })
     await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3' })
@@ -311,7 +354,8 @@ describe('Test follows', function () {
         likes: 1,
         dislikes: 1,
         channel: {
-          name: 'Default root channel',
+          displayName: 'Main root channel',
+          name: 'root_channel',
           description: '',
           isLocal
         },