aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-blacklist.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/video-blacklist.ts')
-rw-r--r--server/tests/api/videos/video-blacklist.ts98
1 files changed, 98 insertions, 0 deletions
diff --git a/server/tests/api/videos/video-blacklist.ts b/server/tests/api/videos/video-blacklist.ts
new file mode 100644
index 000000000..d1cefa5d7
--- /dev/null
+++ b/server/tests/api/videos/video-blacklist.ts
@@ -0,0 +1,98 @@
1/* tslint:disable:no-unused-expression */
2
3import * as chai from 'chai'
4import 'mocha'
5import {
6 addVideoToBlacklist,
7 flushAndRunMultipleServers,
8 flushTests,
9 getVideosList,
10 killallServers,
11 searchVideo,
12 ServerInfo,
13 setAccessTokensToServers,
14 uploadVideo,
15 wait
16} from '../../utils/index'
17import { doubleFollow } from '../../utils/server/follows'
18
19const expect = chai.expect
20
21describe('Test video blacklists', function () {
22 let servers: ServerInfo[] = []
23
24 before(async function () {
25 this.timeout(50000)
26
27 // Run servers
28 servers = await flushAndRunMultipleServers(2)
29
30 // Get the access tokens
31 await setAccessTokensToServers(servers)
32
33 // Server 1 and server 2 follow each other
34 await doubleFollow(servers[0], servers[1])
35
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'
40 }
41 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
42
43 // Wait videos propagation, server 2 has transcoding enabled
44 await wait(10000)
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 server 2')
52 })
53
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)
56 })
57
58 it('Should not have the video blacklisted in videos list on server 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 server 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 server 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 server 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})