]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/video-channels.ts
API: Add ability to update video channel avatar
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-channels.ts
index 7ae505fd78b046da9218822918e9afa71be3673f..e4e3ce9d9e78a2498b8d197e81eb4118e5fa6fd1 100644 (file)
@@ -3,7 +3,14 @@
 import * as chai from 'chai'
 import 'mocha'
 import { User, Video } from '../../../../shared/index'
-import { doubleFollow, flushAndRunMultipleServers, getVideoChannelVideos, updateVideo, uploadVideo, wait } from '../../utils'
+import {
+  doubleFollow,
+  flushAndRunMultipleServers,
+  getVideoChannelVideos, testImage,
+  updateVideo,
+  updateVideoChannelAvatar,
+  uploadVideo, wait
+} from '../../utils'
 import {
   addVideoChannel,
   deleteVideoChannel,
@@ -17,6 +24,7 @@ import {
   setAccessTokensToServers,
   updateVideoChannel
 } from '../../utils/index'
+import { waitJobs } from '../../utils/server/jobs'
 
 const expect = chai.expect
 
@@ -49,7 +57,7 @@ describe('Test video channels', function () {
       firstVideoChannelUUID = user.videoChannels[0].uuid
     }
 
-    await wait(5000)
+    await waitJobs(servers)
   })
 
   it('Should have one video channel (created with root)', async () => {
@@ -80,7 +88,7 @@ describe('Test video channels', function () {
       videoUUID = res.body.video.uuid
     }
 
-    await wait(3000)
+    await waitJobs(servers)
   })
 
   it('Should have two video channels when getting my information', async () => {
@@ -142,7 +150,7 @@ describe('Test video channels', function () {
 
     await updateVideoChannel(servers[0].url, servers[0].accessToken, secondVideoChannelId, videoChannelAttributes)
 
-    await wait(3000)
+    await waitJobs(servers)
   })
 
   it('Should have video channel updated', async function () {
@@ -158,6 +166,31 @@ describe('Test video channels', function () {
     }
   })
 
+  it('Should update video channel avatar', async function () {
+    this.timeout(5000)
+
+    const fixture = 'avatar.png'
+
+    await updateVideoChannelAvatar({
+      url: servers[0].url,
+      accessToken: servers[0].accessToken,
+      videoChannelId: secondVideoChannelId,
+      fixture
+    })
+
+    await waitJobs(servers)
+  })
+
+  it('Should have video channel avatar updated', async function () {
+    for (const server of servers) {
+      const res = await getVideoChannelsList(server.url, 0, 1, '-name')
+
+      const videoChannel = res.body.data.find(c => c.id === secondVideoChannelId)
+
+      await testImage(server.url, 'avatar-resized', videoChannel.avatar.path, '.png')
+    }
+  })
+
   it('Should get video channel', async function () {
     const res = await getVideoChannel(servers[0].url, secondVideoChannelId)
 
@@ -184,7 +217,7 @@ describe('Test video channels', function () {
 
     await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { channelId: firstVideoChannelId })
 
-    await wait(5000)
+    await waitJobs(servers)
   })
 
   it('Should list the first video channel videos', async function () {
@@ -219,10 +252,5 @@ describe('Test video channels', function () {
 
   after(async function () {
     killallServers(servers)
-
-    // Keep the logs if the test failed
-    if (this['ok']) {
-      await flushTests()
-    }
   })
 })