]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/cli/create-import-video-file-job.ts
Fix services tests
[github/Chocobozzz/PeerTube.git] / server / tests / cli / create-import-video-file-job.ts
index 9f1b57a2e04406f29f25dae12eb09c772b13e3ab..c06b9550cb4d611216c657f9c15da7aa2978d850 100644 (file)
@@ -14,7 +14,7 @@ import {
   setAccessTokensToServers,
   waitJobs
 } from '@shared/extra-utils'
-import { HttpStatusCode, VideoDetails, VideoFile } from '@shared/models'
+import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@shared/models'
 
 const expect = chai.expect
 
@@ -37,7 +37,7 @@ async function checkFiles (video: VideoDetails, objectStorage: boolean) {
 }
 
 function runTests (objectStorage: boolean) {
-  let video1UUID: string
+  let video1ShortId: string
   let video2UUID: string
 
   let servers: PeerTubeServer[] = []
@@ -59,8 +59,8 @@ function runTests (objectStorage: boolean) {
 
     // Upload two videos for our needs
     {
-      const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video1' } })
-      video1UUID = uuid
+      const { shortUUID } = await servers[0].videos.upload({ attributes: { name: 'video1' } })
+      video1ShortId = shortUUID
     }
 
     {
@@ -69,10 +69,14 @@ function runTests (objectStorage: boolean) {
     }
 
     await waitJobs(servers)
+
+    for (const server of servers) {
+      await server.config.enableTranscoding()
+    }
   })
 
   it('Should run a import job on video 1 with a lower resolution', async function () {
-    const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm`
+    const command = `npm run create-import-video-file-job -- -v ${video1ShortId} -i server/tests/fixtures/video_short-480.webm`
     await servers[0].cli.execWithEnv(command)
 
     await waitJobs(servers)
@@ -81,8 +85,8 @@ function runTests (objectStorage: boolean) {
       const { data: videos } = await server.videos.list()
       expect(videos).to.have.lengthOf(2)
 
-      const video = videos.find(({ uuid }) => uuid === video1UUID)
-      const videoDetails = await server.videos.get({ id: video.uuid })
+      const video = videos.find(({ shortUUID }) => shortUUID === video1ShortId)
+      const videoDetails = await server.videos.get({ id: video.shortUUID })
 
       expect(videoDetails.files).to.have.lengthOf(2)
       const [ originalVideo, transcodedVideo ] = videoDetails.files
@@ -100,7 +104,7 @@ function runTests (objectStorage: boolean) {
     await waitJobs(servers)
 
     for (const server of servers) {
-      const { data: videos } = await server.videos.list()
+      const { data: videos } = await server.videos.listWithToken({ include: VideoInclude.NOT_PUBLISHED_STATE })
       expect(videos).to.have.lengthOf(2)
 
       const video = videos.find(({ uuid }) => uuid === video2UUID)
@@ -118,16 +122,16 @@ function runTests (objectStorage: boolean) {
   })
 
   it('Should run a import job on video 2 with the same resolution and the same extension', async function () {
-    const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm`
+    const command = `npm run create-import-video-file-job -- -v ${video1ShortId} -i server/tests/fixtures/video_short2.webm`
     await servers[0].cli.execWithEnv(command)
 
     await waitJobs(servers)
 
     for (const server of servers) {
-      const { data: videos } = await server.videos.list()
+      const { data: videos } = await server.videos.listWithToken({ include: VideoInclude.NOT_PUBLISHED_STATE })
       expect(videos).to.have.lengthOf(2)
 
-      const video = videos.find(({ uuid }) => uuid === video1UUID)
+      const video = videos.find(({ shortUUID }) => shortUUID === video1ShortId)
       const videoDetails = await server.videos.get({ id: video.uuid })
 
       expect(videoDetails.files).to.have.lengthOf(2)
@@ -139,6 +143,11 @@ function runTests (objectStorage: boolean) {
     }
   })
 
+  it('Should not have run transcoding after an import job', async function () {
+    const { data } = await servers[0].jobs.list({ jobType: 'video-transcoding' })
+    expect(data).to.have.lengthOf(0)
+  })
+
   after(async function () {
     await cleanupTests(servers)
   })