]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/cli/create-transcoding-job.ts
Relax bitrate/fps test
[github/Chocobozzz/PeerTube.git] / server / tests / cli / create-transcoding-job.ts
index 3fd6240915181a691781e432013dcb9c559a48ec..8897d8c2391de2a6123bb2f520d0bfb008c56dcf 100644 (file)
@@ -1,22 +1,19 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import 'mocha'
-import * as chai from 'chai'
+import { expect } from 'chai'
+import { areObjectStorageTestsDisabled } from '@shared/core-utils'
 import { HttpStatusCode, VideoFile } from '@shared/models'
 import {
-  areObjectStorageTestsDisabled,
   cleanupTests,
   createMultipleServers,
   doubleFollow,
-  expectStartWith,
   makeRawRequest,
   ObjectStorageCommand,
   PeerTubeServer,
   setAccessTokensToServers,
   waitJobs
-} from '../../../shared/extra-utils'
-
-const expect = chai.expect
+} from '@shared/server-commands'
+import { checkResolutionsInMasterPlaylist, expectStartWith } from '../shared'
 
 async function checkFilesInObjectStorage (files: VideoFile[], type: 'webtorrent' | 'playlist') {
   for (const file of files) {
@@ -33,9 +30,10 @@ async function checkFilesInObjectStorage (files: VideoFile[], type: 'webtorrent'
 function runTests (objectStorage: boolean) {
   let servers: PeerTubeServer[] = []
   const videosUUID: string[] = []
+  const publishedAt: string[] = []
 
   before(async function () {
-    this.timeout(60000)
+    this.timeout(120000)
 
     const config = objectStorage
       ? ObjectStorageCommand.getDefaultConfig()
@@ -54,6 +52,11 @@ function runTests (objectStorage: boolean) {
     for (let i = 1; i <= 5; i++) {
       const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'video' + i } })
 
+      await waitJobs(servers)
+
+      const video = await servers[0].videos.get({ id: uuid })
+      publishedAt.push(video.publishedAt as string)
+
       if (i > 2) {
         videosUUID.push(uuid)
       } else {
@@ -157,11 +160,18 @@ function runTests (objectStorage: boolean) {
 
       expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
 
-      const files = videoDetails.streamingPlaylists[0].files
+      const hlsPlaylist = videoDetails.streamingPlaylists[0]
+
+      const files = hlsPlaylist.files
       expect(files).to.have.lengthOf(1)
       expect(files[0].resolution.id).to.equal(480)
 
-      if (objectStorage) await checkFilesInObjectStorage(files, 'playlist')
+      if (objectStorage) {
+        await checkFilesInObjectStorage(files, 'playlist')
+
+        const resolutions = files.map(f => f.resolution.id)
+        await checkResolutionsInMasterPlaylist({ server, playlistUrl: hlsPlaylist.playlistUrl, resolutions })
+      }
     }
   })
 
@@ -214,9 +224,9 @@ function runTests (objectStorage: boolean) {
     for (const server of servers) {
       const videoDetails = await server.videos.get({ id: videosUUID[4] })
 
-      expect(videoDetails.files).to.have.lengthOf(4)
+      expect(videoDetails.files).to.have.lengthOf(5)
       expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
-      expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(4)
+      expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(5)
 
       if (objectStorage) {
         await checkFilesInObjectStorage(videoDetails.files, 'webtorrent')
@@ -225,6 +235,14 @@ function runTests (objectStorage: boolean) {
     }
   })
 
+  it('Should not have updated published at attributes', async function () {
+    for (const id of videosUUID) {
+      const video = await servers[0].videos.get({ id })
+
+      expect(publishedAt.some(p => video.publishedAt === p)).to.be.true
+    }
+  })
+
   after(async function () {
     await cleanupTests(servers)
   })