1 /* tslint:disable:no-unused-expression */
3 import * as chai from 'chai'
7 flushAndRunMultipleServers,
13 setAccessTokensToServers,
16 } from '../../utils/index'
17 import { doubleFollow } from '../../utils/server/follows'
19 const expect = chai.expect
21 describe('Test video blacklists', function () {
22 let servers: ServerInfo[] = []
24 before(async function () {
28 servers = await flushAndRunMultipleServers(2)
30 // Get the access tokens
31 await setAccessTokensToServers(servers)
33 // Server 1 and server 2 follow each other
34 await doubleFollow(servers[0], servers[1])
36 // Upload a video on server 2
37 const videoAttributes = {
38 name: 'my super name for server 2',
39 description: 'my super description for server 2'
41 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
43 // Wait videos propagation, server 2 has transcoding enabled
46 const res = await getVideosList(servers[0].url)
47 const videos = res.body.data
49 expect(videos.length).to.equal(1)
51 servers[0].remoteVideo = videos.find(video => video.name === 'my super name for server 2')
54 it('Should blacklist a remote video on server 1', async function () {
55 await addVideoToBlacklist(servers[0].url, servers[0].accessToken, servers[0].remoteVideo.id)
58 it('Should not have the video blacklisted in videos list on server 1', async function () {
59 const res = await getVideosList(servers[0].url)
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)
66 it('Should not have the video blacklisted in videos search on server 1', async function () {
67 const res = await searchVideo(servers[0].url, 'name')
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)
74 it('Should have the blacklisted video in videos list on server 2', async function () {
75 const res = await getVideosList(servers[1].url)
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)
82 it('Should have the video blacklisted in videos search on server 2', async function () {
83 const res = await searchVideo(servers[1].url, 'name')
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)
90 after(async function () {
91 killallServers(servers)
93 // Keep the logs if the test failed