]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/videos-filter.ts
Add ability to update the banner
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / videos-filter.ts
index e1e65260fe1868198f795a9f9dcc419e65b9b645..2961c8e788120030c0611ac3eaafacf167a693b6 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',
@@ -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 () {