]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/extra-utils/users/accounts.ts
Warning when using capitalized letter in login
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / users / accounts.ts
CommitLineData
a1587156 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
f05a1c30 2
32b2b43c 3import { expect } from 'chai'
9fff08cf 4import { pathExists, readdir } from 'fs-extra'
f05a1c30 5import { join } from 'path'
9fff08cf 6import { root } from '@server/helpers/core-utils'
254d3579 7import { PeerTubeServer } from '../server'
9fff08cf
C
8
9async function expectAccountFollows (options: {
254d3579 10 server: PeerTubeServer
9fff08cf
C
11 handle: string
12 followers: number
13 following: number
14}) {
15 const { server, handle, followers, following } = options
16
89d241a7 17 const body = await server.accounts.list()
9fff08cf
C
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)
32b2b43c
C
23}
24
57cfff78 25async function checkActorFilesWereRemoved (filename: string, serverNumber: number) {
f05a1c30
C
26 const testDirectory = 'test' + serverNumber
27
28 for (const directory of [ 'avatars' ]) {
29 const directoryPath = join(root(), testDirectory, directory)
30
9fff08cf 31 const directoryExists = await pathExists(directoryPath)
f05a1c30
C
32 expect(directoryExists).to.be.true
33
62689b94 34 const files = await readdir(directoryPath)
f05a1c30 35 for (const file of files) {
57cfff78 36 expect(file).to.not.contain(filename)
f05a1c30
C
37 }
38 }
39}
40
265ba139 41export {
32b2b43c 42 expectAccountFollows,
9fff08cf 43 checkActorFilesWereRemoved
265ba139 44}