]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/video-blacklist.ts
Add channels to upload form
[github/Chocobozzz/PeerTube.git] / server / tests / api / video-blacklist.ts
CommitLineData
0e1dc3e7
C
1/* tslint:disable:no-unused-expression */
2
3import 'mocha'
4import * as chai from 'chai'
5const expect = chai.expect
6
7import {
8 ServerInfo,
9 flushTests,
10 uploadVideo,
11 makeFriends,
12 getVideosList,
13 wait,
14 setAccessTokensToServers,
15 flushAndRunMultipleServers,
16 addVideoToBlacklist,
17 searchVideo,
18 killallServers
19} from '../utils'
20
21describe('Test video blacklists', function () {
22 let servers: ServerInfo[] = []
23
24 before(async function () {
25 this.timeout(120000)
26
27 // Run servers
28 servers = await flushAndRunMultipleServers(2)
29
30 // Get the access tokens
31 await setAccessTokensToServers(servers)
32
33 // Pod 1 makes friend with pod 2
34 await makeFriends(servers[0].url, servers[0].accessToken)
35
36 // Upload a video on pod 2
37 const videoAttributes = {
38 name: 'my super name for pod 2',
39 description: 'my super description for pod 2'
40 }
41 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
42
43 // Wait videos propagation
44 await wait(22000)
45
46 const res = await getVideosList(servers[0].url)
47 const videos = res.body.data
48
49 expect(videos.length).to.equal(1)
50
51 servers[0].remoteVideo = videos.find(video => video.name === 'my super name for pod 2')
52 })
53
54 it('Should blacklist a remote video on pod 1', async function () {
55 await addVideoToBlacklist(servers[0].url, servers[0].accessToken, servers[0].remoteVideo.id)
56 })
57
58 it('Should not have the video blacklisted in videos list on pod 1', async function () {
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
66 it('Should not have the video blacklisted in videos search on pod 1', async function () {
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
74 it('Should have the blacklisted video in videos list on pod 2', async function () {
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
82 it('Should have the video blacklisted in videos search on pod 2', async function () {
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})