]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/users/users-multiple-servers.ts
Implement avatar miniatures (#4639)
[github/Chocobozzz/PeerTube.git] / server / tests / api / users / users-multiple-servers.ts
index d0ca82b07867f77371d406c913128892361bc159..3e8b932c05cbdf3e34cd8f0a3d5cbbaeb68c08ba 100644 (file)
@@ -6,16 +6,19 @@ import {
   checkActorFilesWereRemoved,
   checkTmpIsEmpty,
   checkVideoFilesWereRemoved,
+  saveVideoInServers,
+  testImage
+} from '@server/tests/shared'
+import { MyUser } from '@shared/models'
+import {
   cleanupTests,
   createMultipleServers,
   doubleFollow,
   PeerTubeServer,
-  saveVideoInServers,
   setAccessTokensToServers,
-  testImage,
+  setDefaultChannelAvatar,
   waitJobs
-} from '@shared/extra-utils'
-import { MyUser } from '@shared/models'
+} from '@shared/server-commands'
 
 const expect = chai.expect
 
@@ -27,7 +30,7 @@ describe('Test users with multiple servers', function () {
 
   let videoUUID: string
   let userAccessToken: string
-  let userAvatarFilename: string
+  let userAvatarFilenames: string[]
 
   before(async function () {
     this.timeout(120_000)
@@ -36,6 +39,7 @@ describe('Test users with multiple servers', function () {
 
     // Get the access tokens
     await setAccessTokensToServers(servers)
+    await setDefaultChannelAvatar(servers)
 
     // Server 1 and server 2 follow each other
     await doubleFollow(servers[0], servers[1])
@@ -95,9 +99,11 @@ describe('Test users with multiple servers', function () {
     await servers[0].users.updateMyAvatar({ fixture })
 
     user = await servers[0].users.getMyInfo()
-    userAvatarFilename = user.account.avatar.path
+    userAvatarFilenames = user.account.avatars.map(({ path }) => path)
 
-    await testImage(servers[0].url, 'avatar2-resized', userAvatarFilename, '.png')
+    for (const avatar of user.account.avatars) {
+      await testImage(servers[0].url, `avatar2-resized-${avatar.width}x${avatar.width}`, avatar.path, '.png')
+    }
 
     await waitJobs(servers)
   })
@@ -127,7 +133,9 @@ describe('Test users with multiple servers', function () {
         expect(account.userId).to.be.undefined
       }
 
-      await testImage(server.url, 'avatar2-resized', account.avatar.path, '.png')
+      for (const avatar of account.avatars) {
+        await testImage(server.url, `avatar2-resized-${avatar.width}x${avatar.width}`, avatar.path, '.png')
+      }
     }
   })
 
@@ -191,7 +199,9 @@ describe('Test users with multiple servers', function () {
 
   it('Should not have actor files', async () => {
     for (const server of servers) {
-      await checkActorFilesWereRemoved(userAvatarFilename, server.internalServerNumber)
+      for (const userAvatarFilename of userAvatarFilenames) {
+        await checkActorFilesWereRemoved(userAvatarFilename, server.internalServerNumber)
+      }
     }
   })