1 /* tslint:disable:no-unused-expression */
3 import * as chai from 'chai'
6 flushAndRunMultipleServers, flushTests, getVideo, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo,
10 const expect = chai.expect
12 describe('Test video transcoding', function () {
13 let servers: ServerInfo[] = []
15 before(async function () {
19 servers = await flushAndRunMultipleServers(2)
21 await setAccessTokensToServers(servers)
24 it('Should not transcode video on server 1', async function () {
27 const videoAttributes = {
28 name: 'my super name for server 1',
29 description: 'my super description for server 1',
30 fixture: 'video_short.webm'
32 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
36 const res = await getVideosList(servers[0].url)
37 const video = res.body.data[0]
39 const res2 = await getVideo(servers[0].url, video.id)
40 const videoDetails = res2.body
41 expect(videoDetails.files).to.have.lengthOf(1)
43 const magnetUri = videoDetails.files[0].magnetUri
44 expect(magnetUri).to.match(/\.webm/)
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$/)
52 it('Should transcode video on server 2', async function () {
55 const videoAttributes = {
56 name: 'my super name for server 2',
57 description: 'my super description for server 2',
58 fixture: 'video_short.webm'
60 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
64 const res = await getVideosList(servers[1].url)
66 const video = res.body.data[0]
67 const res2 = await getVideo(servers[1].url, video.id)
68 const videoDetails = res2.body
70 expect(videoDetails.files).to.have.lengthOf(4)
72 const magnetUri = videoDetails.files[0].magnetUri
73 expect(magnetUri).to.match(/\.mp4/)
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$/)
81 after(async function () {
82 killallServers(servers)
84 // Keep the logs if the test failed