Improve create transcoding jobs tests
authorChocobozzz <me@florianbigard.com>
Wed, 30 May 2018 09:11:51 +0000 (11:11 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 30 May 2018 09:12:09 +0000 (11:12 +0200)
client/src/assets/player/video-renderer.ts
server/tests/cli/create-transcoding-job.ts

index 4affb43cf1c951aa87cf23c3d246c971b83a9d7d..4b54b661a4e24e8bfc00f1bae0d6285f00c4847a 100644 (file)
@@ -50,7 +50,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca
 
       return fallbackToMediaSource()
     })
-    preparedElem.addEventListener('loadstart', onLoadStart)
+    preparedElem.addEventListener('canplay', onLoadStart)
     return videostream(file, preparedElem)
   }
 
@@ -66,7 +66,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca
 
       return callback(err)
     })
-    preparedElem.addEventListener('loadstart', onLoadStart)
+    preparedElem.addEventListener('canplay', onLoadStart)
 
     const wrapper = new MediaElementWrapper(preparedElem)
     const writable = wrapper.createWriteStream(codecs)
@@ -95,7 +95,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca
   }
 
   function onLoadStart () {
-    preparedElem.removeEventListener('loadstart', onLoadStart)
+    preparedElem.removeEventListener('canplay', onLoadStart)
     if (opts.autoplay) preparedElem.play()
 
     callback(null, renderer)
index c2214d2859a80fc90dddebf8e3584f2bd8e54052..557dd8af988f506a8c2fdfbe31f7f722436ae0bd 100644 (file)
@@ -72,12 +72,27 @@ describe('Test create transcoding jobs', function () {
       const videos = res.body.data
       expect(videos).to.have.lengthOf(2)
 
+      let infoHashes: { [ id: number ]: string }
+
       for (const video of videos) {
         const res2 = await getVideo(server.url, video.uuid)
         const videoDetail: VideoDetails = res2.body
 
         if (video.uuid === video2UUID) {
           expect(videoDetail.files).to.have.lengthOf(4)
+
+          if (!infoHashes) {
+            infoHashes = {}
+
+            for (const file of videoDetail.files) {
+              infoHashes[file.resolution.id.toString()] = file.magnetUri
+            }
+          } else {
+            for (const resolution of Object.keys(infoHashes)) {
+              const file = videoDetail.files.find(f => f.resolution.id.toString() === resolution)
+              expect(file.magnetUri).to.equal(infoHashes[resolution])
+            }
+          }
         } else {
           expect(videoDetail.files).to.have.lengthOf(1)
         }