diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-09-04 21:21:47 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-09-04 21:30:18 +0200 |
commit | 0e1dc3e7c69995c691e1dd82e3c2bc68748661ca (patch) | |
tree | f2a4b5cffc72e33c902b67083bbaa35b6f22f0ca /server/tests/api/video-blacklist.ts | |
parent | b0f9f39ed70299a208d1b388c72de8b7f3510cb7 (diff) | |
download | PeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.tar.gz PeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.tar.zst PeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.zip |
Convert tests to typescript
Diffstat (limited to 'server/tests/api/video-blacklist.ts')
-rw-r--r-- | server/tests/api/video-blacklist.ts | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/server/tests/api/video-blacklist.ts b/server/tests/api/video-blacklist.ts new file mode 100644 index 000000000..e789611d0 --- /dev/null +++ b/server/tests/api/video-blacklist.ts | |||
@@ -0,0 +1,98 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import 'mocha' | ||
4 | import * as chai from 'chai' | ||
5 | const expect = chai.expect | ||
6 | |||
7 | import { | ||
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 | |||
21 | describe('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 | }) | ||