diff options
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.ts | 2 |
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' | |||
4 | import { pathExists, readdir } from 'fs-extra' | 4 | import { pathExists, readdir } from 'fs-extra' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { root } from '@server/helpers/core-utils' | 6 | import { root } from '@server/helpers/core-utils' |
7 | import { Account, VideoChannel } from '@shared/models' | ||
7 | import { PeerTubeServer } from '../server' | 8 | import { PeerTubeServer } from '../server' |
8 | 9 | ||
9 | async function expectAccountFollows (options: { | 10 | async 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}` | 22 | async 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 | ||
25 | async function checkActorFilesWereRemoved (filename: string, serverNumber: number) { | 34 | async function checkActorFilesWereRemoved (filename: string, serverNumber: number) { |
@@ -40,5 +49,25 @@ async function checkActorFilesWereRemoved (filename: string, serverNumber: numbe | |||
40 | 49 | ||
41 | export { | 50 | export { |
42 | expectAccountFollows, | 51 | expectAccountFollows, |
52 | expectChannelsFollows, | ||
43 | checkActorFilesWereRemoved | 53 | checkActorFilesWereRemoved |
44 | } | 54 | } |
55 | |||
56 | // --------------------------------------------------------------------------- | ||
57 | |||
58 | function 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 @@ | |||
1 | export * from './accounts-command' | 1 | export * from './accounts-command' |
2 | export * from './accounts' | 2 | export * from './actors' |
3 | export * from './blocklist-command' | 3 | export * from './blocklist-command' |
4 | export * from './login' | 4 | export * from './login' |
5 | export * from './login-command' | 5 | export * from './login-command' |