1 import * as request from 'supertest'
2 import { wait } from './miscs'
3 import { ServerInfo } from './servers'
5 function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string) {
6 const path = '/api/v1/server/followers'
13 .set('Accept', 'application/json')
15 .expect('Content-Type', /json/)
18 function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string) {
19 const path = '/api/v1/server/following'
26 .set('Accept', 'application/json')
28 .expect('Content-Type', /json/)
31 async function follow (follower: string, following: string[], accessToken: string, expectedStatus = 204) {
32 const path = '/api/v1/server/following'
34 const followingHosts = following.map(f => f.replace(/^http:\/\//, ''))
35 const res = await request(follower)
37 .set('Accept', 'application/json')
38 .set('Authorization', 'Bearer ' + accessToken)
39 .send({ 'hosts': followingHosts })
40 .expect(expectedStatus)
45 async function doubleFollow (server1: ServerInfo, server2: ServerInfo) {
47 follow(server1.url, [ server2.url ], server1.accessToken),
48 follow(server2.url, [ server1.url ], server2.accessToken)
51 // Wait request propagation
57 // ---------------------------------------------------------------------------
60 getFollowersListPaginationAndSort,
61 getFollowingListPaginationAndSort,