2020-01-31 16:56:52 +01:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
2018-01-18 10:53:54 +01:00
|
|
|
|
2018-01-12 11:47:45 +01:00
|
|
|
import { expect } from 'chai'
|
2021-07-07 13:38:26 +02:00
|
|
|
import { pathExists, readdir } from 'fs-extra'
|
2018-01-18 10:53:54 +01:00
|
|
|
import { join } from 'path'
|
2021-07-07 13:38:26 +02:00
|
|
|
import { root } from '@server/helpers/core-utils'
|
|
|
|
import { ServerInfo } from '../server'
|
|
|
|
|
|
|
|
async function expectAccountFollows (options: {
|
|
|
|
server: ServerInfo
|
|
|
|
handle: string
|
|
|
|
followers: number
|
|
|
|
following: number
|
|
|
|
}) {
|
|
|
|
const { server, handle, followers, following } = options
|
|
|
|
|
|
|
|
const body = await server.accountsCommand.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)
|
2018-01-12 11:47:45 +01:00
|
|
|
}
|
|
|
|
|
2019-05-31 14:02:26 +02:00
|
|
|
async function checkActorFilesWereRemoved (filename: string, serverNumber: number) {
|
2018-01-18 10:53:54 +01:00
|
|
|
const testDirectory = 'test' + serverNumber
|
|
|
|
|
|
|
|
for (const directory of [ 'avatars' ]) {
|
|
|
|
const directoryPath = join(root(), testDirectory, directory)
|
|
|
|
|
2021-07-07 13:38:26 +02:00
|
|
|
const directoryExists = await pathExists(directoryPath)
|
2018-01-18 10:53:54 +01:00
|
|
|
expect(directoryExists).to.be.true
|
|
|
|
|
2018-08-27 16:23:34 +02:00
|
|
|
const files = await readdir(directoryPath)
|
2018-01-18 10:53:54 +01:00
|
|
|
for (const file of files) {
|
2019-05-31 14:02:26 +02:00
|
|
|
expect(file).to.not.contain(filename)
|
2018-01-18 10:53:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-03 16:38:50 +01:00
|
|
|
export {
|
2018-01-12 11:47:45 +01:00
|
|
|
expectAccountFollows,
|
2021-07-07 13:38:26 +02:00
|
|
|
checkActorFilesWereRemoved
|
2018-01-03 16:38:50 +01:00
|
|
|
}
|