diff options
Diffstat (limited to 'server/tests/utils/follows.ts')
-rw-r--r-- | server/tests/utils/follows.ts | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/server/tests/utils/follows.ts b/server/tests/utils/follows.ts index 9ad1ca7f4..b454fe2f8 100644 --- a/server/tests/utils/follows.ts +++ b/server/tests/utils/follows.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | |||
3 | import { wait } from './miscs' | 2 | import { wait } from './miscs' |
3 | import { ServerInfo } from './servers' | ||
4 | 4 | ||
5 | function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string) { | 5 | function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string) { |
6 | const path = '/api/v1/servers/followers' | 6 | const path = '/api/v1/server/followers' |
7 | 7 | ||
8 | return request(url) | 8 | return request(url) |
9 | .get(path) | 9 | .get(path) |
@@ -16,7 +16,7 @@ function getFollowersListPaginationAndSort (url: string, start: number, count: n | |||
16 | } | 16 | } |
17 | 17 | ||
18 | function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string) { | 18 | function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string) { |
19 | const path = '/api/v1/servers/following' | 19 | const path = '/api/v1/server/following' |
20 | 20 | ||
21 | return request(url) | 21 | return request(url) |
22 | .get(path) | 22 | .get(path) |
@@ -29,25 +29,36 @@ function getFollowingListPaginationAndSort (url: string, start: number, count: n | |||
29 | } | 29 | } |
30 | 30 | ||
31 | async function follow (follower: string, following: string[], accessToken: string, expectedStatus = 204) { | 31 | async function follow (follower: string, following: string[], accessToken: string, expectedStatus = 204) { |
32 | const path = '/api/v1/servers/follow' | 32 | const path = '/api/v1/server/follow' |
33 | 33 | ||
34 | const followingHosts = following.map(f => f.replace(/^http:\/\//, '')) | ||
34 | const res = await request(follower) | 35 | const res = await request(follower) |
35 | .post(path) | 36 | .post(path) |
36 | .set('Accept', 'application/json') | 37 | .set('Accept', 'application/json') |
37 | .set('Authorization', 'Bearer ' + accessToken) | 38 | .set('Authorization', 'Bearer ' + accessToken) |
38 | .send({ 'hosts': following }) | 39 | .send({ 'hosts': followingHosts }) |
39 | .expect(expectedStatus) | 40 | .expect(expectedStatus) |
40 | 41 | ||
41 | // Wait request propagation | 42 | // Wait request propagation |
42 | await wait(1000) | 43 | await wait(20000) |
43 | 44 | ||
44 | return res | 45 | return res |
45 | } | 46 | } |
46 | 47 | ||
48 | async function doubleFollow (server1: ServerInfo, server2: ServerInfo) { | ||
49 | await Promise.all([ | ||
50 | follow(server1.url, [ server2.url ], server1.accessToken), | ||
51 | follow(server2.url, [ server1.url ], server2.accessToken) | ||
52 | ]) | ||
53 | |||
54 | return true | ||
55 | } | ||
56 | |||
47 | // --------------------------------------------------------------------------- | 57 | // --------------------------------------------------------------------------- |
48 | 58 | ||
49 | export { | 59 | export { |
50 | getFollowersListPaginationAndSort, | 60 | getFollowersListPaginationAndSort, |
51 | getFollowingListPaginationAndSort, | 61 | getFollowingListPaginationAndSort, |
52 | follow | 62 | follow, |
63 | doubleFollow | ||
53 | } | 64 | } |