-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as chai from 'chai'
import 'mocha'
import {
acceptFollower,
+ cleanupTests,
flushAndRunMultipleServers,
- killallServers,
ServerInfo,
setAccessTokensToServers,
updateCustomSubConfig
follow,
getFollowersListPaginationAndSort,
getFollowingListPaginationAndSort,
- removeFollower,
- rejectFollower
+ rejectFollower,
+ removeFollower
} from '../../../../shared/extra-utils/server/follows'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
import { ActorFollow } from '../../../../shared/models/actors'
async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'accepted') {
{
- const res = await getFollowingListPaginationAndSort(servers[0].url, 0, 5, 'createdAt')
+ const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(1)
const follow = res.body.data[0] as ActorFollow
expect(follow.state).to.equal(state)
- expect(follow.follower.url).to.equal('http://localhost:9001/accounts/peertube')
- expect(follow.following.url).to.equal('http://localhost:9002/accounts/peertube')
+ expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + '/accounts/peertube')
+ expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube')
}
{
- const res = await getFollowersListPaginationAndSort(servers[1].url, 0, 5, 'createdAt')
+ const res = await getFollowersListPaginationAndSort({ url: servers[1].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(1)
const follow = res.body.data[0] as ActorFollow
expect(follow.state).to.equal(state)
- expect(follow.follower.url).to.equal('http://localhost:9001/accounts/peertube')
- expect(follow.following.url).to.equal('http://localhost:9002/accounts/peertube')
+ expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + '/accounts/peertube')
+ expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube')
}
}
async function checkNoFollowers (servers: ServerInfo[]) {
{
- const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, 'createdAt')
+ const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(0)
}
{
- const res = await getFollowersListPaginationAndSort(servers[ 1 ].url, 0, 5, 'createdAt')
+ const res = await getFollowersListPaginationAndSort({ url: servers[1].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(0)
}
}
})
it('Should remove follower on server 2', async function () {
+ this.timeout(10000)
+
await removeFollower(servers[1].url, servers[1].accessToken, servers[0])
await waitJobs(servers)
})
it('Should disable followers on server 2', async function () {
+ this.timeout(10000)
+
const subConfig = {
followers: {
instance: {
})
it('Should re enable followers on server 2', async function () {
+ this.timeout(10000)
+
const subConfig = {
followers: {
instance: {
})
it('Should accept a follower', async function () {
- await acceptFollower(servers[1].url, servers[1].accessToken, 'peertube@localhost:9001')
+ this.timeout(10000)
+
+ await acceptFollower(servers[1].url, servers[1].accessToken, 'peertube@localhost:' + servers[0].port)
await waitJobs(servers)
await checkServer1And2HasFollowers(servers)
await waitJobs(servers)
{
- const res = await getFollowingListPaginationAndSort(servers[0].url, 0, 5, 'createdAt')
+ const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(2)
}
{
- const res = await getFollowersListPaginationAndSort(servers[1].url, 0, 5, 'createdAt')
+ const res = await getFollowersListPaginationAndSort({ url: servers[1].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(1)
}
{
- const res = await getFollowersListPaginationAndSort(servers[2].url, 0, 5, 'createdAt')
+ const res = await getFollowersListPaginationAndSort({ url: servers[2].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(1)
}
- await rejectFollower(servers[2].url, servers[2].accessToken, 'peertube@localhost:9001')
+ await rejectFollower(servers[2].url, servers[2].accessToken, 'peertube@localhost:' + servers[0].port)
await waitJobs(servers)
await checkServer1And2HasFollowers(servers)
{
- const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt')
+ const res = await getFollowersListPaginationAndSort({ url: servers[2].url, start: 0, count: 5, sort: 'createdAt' })
expect(res.body.total).to.equal(0)
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})