1 /* tslint:disable:no-unused-expression */
4 import * as chai from 'chai'
5 const expect = chai.expect
13 setAccessTokensToServers,
14 flushAndRunMultipleServers,
20 describe('Test video transcoding', function () {
21 let servers: ServerInfo[] = []
23 before(async function () {
27 servers = await flushAndRunMultipleServers(2)
29 await setAccessTokensToServers(servers)
32 it('Should not transcode video on server 1', async function () {
35 const videoAttributes = {
36 name: 'my super name for server 1',
37 description: 'my super description for server 1',
38 fixture: 'video_short.webm'
40 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
44 const res = await getVideosList(servers[0].url)
45 const video = res.body.data[0]
47 const res2 = await getVideo(servers[0].url, video.id)
48 const videoDetails = res2.body
49 expect(videoDetails.files).to.have.lengthOf(1)
51 const magnetUri = videoDetails.files[0].magnetUri
52 expect(magnetUri).to.match(/\.webm/)
54 const torrent = await webtorrentAdd(magnetUri)
55 expect(torrent.files).to.be.an('array')
56 expect(torrent.files.length).to.equal(1)
57 expect(torrent.files[0].path).match(/\.webm$/)
60 it('Should transcode video on server 2', async function () {
63 const videoAttributes = {
64 name: 'my super name for server 2',
65 description: 'my super description for server 2',
66 fixture: 'video_short.webm'
68 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
72 const res = await getVideosList(servers[1].url)
74 const video = res.body.data[0]
75 const res2 = await getVideo(servers[1].url, video.id)
76 const videoDetails = res2.body
78 expect(videoDetails.files).to.have.lengthOf(4)
80 const magnetUri = videoDetails.files[0].magnetUri
81 expect(magnetUri).to.match(/\.mp4/)
83 const torrent = await webtorrentAdd(magnetUri)
84 expect(torrent.files).to.be.an('array')
85 expect(torrent.files.length).to.equal(1)
86 expect(torrent.files[0].path).match(/\.mp4$/)
89 after(async function () {
90 killallServers(servers)
92 // Keep the logs if the test failed