]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/cli/create-transcoding-job.ts
Merge branch 'release/v1.3.0' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / cli / create-transcoding-job.ts
index e7c36f9c6243702c4775f05de750daafbdb62c9d..1c0e10066143ca270bf3430e6e8709dc0016690a 100644 (file)
@@ -4,6 +4,7 @@ import 'mocha'
 import * as chai from 'chai'
 import { VideoDetails } from '../../../shared/models/videos'
 import {
+  cleanupTests,
   doubleFollow,
   execCLI,
   flushAndRunMultipleServers,
@@ -15,20 +16,19 @@ import {
   ServerInfo,
   setAccessTokensToServers,
   uploadVideo, wait
-} from '../utils'
-import { waitJobs } from '../utils/server/jobs'
+} from '../../../shared/extra-utils'
+import { waitJobs } from '../../../shared/extra-utils/server/jobs'
 
 const expect = chai.expect
 
 describe('Test create transcoding jobs', function () {
   let servers: ServerInfo[] = []
+  let video1UUID: string
   let video2UUID: string
 
   before(async function () {
     this.timeout(60000)
 
-    await flushTests()
-
     // Run server 2 to have transcoding enabled
     servers = await flushAndRunMultipleServers(2)
     await setAccessTokensToServers(servers)
@@ -36,9 +36,10 @@ describe('Test create transcoding jobs', function () {
     await doubleFollow(servers[0], servers[1])
 
     // Upload two videos for our needs
-    await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1' })
-    const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2' })
-    video2UUID = res.body.video.uuid
+    const res1 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1' })
+    video1UUID = res1.body.video.uuid
+    const res2 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2' })
+    video2UUID = res2.body.video.uuid
 
     await waitJobs(servers)
   })
@@ -100,7 +101,31 @@ describe('Test create transcoding jobs', function () {
     }
   })
 
+  it('Should run a transcoding job on video 1 with resolution', async function () {
+    this.timeout(60000)
+
+    const env = getEnvCli(servers[0])
+    await execCLI(`${env} npm run create-transcoding-job -- -v ${video1UUID} -r 480`)
+
+    await waitJobs(servers)
+
+    for (const server of servers) {
+      const res = await getVideosList(server.url)
+      const videos = res.body.data
+      expect(videos).to.have.lengthOf(2)
+
+      const res2 = await getVideo(server.url, video1UUID)
+      const videoDetail: VideoDetails = res2.body
+
+      expect(videoDetail.files).to.have.lengthOf(2)
+
+      expect(videoDetail.files[0].resolution.id).to.equal(720)
+
+      expect(videoDetail.files[1].resolution.id).to.equal(480)
+    }
+  })
+
   after(async function () {
-    killallServers(servers)
+    await cleanupTests(servers)
   })
 })