1 /* tslint:disable:no-unused-expression */
3 import * as chai from 'chai'
7 flushAndRunMultipleServers,
12 setAccessTokensToServers,
14 } from '../../utils/index'
15 import { doubleFollow } from '../../utils/server/follows'
16 import { waitJobs } from '../../utils/server/jobs'
18 const expect = chai.expect
20 describe('Test video blacklists', function () {
21 let servers: ServerInfo[] = []
23 before(async function () {
27 servers = await flushAndRunMultipleServers(2)
29 // Get the access tokens
30 await setAccessTokensToServers(servers)
32 // Server 1 and server 2 follow each other
33 await doubleFollow(servers[0], servers[1])
35 // Upload a video on server 2
36 const videoAttributes = {
37 name: 'my super name for server 2',
38 description: 'my super description for server 2'
40 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
42 // Wait videos propagation, server 2 has transcoding enabled
43 await waitJobs(servers)
45 const res = await getVideosList(servers[0].url)
46 const videos = res.body.data
48 expect(videos.length).to.equal(1)
50 servers[0].remoteVideo = videos.find(video => video.name === 'my super name for server 2')
53 it('Should blacklist a remote video on server 1', async function () {
54 await addVideoToBlacklist(servers[0].url, servers[0].accessToken, servers[0].remoteVideo.id)
57 it('Should not have the video blacklisted in videos list on server 1', async function () {
58 const res = await getVideosList(servers[0].url)
60 expect(res.body.total).to.equal(0)
61 expect(res.body.data).to.be.an('array')
62 expect(res.body.data.length).to.equal(0)
65 it('Should not have the video blacklisted in videos search on server 1', async function () {
66 const res = await searchVideo(servers[0].url, 'name')
68 expect(res.body.total).to.equal(0)
69 expect(res.body.data).to.be.an('array')
70 expect(res.body.data.length).to.equal(0)
73 it('Should have the blacklisted video in videos list on server 2', async function () {
74 const res = await getVideosList(servers[1].url)
76 expect(res.body.total).to.equal(1)
77 expect(res.body.data).to.be.an('array')
78 expect(res.body.data.length).to.equal(1)
81 it('Should have the video blacklisted in videos search on server 2', async function () {
82 const res = await searchVideo(servers[1].url, 'name')
84 expect(res.body.total).to.equal(1)
85 expect(res.body.data).to.be.an('array')
86 expect(res.body.data.length).to.equal(1)
89 after(async function () {
90 killallServers(servers)