aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/users
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/users')
-rw-r--r--shared/extra-utils/users/actors.ts (renamed from shared/extra-utils/users/accounts.ts)43
-rw-r--r--shared/extra-utils/users/index.ts2
2 files changed, 37 insertions, 8 deletions
diff --git a/shared/extra-utils/users/accounts.ts b/shared/extra-utils/users/actors.ts
index 9fc1bcfc4..cfcc7d0a7 100644
--- a/shared/extra-utils/users/accounts.ts
+++ b/shared/extra-utils/users/actors.ts
@@ -4,22 +4,31 @@ import { expect } from 'chai'
4import { pathExists, readdir } from 'fs-extra' 4import { pathExists, readdir } from 'fs-extra'
5import { join } from 'path' 5import { join } from 'path'
6import { root } from '@server/helpers/core-utils' 6import { root } from '@server/helpers/core-utils'
7import { Account, VideoChannel } from '@shared/models'
7import { PeerTubeServer } from '../server' 8import { PeerTubeServer } from '../server'
8 9
9async function expectAccountFollows (options: { 10async function expectChannelsFollows (options: {
10 server: PeerTubeServer 11 server: PeerTubeServer
11 handle: string 12 handle: string
12 followers: number 13 followers: number
13 following: number 14 following: number
14}) { 15}) {
15 const { server, handle, followers, following } = options 16 const { server } = options
17 const { data } = await server.channels.list()
16 18
17 const body = await server.accounts.list() 19 return expectActorFollow({ ...options, data })
18 const account = body.data.find(a => a.name + '@' + a.host === handle) 20}
19 21
20 const message = `${handle} on ${server.url}` 22async function expectAccountFollows (options: {
21 expect(account.followersCount).to.equal(followers, message) 23 server: PeerTubeServer
22 expect(account.followingCount).to.equal(following, message) 24 handle: string
25 followers: number
26 following: number
27}) {
28 const { server } = options
29 const { data } = await server.accounts.list()
30
31 return expectActorFollow({ ...options, data })
23} 32}
24 33
25async function checkActorFilesWereRemoved (filename: string, serverNumber: number) { 34async function checkActorFilesWereRemoved (filename: string, serverNumber: number) {
@@ -40,5 +49,25 @@ async function checkActorFilesWereRemoved (filename: string, serverNumber: numbe
40 49
41export { 50export {
42 expectAccountFollows, 51 expectAccountFollows,
52 expectChannelsFollows,
43 checkActorFilesWereRemoved 53 checkActorFilesWereRemoved
44} 54}
55
56// ---------------------------------------------------------------------------
57
58function expectActorFollow (options: {
59 server: PeerTubeServer
60 data: (Account | VideoChannel)[]
61 handle: string
62 followers: number
63 following: number
64}) {
65 const { server, data, handle, followers, following } = options
66
67 const actor = data.find(a => a.name + '@' + a.host === handle)
68 const message = `${handle} on ${server.url}`
69
70 expect(actor, message).to.exist
71 expect(actor.followersCount).to.equal(followers, message)
72 expect(actor.followingCount).to.equal(following, message)
73}
diff --git a/shared/extra-utils/users/index.ts b/shared/extra-utils/users/index.ts
index fbb454e8f..460a06f70 100644
--- a/shared/extra-utils/users/index.ts
+++ b/shared/extra-utils/users/index.ts
@@ -1,5 +1,5 @@
1export * from './accounts-command' 1export * from './accounts-command'
2export * from './accounts' 2export * from './actors'
3export * from './blocklist-command' 3export * from './blocklist-command'
4export * from './login' 4export * from './login'
5export * from './login-command' 5export * from './login-command'