]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/extra-utils/users/accounts.ts
Introduce live command
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / users / accounts.ts
1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3 import { expect } from 'chai'
4 import { pathExists, readdir } from 'fs-extra'
5 import { join } from 'path'
6 import { root } from '@server/helpers/core-utils'
7 import { ServerInfo } from '../server'
8
9 async function expectAccountFollows (options: {
10 server: ServerInfo
11 handle: string
12 followers: number
13 following: number
14 }) {
15 const { server, handle, followers, following } = options
16
17 const body = await server.accountsCommand.list()
18 const account = body.data.find(a => a.name + '@' + a.host === handle)
19
20 const message = `${handle} on ${server.url}`
21 expect(account.followersCount).to.equal(followers, message)
22 expect(account.followingCount).to.equal(following, message)
23 }
24
25 async function checkActorFilesWereRemoved (filename: string, serverNumber: number) {
26 const testDirectory = 'test' + serverNumber
27
28 for (const directory of [ 'avatars' ]) {
29 const directoryPath = join(root(), testDirectory, directory)
30
31 const directoryExists = await pathExists(directoryPath)
32 expect(directoryExists).to.be.true
33
34 const files = await readdir(directoryPath)
35 for (const file of files) {
36 expect(file).to.not.contain(filename)
37 }
38 }
39 }
40
41 export {
42 expectAccountFollows,
43 checkActorFilesWereRemoved
44 }