1 /* tslint:disable:no-unused-expression */
4 import * as chai from 'chai'
5 import { VideoDetails } from '../../../shared/models/videos'
6 const expect = chai.expect
17 setAccessTokensToServers,
20 getVideo, flushAndRunMultipleServers, doubleFollow
23 describe('Test create transcoding jobs', function () {
24 let servers: ServerInfo[] = []
25 let video2UUID: string
27 before(async function () {
32 // Run server 2 to have transcoding enabled
33 servers = await flushAndRunMultipleServers(2)
34 await setAccessTokensToServers(servers)
36 await doubleFollow(servers[0], servers[1])
38 // Upload two videos for our needs
39 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1' })
40 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2' })
41 video2UUID = res.body.video.uuid
46 it('Should have two video files on each server', async function () {
49 for (const server of servers) {
50 const res = await getVideosList(server.url)
51 const videos = res.body.data
52 expect(videos).to.have.lengthOf(2)
54 for (const video of videos) {
55 const res2 = await getVideo(server.url, video.uuid)
56 const videoDetail: VideoDetails = res2.body
57 expect(videoDetail.files).to.have.lengthOf(1)
62 it('Should run a transcoding job on video 2', async function () {
65 const env = getEnvCli(servers[0])
66 await execCLI(`${env} npm run create-transcoding-job -- -v ${video2UUID}`)
70 for (const server of servers) {
71 const res = await getVideosList(server.url)
72 const videos = res.body.data
73 expect(videos).to.have.lengthOf(2)
75 for (const video of videos) {
76 const res2 = await getVideo(server.url, video.uuid)
77 const videoDetail: VideoDetails = res2.body
79 if (video.uuid === video2UUID) {
80 expect(videoDetail.files).to.have.lengthOf(4)
82 expect(videoDetail.files).to.have.lengthOf(1)
88 after(async function () {
89 killallServers(servers)
91 // Keep the logs if the test failed