+ {
+ const body = await servers[0].follows.getFollowings({ start, count, sort, search: 'bla' })
+ expect(body.total).to.equal(0)
+
+ expect(body.data).to.have.lengthOf(0)
+ }
+ })
+
+ it('Should search/filter followers on server 2', async function () {
+ const start = 0
+ const count = 5
+ const sort = 'createdAt'
+
+ {
+ const search = servers[0].port + ''
+
+ {
+ const body = await servers[2].follows.getFollowers({ start, count, sort, search })
+ expect(body.total).to.equal(1)
+
+ const follows = body.data
+ expect(follows).to.have.lengthOf(1)
+ expect(follows[0].following.host).to.equal(servers[2].host)
+ }
+
+ {
+ const body = await servers[2].follows.getFollowers({ start, count, sort, search, state: 'accepted' })
+ expect(body.total).to.equal(1)
+ expect(body.data).to.have.lengthOf(1)
+ }
+
+ {
+ const body = await servers[2].follows.getFollowers({ start, count, sort, search, state: 'accepted', actorType: 'Person' })
+ expect(body.total).to.equal(0)
+ expect(body.data).to.have.lengthOf(0)
+ }
+
+ {
+ const body = await servers[2].follows.getFollowers({
+ start,
+ count,
+ sort,
+ search,
+ state: 'accepted',
+ actorType: 'Application'
+ })
+ expect(body.total).to.equal(1)
+ expect(body.data).to.have.lengthOf(1)
+ }
+
+ {
+ const body = await servers[2].follows.getFollowers({ start, count, sort, search, state: 'pending' })
+ expect(body.total).to.equal(0)
+ expect(body.data).to.have.lengthOf(0)
+ }
+ }
+
+ {
+ const body = await servers[2].follows.getFollowers({ start, count, sort, search: 'bla' })
+ expect(body.total).to.equal(0)
+
+ const follows = body.data
+ expect(follows).to.have.lengthOf(0)
+ }
+ })
+
+ it('Should have the correct follows counts', async function () {
+ await expectAccountFollows({ server: servers[0], handle: 'peertube@' + servers[0].host, followers: 0, following: 2 })
+ await expectAccountFollows({ server: servers[0], handle: 'root@' + servers[1].host, followers: 1, following: 0 })
+ await expectAccountFollows({ server: servers[0], handle: 'peertube@' + servers[2].host, followers: 1, following: 0 })
+
+ // Server 2 and 3 does not know server 1 follow another server (there was not a refresh)
+ await expectAccountFollows({ server: servers[1], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 })
+ await expectAccountFollows({ server: servers[1], handle: 'root@' + servers[1].host, followers: 1, following: 0 })
+ await expectAccountFollows({ server: servers[1], handle: 'peertube@' + servers[1].host, followers: 0, following: 0 })
+
+ await expectAccountFollows({ server: servers[2], handle: 'peertube@' + servers[0].host, followers: 0, following: 1 })
+ await expectAccountFollows({ server: servers[2], handle: 'peertube@' + servers[2].host, followers: 1, following: 0 })
+ })
+
+ it('Should unfollow server 3 on server 1', async function () {
+ this.timeout(15000)
+
+ await servers[0].follows.unfollow({ target: servers[2] })
+
+ await waitJobs(servers)
+ })