]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/videos-filter.ts
Introduce blacklist command
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / videos-filter.ts
index e1e65260fe1868198f795a9f9dcc419e65b9b645..7428b82c57cc99e8e758026bff7b8d1100ba6ebd 100644 (file)
@@ -1,4 +1,4 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import * as chai from 'chai'
 import 'mocha'
@@ -7,8 +7,6 @@ import {
   createUser,
   doubleFollow,
   flushAndRunMultipleServers,
-  flushTests,
-  killallServers,
   makeGetRequest,
   ServerInfo,
   setAccessTokensToServers,
@@ -17,10 +15,11 @@ import {
 } from '../../../../shared/extra-utils'
 import { Video, VideoPrivacy } from '../../../../shared/models/videos'
 import { UserRole } from '../../../../shared/models/users'
+import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
 
 const expect = chai.expect
 
-async function getVideosNames (server: ServerInfo, token: string, filter: string, statusCodeExpected = 200) {
+async function getVideosNames (server: ServerInfo, token: string, filter: string, statusCodeExpected = HttpStatusCode.OK_200) {
   const paths = [
     '/api/v1/video-channels/root_channel/videos',
     '/api/v1/accounts/root/videos',
@@ -48,13 +47,13 @@ async function getVideosNames (server: ServerInfo, token: string, filter: string
   return videosResults
 }
 
-describe('Test videos filter validator', function () {
+describe('Test videos filter', function () {
   let servers: ServerInfo[]
 
   // ---------------------------------------------------------------
 
   before(async function () {
-    this.timeout(120000)
+    this.timeout(160000)
 
     servers = await flushAndRunMultipleServers(2)
 
@@ -98,7 +97,7 @@ describe('Test videos filter validator', function () {
         const namesResults = await getVideosNames(server, server.accessToken, 'local')
         for (const names of namesResults) {
           expect(names).to.have.lengthOf(1)
-          expect(names[ 0 ]).to.equal('public ' + server.serverNumber)
+          expect(names[0]).to.equal('public ' + server.serverNumber)
         }
       }
     })
@@ -111,13 +110,27 @@ describe('Test videos filter validator', function () {
           for (const names of namesResults) {
             expect(names).to.have.lengthOf(3)
 
-            expect(names[ 0 ]).to.equal('public ' + server.serverNumber)
-            expect(names[ 1 ]).to.equal('unlisted ' + server.serverNumber)
-            expect(names[ 2 ]).to.equal('private ' + server.serverNumber)
+            expect(names[0]).to.equal('public ' + server.serverNumber)
+            expect(names[1]).to.equal('unlisted ' + server.serverNumber)
+            expect(names[2]).to.equal('private ' + server.serverNumber)
           }
         }
       }
     })
+
+    it('Should display all videos by the admin or the moderator', async function () {
+      for (const server of servers) {
+        for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) {
+
+          const [ channelVideos, accountVideos, videos, searchVideos ] = await getVideosNames(server, token, 'all')
+          expect(channelVideos).to.have.lengthOf(3)
+          expect(accountVideos).to.have.lengthOf(3)
+
+          expect(videos).to.have.lengthOf(5)
+          expect(searchVideos).to.have.lengthOf(5)
+        }
+      }
+    })
   })
 
   after(async function () {