]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/video-transcoder.ts
Merge branch 'release/3.2.0' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-transcoder.ts
index 1c99f26df27544bf4278a8f8d8ca70f02d0967b4..ea5ffd23917c3f0636055c7babba5f7603bcee1e 100644 (file)
@@ -361,106 +361,117 @@ describe('Test video transcoding', function () {
 
   describe('Audio upload', function () {
 
-    before(async function () {
-      await updateCustomSubConfig(servers[1].url, servers[1].accessToken, {
-        transcoding: {
-          hls: { enabled: true },
-          webtorrent: { enabled: true },
-          resolutions: {
-            '0p': false,
-            '240p': false,
-            '360p': false,
-            '480p': false,
-            '720p': false,
-            '1080p': false,
-            '1440p': false,
-            '2160p': false
+    function runSuite (mode: 'legacy' | 'resumable') {
+
+      before(async function () {
+        await updateCustomSubConfig(servers[1].url, servers[1].accessToken, {
+          transcoding: {
+            hls: { enabled: true },
+            webtorrent: { enabled: true },
+            resolutions: {
+              '0p': false,
+              '240p': false,
+              '360p': false,
+              '480p': false,
+              '720p': false,
+              '1080p': false,
+              '1440p': false,
+              '2160p': false
+            }
           }
-        }
+        })
       })
-    })
-
-    it('Should merge an audio file with the preview file', async function () {
-      this.timeout(60_000)
-
-      const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
-      await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg)
 
-      await waitJobs(servers)
+      it('Should merge an audio file with the preview file', async function () {
+        this.timeout(60_000)
 
-      for (const server of servers) {
-        const res = await getVideosList(server.url)
+        const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
+        await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg, HttpStatusCode.OK_200, mode)
 
-        const video = res.body.data.find(v => v.name === 'audio_with_preview')
-        const res2 = await getVideo(server.url, video.id)
-        const videoDetails: VideoDetails = res2.body
+        await waitJobs(servers)
 
-        expect(videoDetails.files).to.have.lengthOf(1)
+        for (const server of servers) {
+          const res = await getVideosList(server.url)
 
-        await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: HttpStatusCode.OK_200 })
-        await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: HttpStatusCode.OK_200 })
+          const video = res.body.data.find(v => v.name === 'audio_with_preview')
+          const res2 = await getVideo(server.url, video.id)
+          const videoDetails: VideoDetails = res2.body
 
-        const magnetUri = videoDetails.files[0].magnetUri
-        expect(magnetUri).to.contain('.mp4')
-      }
-    })
+          expect(videoDetails.files).to.have.lengthOf(1)
 
-    it('Should upload an audio file and choose a default background image', async function () {
-      this.timeout(60_000)
+          await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: HttpStatusCode.OK_200 })
+          await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: HttpStatusCode.OK_200 })
 
-      const videoAttributesArg = { name: 'audio_without_preview', fixture: 'sample.ogg' }
-      await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg)
+          const magnetUri = videoDetails.files[0].magnetUri
+          expect(magnetUri).to.contain('.mp4')
+        }
+      })
 
-      await waitJobs(servers)
+      it('Should upload an audio file and choose a default background image', async function () {
+        this.timeout(60_000)
 
-      for (const server of servers) {
-        const res = await getVideosList(server.url)
+        const videoAttributesArg = { name: 'audio_without_preview', fixture: 'sample.ogg' }
+        await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg, HttpStatusCode.OK_200, mode)
 
-        const video = res.body.data.find(v => v.name === 'audio_without_preview')
-        const res2 = await getVideo(server.url, video.id)
-        const videoDetails = res2.body
+        await waitJobs(servers)
 
-        expect(videoDetails.files).to.have.lengthOf(1)
+        for (const server of servers) {
+          const res = await getVideosList(server.url)
 
-        await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: HttpStatusCode.OK_200 })
-        await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: HttpStatusCode.OK_200 })
+          const video = res.body.data.find(v => v.name === 'audio_without_preview')
+          const res2 = await getVideo(server.url, video.id)
+          const videoDetails = res2.body
 
-        const magnetUri = videoDetails.files[0].magnetUri
-        expect(magnetUri).to.contain('.mp4')
-      }
-    })
+          expect(videoDetails.files).to.have.lengthOf(1)
 
-    it('Should upload an audio file and create an audio version only', async function () {
-      this.timeout(60_000)
+          await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: HttpStatusCode.OK_200 })
+          await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: HttpStatusCode.OK_200 })
 
-      await updateCustomSubConfig(servers[1].url, servers[1].accessToken, {
-        transcoding: {
-          hls: { enabled: true },
-          webtorrent: { enabled: true },
-          resolutions: {
-            '0p': true,
-            '240p': false,
-            '360p': false
-          }
+          const magnetUri = videoDetails.files[0].magnetUri
+          expect(magnetUri).to.contain('.mp4')
         }
       })
 
-      const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
-      const resVideo = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg)
+      it('Should upload an audio file and create an audio version only', async function () {
+        this.timeout(60_000)
+
+        await updateCustomSubConfig(servers[1].url, servers[1].accessToken, {
+          transcoding: {
+            hls: { enabled: true },
+            webtorrent: { enabled: true },
+            resolutions: {
+              '0p': true,
+              '240p': false,
+              '360p': false
+            }
+          }
+        })
 
-      await waitJobs(servers)
+        const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
+        const resVideo = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg, HttpStatusCode.OK_200, mode)
 
-      for (const server of servers) {
-        const res2 = await getVideo(server.url, resVideo.body.video.id)
-        const videoDetails: VideoDetails = res2.body
+        await waitJobs(servers)
+
+        for (const server of servers) {
+          const res2 = await getVideo(server.url, resVideo.body.video.id)
+          const videoDetails: VideoDetails = res2.body
 
-        for (const files of [ videoDetails.files, videoDetails.streamingPlaylists[0].files ]) {
-          expect(files).to.have.lengthOf(2)
-          expect(files.find(f => f.resolution.id === 0)).to.not.be.undefined
+          for (const files of [ videoDetails.files, videoDetails.streamingPlaylists[0].files ]) {
+            expect(files).to.have.lengthOf(2)
+            expect(files.find(f => f.resolution.id === 0)).to.not.be.undefined
+          }
         }
-      }
 
-      await updateConfigForTranscoding(servers[1])
+        await updateConfigForTranscoding(servers[1])
+      })
+    }
+
+    describe('Legacy upload', function () {
+      runSuite('legacy')
+    })
+
+    describe('Resumable upload', function () {
+      runSuite('resumable')
     })
   })