]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/multiple-servers.ts
shared/ typescript types dir server-commands
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / multiple-servers.ts
index f9220e4b34a780e2470ed09904fc20414075eda7..cb83fa0f07ac7984c7860f4815398b9bf590f47b 100644 (file)
@@ -2,13 +2,12 @@
 
 import 'mocha'
 import * as chai from 'chai'
-import * as request from 'supertest'
+import request from 'supertest'
 import {
   buildAbsoluteFixturePath,
   checkTmpIsEmpty,
   checkVideoFilesWereRemoved,
   cleanupTests,
-  completeVideoCheck,
   createMultipleServers,
   dateIsValid,
   doubleFollow,
@@ -19,8 +18,9 @@ import {
   wait,
   waitJobs,
   webtorrentAdd
-} from '@shared/extra-utils'
+} from '@shared/server-commands'
 import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
+import { completeVideoCheck } from '@server/tests/shared/video'
 
 const expect = chai.expect
 
@@ -349,7 +349,7 @@ describe('Test multiple servers', function () {
 
   describe('It should list local videos', function () {
     it('Should list only local videos on server 1', async function () {
-      const { data, total } = await servers[0].videos.list({ filter: 'local' })
+      const { data, total } = await servers[0].videos.list({ isLocal: true })
 
       expect(total).to.equal(1)
       expect(data).to.be.an('array')
@@ -358,7 +358,7 @@ describe('Test multiple servers', function () {
     })
 
     it('Should list only local videos on server 2', async function () {
-      const { data, total } = await servers[1].videos.list({ filter: 'local' })
+      const { data, total } = await servers[1].videos.list({ isLocal: true })
 
       expect(total).to.equal(1)
       expect(data).to.be.an('array')
@@ -367,7 +367,7 @@ describe('Test multiple servers', function () {
     })
 
     it('Should list only local videos on server 3', async function () {
-      const { data, total } = await servers[2].videos.list({ filter: 'local' })
+      const { data, total } = await servers[2].videos.list({ isLocal: true })
 
       expect(total).to.equal(2)
       expect(data).to.be.an('array')
@@ -591,7 +591,9 @@ describe('Test multiple servers', function () {
   })
 
   describe('Should manipulate these videos', function () {
-    it('Should update the video 3 by asking server 3', async function () {
+    let updatedAtMin: Date
+
+    it('Should update video 3', async function () {
       this.timeout(10000)
 
       const attributes = {
@@ -608,6 +610,7 @@ describe('Test multiple servers', function () {
         previewfile: 'preview.jpg'
       }
 
+      updatedAtMin = new Date()
       await servers[2].videos.update({ id: toRemove[0].id, attributes })
 
       await waitJobs(servers)
@@ -622,6 +625,8 @@ describe('Test multiple servers', function () {
         const videoUpdated = data.find(video => video.name === 'my super video updated')
         expect(!!videoUpdated).to.be.true
 
+        expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
+
         const isLocal = server.url === 'http://localhost:' + servers[2].port
         const checkAttributes = {
           name: 'my super video updated',
@@ -662,6 +667,26 @@ describe('Test multiple servers', function () {
       }
     })
 
+    it('Should only update thumbnail and update updatedAt attribute', async function () {
+      this.timeout(10000)
+
+      const attributes = {
+        thumbnailfile: 'thumbnail.jpg'
+      }
+
+      updatedAtMin = new Date()
+      await servers[2].videos.update({ id: toRemove[0].id, attributes })
+
+      await waitJobs(servers)
+
+      for (const server of servers) {
+        const { data } = await server.videos.list()
+
+        const videoUpdated = data.find(video => video.name === 'my super video updated')
+        expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
+      }
+    })
+
     it('Should remove the videos 3 and 3-2 by asking server 3 and correctly delete files', async function () {
       this.timeout(30000)
 
@@ -1024,15 +1049,15 @@ describe('Test multiple servers', function () {
           files: [
             {
               resolution: 720,
-              size: 59000
+              size: 61000
             },
             {
               resolution: 480,
-              size: 34000
+              size: 40000
             },
             {
               resolution: 360,
-              size: 31000
+              size: 32000
             },
             {
               resolution: 240,