X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Futils%2Ffollows.ts;h=b88776011e590f4235782b60a806f101062305b1;hb=1f3e9feca2caf68024168b0ea9ed39d8438fa235;hp=b454fe2f8f3a1f303f675cbf585e9a13c60807a7;hpb=afffe98839db7ccbfa9fb8b7d1413b97900fdc73;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/utils/follows.ts b/server/tests/utils/follows.ts index b454fe2f8..b88776011 100644 --- a/server/tests/utils/follows.ts +++ b/server/tests/utils/follows.ts @@ -29,7 +29,7 @@ function getFollowingListPaginationAndSort (url: string, start: number, count: n } async function follow (follower: string, following: string[], accessToken: string, expectedStatus = 204) { - const path = '/api/v1/server/follow' + const path = '/api/v1/server/following' const followingHosts = following.map(f => f.replace(/^http:\/\//, '')) const res = await request(follower) @@ -39,8 +39,17 @@ async function follow (follower: string, following: string[], accessToken: strin .send({ 'hosts': followingHosts }) .expect(expectedStatus) - // Wait request propagation - await wait(20000) + return res +} + +async function unfollow (url: string, accessToken: string, id: number, expectedStatus = 204) { + const path = '/api/v1/server/following/' + id + + const res = await request(url) + .delete(path) + .set('Accept', 'application/json') + .set('Authorization', 'Bearer ' + accessToken) + .expect(expectedStatus) return res } @@ -51,6 +60,9 @@ async function doubleFollow (server1: ServerInfo, server2: ServerInfo) { follow(server2.url, [ server1.url ], server2.accessToken) ]) + // Wait request propagation + await wait(20000) + return true } @@ -59,6 +71,7 @@ async function doubleFollow (server1: ServerInfo, server2: ServerInfo) { export { getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, + unfollow, follow, doubleFollow }