+
+ config.followings.instance.autoFollowBack.enabled = false
+ config.followers.instance.manualApproval = false
+ await servers[1].config.updateCustomSubConfig({ newConfig: config })
+ })
+ })
+
+ describe('Auto follow index', function () {
+ const instanceIndexServer = new MockInstancesIndex()
+ let port: number
+
+ before(async () => {
+ port = await instanceIndexServer.initialize()
+ })
+
+ it('Should not auto follow index if the option is not enabled', async function () {
+ this.timeout(30000)
+
+ await wait(5000)
+ await waitJobs(servers)
+
+ await checkFollow(servers[0], servers[1], false)
+ await checkFollow(servers[1], servers[0], false)
+ })
+
+ it('Should auto follow the index', async function () {
+ this.timeout(30000)
+
+ instanceIndexServer.addInstance(servers[1].host)
+
+ const config = {
+ followings: {
+ instance: {
+ autoFollowIndex: {
+ indexUrl: `http://127.0.0.1:${port}/api/v1/instances/hosts`,
+ enabled: true
+ }
+ }
+ }
+ }
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
+
+ await wait(5000)
+ await waitJobs(servers)
+
+ await checkFollow(servers[0], servers[1], true)
+
+ await resetFollows(servers)
+ })
+
+ it('Should follow new added instances in the index but not old ones', async function () {
+ this.timeout(30000)
+
+ instanceIndexServer.addInstance(servers[2].host)
+
+ await wait(5000)
+ await waitJobs(servers)
+
+ await checkFollow(servers[0], servers[1], false)
+ await checkFollow(servers[0], servers[2], true)
+ })
+
+ after(async function () {
+ await instanceIndexServer.terminate()