]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/follow-constraints.ts
Support video views/viewers stats in server
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / follow-constraints.ts
index 887e400e9b32a4a86ab9b62c3e45b92468aef05b..455fbc76298c12f9961c7b6b04583c3e82c35d7a 100644 (file)
@@ -2,22 +2,21 @@
 
 import 'mocha'
 import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
-import { cleanupTests, doubleFollow, flushAndRunMultipleServers, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils'
-import { PeerTubeProblemDocument, ServerErrorCode } from '@shared/models'
+import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
+import { HttpStatusCode, PeerTubeProblemDocument, ServerErrorCode } from '@shared/models'
 
 const expect = chai.expect
 
 describe('Test follow constraints', function () {
-  let servers: ServerInfo[] = []
+  let servers: PeerTubeServer[] = []
   let video1UUID: string
   let video2UUID: string
   let userToken: string
 
   before(async function () {
-    this.timeout(90000)
+    this.timeout(240000)
 
-    servers = await flushAndRunMultipleServers(2)
+    servers = await createMultipleServers(2)
 
     // Get the access tokens
     await setAccessTokensToServers(servers)
@@ -54,30 +53,30 @@ describe('Test follow constraints', function () {
       })
 
       it('Should list local account videos', async function () {
-        const { total, data } = await servers[0].videos.listByAccount({ accountName: 'root@localhost:' + servers[0].port })
+        const { total, data } = await servers[0].videos.listByAccount({ handle: 'root@localhost:' + servers[0].port })
 
         expect(total).to.equal(1)
         expect(data).to.have.lengthOf(1)
       })
 
       it('Should list remote account videos', async function () {
-        const { total, data } = await servers[0].videos.listByAccount({ accountName: 'root@localhost:' + servers[1].port })
+        const { total, data } = await servers[0].videos.listByAccount({ handle: 'root@localhost:' + servers[1].port })
 
         expect(total).to.equal(1)
         expect(data).to.have.lengthOf(1)
       })
 
       it('Should list local channel videos', async function () {
-        const videoChannelName = 'root_channel@localhost:' + servers[0].port
-        const { total, data } = await servers[0].videos.listByChannel({ videoChannelName })
+        const handle = 'root_channel@localhost:' + servers[0].port
+        const { total, data } = await servers[0].videos.listByChannel({ handle })
 
         expect(total).to.equal(1)
         expect(data).to.have.lengthOf(1)
       })
 
       it('Should list remote channel videos', async function () {
-        const videoChannelName = 'root_channel@localhost:' + servers[1].port
-        const { total, data } = await servers[0].videos.listByChannel({ videoChannelName })
+        const handle = 'root_channel@localhost:' + servers[1].port
+        const { total, data } = await servers[0].videos.listByChannel({ handle })
 
         expect(total).to.equal(1)
         expect(data).to.have.lengthOf(1)
@@ -94,30 +93,30 @@ describe('Test follow constraints', function () {
       })
 
       it('Should list local account videos', async function () {
-        const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port })
+        const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[0].port })
 
         expect(total).to.equal(1)
         expect(data).to.have.lengthOf(1)
       })
 
       it('Should list remote account videos', async function () {
-        const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port })
+        const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[1].port })
 
         expect(total).to.equal(1)
         expect(data).to.have.lengthOf(1)
       })
 
       it('Should list local channel videos', async function () {
-        const videoChannelName = 'root_channel@localhost:' + servers[0].port
-        const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
+        const handle = 'root_channel@localhost:' + servers[0].port
+        const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle })
 
         expect(total).to.equal(1)
         expect(data).to.have.lengthOf(1)
       })
 
       it('Should list remote channel videos', async function () {
-        const videoChannelName = 'root_channel@localhost:' + servers[1].port
-        const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
+        const handle = 'root_channel@localhost:' + servers[1].port
+        const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle })
 
         expect(total).to.equal(1)
         expect(data).to.have.lengthOf(1)
@@ -157,8 +156,8 @@ describe('Test follow constraints', function () {
 
       it('Should list local account videos', async function () {
         const { total, data } = await servers[0].videos.listByAccount({
-          token: undefined,
-          accountName: 'root@localhost:' + servers[0].port
+          token: null,
+          handle: 'root@localhost:' + servers[0].port
         })
 
         expect(total).to.equal(1)
@@ -167,8 +166,8 @@ describe('Test follow constraints', function () {
 
       it('Should not list remote account videos', async function () {
         const { total, data } = await servers[0].videos.listByAccount({
-          token: undefined,
-          accountName: 'root@localhost:' + servers[1].port
+          token: null,
+          handle: 'root@localhost:' + servers[1].port
         })
 
         expect(total).to.equal(0)
@@ -176,16 +175,16 @@ describe('Test follow constraints', function () {
       })
 
       it('Should list local channel videos', async function () {
-        const videoChannelName = 'root_channel@localhost:' + servers[0].port
-        const { total, data } = await servers[0].videos.listByChannel({ token: undefined, videoChannelName })
+        const handle = 'root_channel@localhost:' + servers[0].port
+        const { total, data } = await servers[0].videos.listByChannel({ token: null, handle })
 
         expect(total).to.equal(1)
         expect(data).to.have.lengthOf(1)
       })
 
       it('Should not list remote channel videos', async function () {
-        const videoChannelName = 'root_channel@localhost:' + servers[1].port
-        const { total, data } = await servers[0].videos.listByChannel({ token: undefined, videoChannelName })
+        const handle = 'root_channel@localhost:' + servers[1].port
+        const { total, data } = await servers[0].videos.listByChannel({ token: null, handle })
 
         expect(total).to.equal(0)
         expect(data).to.have.lengthOf(0)
@@ -202,30 +201,30 @@ describe('Test follow constraints', function () {
       })
 
       it('Should list local account videos', async function () {
-        const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port })
+        const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[0].port })
 
         expect(total).to.equal(1)
         expect(data).to.have.lengthOf(1)
       })
 
       it('Should list remote account videos', async function () {
-        const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port })
+        const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[1].port })
 
         expect(total).to.equal(1)
         expect(data).to.have.lengthOf(1)
       })
 
       it('Should list local channel videos', async function () {
-        const videoChannelName = 'root_channel@localhost:' + servers[0].port
-        const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
+        const handle = 'root_channel@localhost:' + servers[0].port
+        const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle })
 
         expect(total).to.equal(1)
         expect(data).to.have.lengthOf(1)
       })
 
       it('Should list remote channel videos', async function () {
-        const videoChannelName = 'root_channel@localhost:' + servers[1].port
-        const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
+        const handle = 'root_channel@localhost:' + servers[1].port
+        const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle })
 
         expect(total).to.equal(1)
         expect(data).to.have.lengthOf(1)