]>
Commit | Line | Data |
---|---|---|
0e1dc3e7 C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
0e1dc3e7 | 3 | import * as chai from 'chai' |
a7ba16b6 | 4 | import 'mocha' |
0e1dc3e7 | 5 | import { |
a7ba16b6 C |
6 | flushAndRunMultipleServers, flushTests, getVideo, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo, |
7 | wait, webtorrentAdd | |
8 | } from '../../utils' | |
9 | ||
10 | const expect = chai.expect | |
0e1dc3e7 C |
11 | |
12 | describe('Test video transcoding', function () { | |
13 | let servers: ServerInfo[] = [] | |
14 | ||
15 | before(async function () { | |
572f8d3d | 16 | this.timeout(10000) |
0e1dc3e7 C |
17 | |
18 | // Run servers | |
19 | servers = await flushAndRunMultipleServers(2) | |
20 | ||
21 | await setAccessTokensToServers(servers) | |
22 | }) | |
23 | ||
24 | it('Should not transcode video on server 1', async function () { | |
25 | this.timeout(60000) | |
26 | ||
27 | const videoAttributes = { | |
975e6e0e C |
28 | name: 'my super name for server 1', |
29 | description: 'my super description for server 1', | |
0e1dc3e7 C |
30 | fixture: 'video_short.webm' |
31 | } | |
32 | await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) | |
33 | ||
572f8d3d | 34 | await wait(10000) |
0e1dc3e7 C |
35 | |
36 | const res = await getVideosList(servers[0].url) | |
37 | const video = res.body.data[0] | |
40298b02 | 38 | |
5f04dd2f C |
39 | const res2 = await getVideo(servers[0].url, video.id) |
40 | const videoDetails = res2.body | |
41 | expect(videoDetails.files).to.have.lengthOf(1) | |
42 | ||
43 | const magnetUri = videoDetails.files[0].magnetUri | |
0e1dc3e7 C |
44 | expect(magnetUri).to.match(/\.webm/) |
45 | ||
46 | const torrent = await webtorrentAdd(magnetUri) | |
47 | expect(torrent.files).to.be.an('array') | |
48 | expect(torrent.files.length).to.equal(1) | |
49 | expect(torrent.files[0].path).match(/\.webm$/) | |
50 | }) | |
51 | ||
52 | it('Should transcode video on server 2', async function () { | |
53 | this.timeout(60000) | |
54 | ||
55 | const videoAttributes = { | |
975e6e0e C |
56 | name: 'my super name for server 2', |
57 | description: 'my super description for server 2', | |
0e1dc3e7 C |
58 | fixture: 'video_short.webm' |
59 | } | |
60 | await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) | |
61 | ||
5e3bb76c | 62 | await wait(20000) |
0e1dc3e7 C |
63 | |
64 | const res = await getVideosList(servers[1].url) | |
65 | ||
66 | const video = res.body.data[0] | |
5f04dd2f C |
67 | const res2 = await getVideo(servers[1].url, video.id) |
68 | const videoDetails = res2.body | |
69 | ||
70 | expect(videoDetails.files).to.have.lengthOf(4) | |
40298b02 | 71 | |
5f04dd2f | 72 | const magnetUri = videoDetails.files[0].magnetUri |
0e1dc3e7 C |
73 | expect(magnetUri).to.match(/\.mp4/) |
74 | ||
75 | const torrent = await webtorrentAdd(magnetUri) | |
76 | expect(torrent.files).to.be.an('array') | |
77 | expect(torrent.files.length).to.equal(1) | |
78 | expect(torrent.files[0].path).match(/\.mp4$/) | |
79 | }) | |
80 | ||
81 | after(async function () { | |
82 | killallServers(servers) | |
83 | ||
84 | // Keep the logs if the test failed | |
85 | if (this['ok']) { | |
86 | await flushTests() | |
87 | } | |
88 | }) | |
89 | }) |