]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/follow-constraints.ts
Merge branch 'release/2.1.0' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / follow-constraints.ts
index cf40018b38b4bc06f21295d01e66d4038e14f08f..a73440286560505063abc97a5cef58e72aec3c62 100644 (file)
@@ -1,15 +1,15 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import * as chai from 'chai'
 import 'mocha'
 import {
+  cleanupTests,
   doubleFollow,
+  flushAndRunMultipleServers,
   getAccountVideos,
   getVideo,
   getVideoChannelVideos,
   getVideoWithToken,
-  flushAndRunMultipleServers,
-  killallServers,
   ServerInfo,
   setAccessTokensToServers,
   uploadVideo
@@ -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)
 
@@ -35,11 +35,11 @@ describe('Test follow constraints', function () {
     await setAccessTokensToServers(servers)
 
     {
-      const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video server 1' })
+      const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video server 1' })
       video1UUID = res.body.video.uuid
     }
     {
-      const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video server 2' })
+      const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video server 2' })
       video2UUID = res.body.video.uuid
     }
 
@@ -47,7 +47,7 @@ describe('Test follow constraints', function () {
       username: 'user1',
       password: 'super_password'
     }
-    await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: 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)
@@ -219,7 +227,7 @@ describe('Test follow constraints', function () {
     })
   })
 
-  after(function () {
-    killallServers(servers)
+  after(async function () {
+    await cleanupTests(servers)
   })
 })