]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/users/users-multiple-servers.ts
Fix video import if autoblacklist is enabled
[github/Chocobozzz/PeerTube.git] / server / tests / api / users / users-multiple-servers.ts
index 575e04546d776d21de36c5dbf02ab58c16a845bd..9a971adb39350d557938d55314c9c51c8428d66f 100644 (file)
@@ -4,7 +4,8 @@ import * as chai from 'chai'
 import 'mocha'
 import { Account } from '../../../../shared/models/actors'
 import {
-  checkVideoFilesWereRemoved,
+  checkTmpIsEmpty,
+  checkVideoFilesWereRemoved, cleanupTests,
   createUser,
   doubleFollow,
   flushAndRunMultipleServers,
@@ -13,13 +14,20 @@ import {
   removeUser,
   updateMyUser,
   userLogin
-} from '../../utils'
-import { getMyUserInformation, killallServers, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../utils/index'
-import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../utils/users/accounts'
-import { setAccessTokensToServers } from '../../utils/users/login'
+} from '../../../../shared/extra-utils'
+import {
+  getMyUserInformation,
+  killallServers,
+  ServerInfo,
+  testImage,
+  updateMyAvatar,
+  uploadVideo
+} from '../../../../shared/extra-utils/index'
+import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../../../shared/extra-utils/users/accounts'
+import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
 import { User } from '../../../../shared/models/users'
 import { VideoChannel } from '../../../../shared/models/videos'
-import { waitJobs } from '../../utils/server/jobs'
+import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
 
 const expect = chai.expect
 
@@ -27,6 +35,7 @@ describe('Test users with multiple servers', function () {
   let servers: ServerInfo[] = []
   let user: User
   let userAccountName: string
+  let userAccountUUID: string
   let userVideoChannelUUID: string
   let userId: number
   let videoUUID: string
@@ -55,14 +64,21 @@ describe('Test users with multiple servers', function () {
         username: 'user1',
         password: 'password'
       }
-      const res = await createUser(servers[ 0 ].url, servers[ 0 ].accessToken, user.username, user.password)
+      const res = await createUser({
+        url: servers[ 0 ].url,
+        accessToken: servers[ 0 ].accessToken,
+        username: user.username,
+        password: user.password
+      })
       userId = res.body.user.id
       userAccessToken = await userLogin(servers[ 0 ], user)
     }
 
     {
       const res = await getMyUserInformation(servers[0].url, userAccessToken)
-      userAccountName = res.body.account.name + '@' + res.body.account.host
+      const account: Account = res.body.account
+      userAccountName = account.name + '@' + account.host
+      userAccountUUID = account.uuid
     }
 
     {
@@ -145,6 +161,12 @@ describe('Test users with multiple servers', function () {
       expect(rootServer1Get.displayName).to.equal('my super display name')
       expect(rootServer1Get.description).to.equal('my super description updated')
 
+      if (server.serverNumber === 1) {
+        expect(rootServer1Get.userId).to.be.a('number')
+      } else {
+        expect(rootServer1Get.userId).to.be.undefined
+      }
+
       await testImage(server.url, 'avatar2-resized', rootServer1Get.avatar.path, '.png')
     }
   })
@@ -196,7 +218,7 @@ describe('Test users with multiple servers', function () {
 
   it('Should not have actor files', async () => {
     for (const server of servers) {
-      await checkActorFilesWereRemoved(userAccountName, server.serverNumber)
+      await checkActorFilesWereRemoved(userAccountUUID, server.serverNumber)
       await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber)
     }
   })
@@ -207,7 +229,13 @@ describe('Test users with multiple servers', function () {
     }
   })
 
+  it('Should have an empty tmp directory', async function () {
+    for (const server of servers) {
+      await checkTmpIsEmpty(server)
+    }
+  })
+
   after(async function () {
-    killallServers(servers)
+    await cleanupTests(servers)
   })
 })