aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/utils')
-rw-r--r--server/tests/utils/follows.ts25
-rw-r--r--server/tests/utils/servers.ts2
2 files changed, 19 insertions, 8 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 @@
1import * as request from 'supertest' 1import * as request from 'supertest'
2
3import { wait } from './miscs' 2import { wait } from './miscs'
3import { ServerInfo } from './servers'
4 4
5function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string) { 5function 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
18function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string) { 18function 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
31async function follow (follower: string, following: string[], accessToken: string, expectedStatus = 204) { 31async 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
48async 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
49export { 59export {
50 getFollowersListPaginationAndSort, 60 getFollowersListPaginationAndSort,
51 getFollowingListPaginationAndSort, 61 getFollowingListPaginationAndSort,
52 follow 62 follow,
63 doubleFollow
53} 64}
diff --git a/server/tests/utils/servers.ts b/server/tests/utils/servers.ts
index f042a9e53..faa2f19ff 100644
--- a/server/tests/utils/servers.ts
+++ b/server/tests/utils/servers.ts
@@ -24,7 +24,7 @@ interface ServerInfo {
24 id: number 24 id: number
25 uuid: string 25 uuid: string
26 name: string 26 name: string
27 author: string 27 account: string
28 } 28 }
29 29
30 remoteVideo?: { 30 remoteVideo?: {