aboutsummaryrefslogblamecommitdiffhomepage
path: root/shared/extra-utils/users/accounts.ts
blob: 9fc1bcfc4f826cdb7ef5c8a5b4f994fb6ea2a173 (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                                                              
 
                             
                                              
                           
                                                 
                                          

                                               
                        





                                                          
                                           




                                                                       

 
                                                                                    




                                                                
                                                           

                                      
                                              
                               
                                           



     
        
                       
                            
 
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */

import { expect } from 'chai'
import { pathExists, readdir } from 'fs-extra'
import { join } from 'path'
import { root } from '@server/helpers/core-utils'
import { PeerTubeServer } from '../server'

async function expectAccountFollows (options: {
  server: PeerTubeServer
  handle: string
  followers: number
  following: number
}) {
  const { server, handle, followers, following } = options

  const body = await server.accounts.list()
  const account = body.data.find(a => a.name + '@' + a.host === handle)

  const message = `${handle} on ${server.url}`
  expect(account.followersCount).to.equal(followers, message)
  expect(account.followingCount).to.equal(following, message)
}

async function checkActorFilesWereRemoved (filename: string, serverNumber: number) {
  const testDirectory = 'test' + serverNumber

  for (const directory of [ 'avatars' ]) {
    const directoryPath = join(root(), testDirectory, directory)

    const directoryExists = await pathExists(directoryPath)
    expect(directoryExists).to.be.true

    const files = await readdir(directoryPath)
    for (const file of files) {
      expect(file).to.not.contain(filename)
    }
  }
}

export {
  expectAccountFollows,
  checkActorFilesWereRemoved
}