]> 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 35c418f7c65abf342fc9d60f9d8fd4ac23b05fd5..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,7 +24,7 @@ import {
   setAccessTokensToServers,
   updateVideoChannel
 } from '../../utils/index'
-import { getAccountsList } from '../../utils/users/accounts'
+import { waitJobs } from '../../utils/server/jobs'
 
 const expect = chai.expect
 
@@ -50,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 () => {
@@ -81,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 () => {
@@ -99,7 +106,7 @@ describe('Test video channels', function () {
   })
 
   it('Should have two video channels when getting account channels on server 1', async function () {
-    const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.uuid)
+    const res = await getAccountVideoChannelsList(servers[0].url, userInfo.account.name + '@' + userInfo.account.host)
     expect(res.body.total).to.equal(2)
     expect(res.body.data).to.be.an('array')
     expect(res.body.data).to.have.lengthOf(2)
@@ -112,7 +119,7 @@ describe('Test video channels', function () {
   })
 
   it('Should have one video channel when getting account channels on server 2', async function () {
-    const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.uuid)
+    const res = await getAccountVideoChannelsList(servers[1].url, userInfo.account.name + '@' + userInfo.account.host)
     expect(res.body.total).to.equal(1)
     expect(res.body.data).to.be.an('array')
     expect(res.body.data).to.have.lengthOf(1)
@@ -143,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 () {
@@ -159,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)
 
@@ -185,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 () {
@@ -220,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()
-    }
   })
 })