]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/follow-constraints.ts
Fix misc tests
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / follow-constraints.ts
index 8bb073c413061b0d6826dd02d0eff3764652b896..46663bf7cb6e844bbf3ea3070e4a7da6de78a690 100644 (file)
@@ -3,20 +3,20 @@
 import * as chai from 'chai'
 import 'mocha'
 import {
+  cleanupTests,
   doubleFollow,
+  flushAndRunMultipleServers,
   getAccountVideos,
   getVideo,
   getVideoChannelVideos,
   getVideoWithToken,
-  flushAndRunMultipleServers,
-  killallServers,
   ServerInfo,
   setAccessTokensToServers,
   uploadVideo
-} from '../../../../shared/utils'
-import { unfollow } from '../../../../shared/utils/server/follows'
-import { userLogin } from '../../../../shared/utils/users/login'
-import { createUser } from '../../../../shared/utils/users/users'
+} from '../../../../shared/extra-utils'
+import { unfollow } from '../../../../shared/extra-utils/server/follows'
+import { userLogin } from '../../../../shared/extra-utils/users/login'
+import { createUser } from '../../../../shared/extra-utils/users/users'
 
 const expect = chai.expect
 
@@ -27,7 +27,7 @@ describe('Test follow constraints', function () {
   let userAccessToken: string
 
   before(async function () {
-    this.timeout(30000)
+    this.timeout(60000)
 
     servers = await flushAndRunMultipleServers(2)
 
@@ -47,7 +47,7 @@ describe('Test follow constraints', function () {
       username: 'user1',
       password: 'super_password'
     }
-    await createUser(servers[0].url, servers[0].accessToken, user.username, user.password)
+    await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
     userAccessToken = await userLogin(servers[0], user)
 
     await doubleFollow(servers[0], servers[1])
@@ -66,28 +66,30 @@ describe('Test follow constraints', function () {
       })
 
       it('Should list local account videos', async function () {
-        const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9001', 0, 5)
+        const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:' + servers[0].port, 0, 5)
 
         expect(res.body.total).to.equal(1)
         expect(res.body.data).to.have.lengthOf(1)
       })
 
       it('Should list remote account videos', async function () {
-        const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9002', 0, 5)
+        const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:' + servers[1].port, 0, 5)
 
         expect(res.body.total).to.equal(1)
         expect(res.body.data).to.have.lengthOf(1)
       })
 
       it('Should list local channel videos', async function () {
-        const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9001', 0, 5)
+        const videoChannelName = 'root_channel@localhost:' + servers[0].port
+        const res = await getVideoChannelVideos(servers[0].url, undefined, videoChannelName, 0, 5)
 
         expect(res.body.total).to.equal(1)
         expect(res.body.data).to.have.lengthOf(1)
       })
 
       it('Should list remote channel videos', async function () {
-        const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9002', 0, 5)
+        const videoChannelName = 'root_channel@localhost:' + servers[1].port
+        const res = await getVideoChannelVideos(servers[0].url, undefined, videoChannelName, 0, 5)
 
         expect(res.body.total).to.equal(1)
         expect(res.body.data).to.have.lengthOf(1)
@@ -104,28 +106,30 @@ describe('Test follow constraints', function () {
       })
 
       it('Should list local account videos', async function () {
-        const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9001', 0, 5)
+        const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:' + servers[0].port, 0, 5)
 
         expect(res.body.total).to.equal(1)
         expect(res.body.data).to.have.lengthOf(1)
       })
 
       it('Should list remote account videos', async function () {
-        const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9002', 0, 5)
+        const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:' + servers[1].port, 0, 5)
 
         expect(res.body.total).to.equal(1)
         expect(res.body.data).to.have.lengthOf(1)
       })
 
       it('Should list local channel videos', async function () {
-        const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9001', 0, 5)
+        const videoChannelName = 'root_channel@localhost:' + servers[0].port
+        const res = await getVideoChannelVideos(servers[0].url, userAccessToken, videoChannelName, 0, 5)
 
         expect(res.body.total).to.equal(1)
         expect(res.body.data).to.have.lengthOf(1)
       })
 
       it('Should list remote channel videos', async function () {
-        const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9002', 0, 5)
+        const videoChannelName = 'root_channel@localhost:' + servers[1].port
+        const res = await getVideoChannelVideos(servers[0].url, userAccessToken, videoChannelName, 0, 5)
 
         expect(res.body.total).to.equal(1)
         expect(res.body.data).to.have.lengthOf(1)
@@ -152,28 +156,30 @@ describe('Test follow constraints', function () {
       })
 
       it('Should list local account videos', async function () {
-        const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9001', 0, 5)
+        const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:' + servers[0].port, 0, 5)
 
         expect(res.body.total).to.equal(1)
         expect(res.body.data).to.have.lengthOf(1)
       })
 
       it('Should not list remote account videos', async function () {
-        const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9002', 0, 5)
+        const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:' + servers[1].port, 0, 5)
 
         expect(res.body.total).to.equal(0)
         expect(res.body.data).to.have.lengthOf(0)
       })
 
       it('Should list local channel videos', async function () {
-        const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9001', 0, 5)
+        const videoChannelName = 'root_channel@localhost:' + servers[0].port
+        const res = await getVideoChannelVideos(servers[0].url, undefined, videoChannelName, 0, 5)
 
         expect(res.body.total).to.equal(1)
         expect(res.body.data).to.have.lengthOf(1)
       })
 
       it('Should not list remote channel videos', async function () {
-        const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9002', 0, 5)
+        const videoChannelName = 'root_channel@localhost:' + servers[1].port
+        const res = await getVideoChannelVideos(servers[0].url, undefined, videoChannelName, 0, 5)
 
         expect(res.body.total).to.equal(0)
         expect(res.body.data).to.have.lengthOf(0)
@@ -190,28 +196,30 @@ describe('Test follow constraints', function () {
       })
 
       it('Should list local account videos', async function () {
-        const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9001', 0, 5)
+        const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:' + servers[0].port, 0, 5)
 
         expect(res.body.total).to.equal(1)
         expect(res.body.data).to.have.lengthOf(1)
       })
 
       it('Should list remote account videos', async function () {
-        const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9002', 0, 5)
+        const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:' + servers[1].port, 0, 5)
 
         expect(res.body.total).to.equal(1)
         expect(res.body.data).to.have.lengthOf(1)
       })
 
       it('Should list local channel videos', async function () {
-        const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9001', 0, 5)
+        const videoChannelName = 'root_channel@localhost:' + servers[0].port
+        const res = await getVideoChannelVideos(servers[0].url, userAccessToken, videoChannelName, 0, 5)
 
         expect(res.body.total).to.equal(1)
         expect(res.body.data).to.have.lengthOf(1)
       })
 
       it('Should list remote channel videos', async function () {
-        const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9002', 0, 5)
+        const videoChannelName = 'root_channel@localhost:' + servers[1].port
+        const res = await getVideoChannelVideos(servers[0].url, userAccessToken, videoChannelName, 0, 5)
 
         expect(res.body.total).to.equal(1)
         expect(res.body.data).to.have.lengthOf(1)
@@ -220,6 +228,6 @@ describe('Test follow constraints', function () {
   })
 
   after(async function () {
-    killallServers(servers)
+    await cleanupTests(servers)
   })
 })