]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/videos/video-blacklist.ts
nginx optimizations
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-blacklist.ts
CommitLineData
0e1dc3e7
C
1/* tslint:disable:no-unused-expression */
2
0e1dc3e7 3import * as chai from 'chai'
975e6e0e 4import 'mocha'
0e1dc3e7 5import {
975e6e0e
C
6 addVideoToBlacklist,
7 flushAndRunMultipleServers,
0e1dc3e7 8 flushTests,
0e1dc3e7 9 getVideosList,
975e6e0e 10 killallServers,
0e1dc3e7 11 searchVideo,
975e6e0e
C
12 ServerInfo,
13 setAccessTokensToServers,
14 uploadVideo,
15 wait
c5d31dba
C
16} from '../../utils/index'
17import { doubleFollow } from '../../utils/server/follows'
975e6e0e
C
18
19const expect = chai.expect
0e1dc3e7
C
20
21describe('Test video blacklists', function () {
22 let servers: ServerInfo[] = []
23
24 before(async function () {
572f8d3d 25 this.timeout(50000)
0e1dc3e7
C
26
27 // Run servers
28 servers = await flushAndRunMultipleServers(2)
29
30 // Get the access tokens
31 await setAccessTokensToServers(servers)
32
975e6e0e
C
33 // Server 1 and server 2 follow each other
34 await doubleFollow(servers[0], servers[1])
0e1dc3e7 35
975e6e0e 36 // Upload a video on server 2
0e1dc3e7 37 const videoAttributes = {
975e6e0e
C
38 name: 'my super name for server 2',
39 description: 'my super description for server 2'
0e1dc3e7
C
40 }
41 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
42
572f8d3d
C
43 // Wait videos propagation, server 2 has transcoding enabled
44 await wait(10000)
0e1dc3e7
C
45
46 const res = await getVideosList(servers[0].url)
47 const videos = res.body.data
48
49 expect(videos.length).to.equal(1)
50
975e6e0e 51 servers[0].remoteVideo = videos.find(video => video.name === 'my super name for server 2')
0e1dc3e7
C
52 })
53
975e6e0e 54 it('Should blacklist a remote video on server 1', async function () {
0e1dc3e7
C
55 await addVideoToBlacklist(servers[0].url, servers[0].accessToken, servers[0].remoteVideo.id)
56 })
57
975e6e0e 58 it('Should not have the video blacklisted in videos list on server 1', async function () {
0e1dc3e7
C
59 const res = await getVideosList(servers[0].url)
60
61 expect(res.body.total).to.equal(0)
62 expect(res.body.data).to.be.an('array')
63 expect(res.body.data.length).to.equal(0)
64 })
65
975e6e0e 66 it('Should not have the video blacklisted in videos search on server 1', async function () {
0e1dc3e7
C
67 const res = await searchVideo(servers[0].url, 'name')
68
69 expect(res.body.total).to.equal(0)
70 expect(res.body.data).to.be.an('array')
71 expect(res.body.data.length).to.equal(0)
72 })
73
975e6e0e 74 it('Should have the blacklisted video in videos list on server 2', async function () {
0e1dc3e7
C
75 const res = await getVideosList(servers[1].url)
76
77 expect(res.body.total).to.equal(1)
78 expect(res.body.data).to.be.an('array')
79 expect(res.body.data.length).to.equal(1)
80 })
81
975e6e0e 82 it('Should have the video blacklisted in videos search on server 2', async function () {
0e1dc3e7
C
83 const res = await searchVideo(servers[1].url, 'name')
84
85 expect(res.body.total).to.equal(1)
86 expect(res.body.data).to.be.an('array')
87 expect(res.body.data.length).to.equal(1)
88 })
89
90 after(async function () {
91 killallServers(servers)
92
93 // Keep the logs if the test failed
94 if (this['ok']) {
95 await flushTests()
96 }
97 })
98})