]>
Commit | Line | Data |
---|---|---|
0e1dc3e7 C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
0e1dc3e7 | 3 | import * as chai from 'chai' |
975e6e0e | 4 | import 'mocha' |
0e1dc3e7 | 5 | import { |
975e6e0e C |
6 | addVideoToBlacklist, |
7 | flushAndRunMultipleServers, | |
0e1dc3e7 | 8 | getVideosList, |
975e6e0e | 9 | killallServers, |
0e1dc3e7 | 10 | searchVideo, |
975e6e0e C |
11 | ServerInfo, |
12 | setAccessTokensToServers, | |
3cd0734f | 13 | uploadVideo |
c5d31dba C |
14 | } from '../../utils/index' |
15 | import { doubleFollow } from '../../utils/server/follows' | |
3cd0734f | 16 | import { waitJobs } from '../../utils/server/jobs' |
975e6e0e C |
17 | |
18 | const expect = chai.expect | |
0e1dc3e7 C |
19 | |
20 | describe('Test video blacklists', function () { | |
21 | let servers: ServerInfo[] = [] | |
22 | ||
23 | before(async function () { | |
572f8d3d | 24 | this.timeout(50000) |
0e1dc3e7 C |
25 | |
26 | // Run servers | |
27 | servers = await flushAndRunMultipleServers(2) | |
28 | ||
29 | // Get the access tokens | |
30 | await setAccessTokensToServers(servers) | |
31 | ||
975e6e0e C |
32 | // Server 1 and server 2 follow each other |
33 | await doubleFollow(servers[0], servers[1]) | |
0e1dc3e7 | 34 | |
975e6e0e | 35 | // Upload a video on server 2 |
0e1dc3e7 | 36 | const videoAttributes = { |
975e6e0e C |
37 | name: 'my super name for server 2', |
38 | description: 'my super description for server 2' | |
0e1dc3e7 C |
39 | } |
40 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) | |
41 | ||
572f8d3d | 42 | // Wait videos propagation, server 2 has transcoding enabled |
3cd0734f | 43 | await waitJobs(servers) |
0e1dc3e7 C |
44 | |
45 | const res = await getVideosList(servers[0].url) | |
46 | const videos = res.body.data | |
47 | ||
48 | expect(videos.length).to.equal(1) | |
49 | ||
975e6e0e | 50 | servers[0].remoteVideo = videos.find(video => video.name === 'my super name for server 2') |
0e1dc3e7 C |
51 | }) |
52 | ||
975e6e0e | 53 | it('Should blacklist a remote video on server 1', async function () { |
0e1dc3e7 C |
54 | await addVideoToBlacklist(servers[0].url, servers[0].accessToken, servers[0].remoteVideo.id) |
55 | }) | |
56 | ||
975e6e0e | 57 | it('Should not have the video blacklisted in videos list on server 1', async function () { |
0e1dc3e7 C |
58 | const res = await getVideosList(servers[0].url) |
59 | ||
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) | |
63 | }) | |
64 | ||
975e6e0e | 65 | it('Should not have the video blacklisted in videos search on server 1', async function () { |
0e1dc3e7 C |
66 | const res = await searchVideo(servers[0].url, 'name') |
67 | ||
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) | |
71 | }) | |
72 | ||
975e6e0e | 73 | it('Should have the blacklisted video in videos list on server 2', async function () { |
0e1dc3e7 C |
74 | const res = await getVideosList(servers[1].url) |
75 | ||
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) | |
79 | }) | |
80 | ||
975e6e0e | 81 | it('Should have the video blacklisted in videos search on server 2', async function () { |
0e1dc3e7 C |
82 | const res = await searchVideo(servers[1].url, 'name') |
83 | ||
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) | |
87 | }) | |
88 | ||
89 | after(async function () { | |
90 | killallServers(servers) | |
0e1dc3e7 C |
91 | }) |
92 | }) |