]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/cli/create-transcoding-job.ts
Merge branch 'release/4.0.0' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / cli / create-transcoding-job.ts
index 3313a492fdf61ec12d5e9cb26f5230253716653b..c85130fef8db2ea17c2e71f9837a5fd67804f9ce 100644 (file)
@@ -2,19 +2,19 @@
 
 import 'mocha'
 import * as chai 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'
+} from '@shared/server-commands'
+import { expectStartWith } from '../shared'
 
 const expect = chai.expect
 
@@ -33,9 +33,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()
@@ -52,8 +53,18 @@ function runTests (objectStorage: boolean) {
     if (objectStorage) await ObjectStorageCommand.prepareDefaultBuckets()
 
     for (let i = 1; i <= 5; i++) {
-      const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' + i } })
-      videosUUID.push(uuid)
+      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 {
+        videosUUID.push(shortUUID)
+      }
     }
 
     await waitJobs(servers)
@@ -88,7 +99,7 @@ function runTests (objectStorage: boolean) {
       for (const video of data) {
         const videoDetails = await server.videos.get({ id: video.uuid })
 
-        if (video.uuid === videosUUID[1]) {
+        if (video.shortUUID === videosUUID[1] || video.uuid === videosUUID[1]) {
           expect(videoDetails.files).to.have.lengthOf(4)
           expect(videoDetails.streamingPlaylists).to.have.lengthOf(0)
 
@@ -209,9 +220,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')
@@ -220,6 +231,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)
   })