]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/friends-basic.js
Begin user quota
[github/Chocobozzz/PeerTube.git] / server / tests / api / friends-basic.js
index 4c2043b3984f0432aff3150940bf04f9428877e7..5f1fdd255d728104db58d2fa433886baf20d2662 100644 (file)
@@ -198,6 +198,71 @@ describe('Test basic friends', function () {
     })
   })
 
+  it('Should allow pod 1 to quit only pod 2', function (done) {
+    series([
+      // Pod 1 quits pod 2
+      function (next) {
+        const server = servers[0]
+
+        // Get pod 2 id so we can query it
+        podsUtils.getFriendsList(server.url, function (err, res) {
+          if (err) throw err
+
+          const result = res.body.data
+          let pod = result.find((friend) => (friend.host === servers[1].host))
+
+          // Remove it from the friends list
+          podsUtils.quitOneFriend(server.url, server.accessToken, pod.id, next)
+        })
+      },
+
+      // Pod 1 should have only pod 3 in its friends list
+      function (next) {
+        podsUtils.getFriendsList(servers[0].url, function (err, res) {
+          if (err) throw err
+
+          const result = res.body.data
+          expect(result).to.be.an('array')
+          expect(result.length).to.equal(1)
+
+          const pod = result[0]
+          expect(pod.host).to.equal(servers[2].host)
+
+          next()
+        })
+      },
+
+      // Pod 2 should have only pod 3 in its friends list
+      function (next) {
+        podsUtils.getFriendsList(servers[1].url, function (err, res) {
+          if (err) throw err
+
+          const result = res.body.data
+          expect(result).to.be.an('array')
+          expect(result.length).to.equal(1)
+
+          const pod = result[0]
+          expect(pod.host).to.equal(servers[2].host)
+
+          next()
+        })
+      },
+
+      // Pod 3 should have both pods in its friends list
+      function (next) {
+        podsUtils.getFriendsList(servers[2].url, function (err, res) {
+          if (err) throw err
+
+          const result = res.body.data
+          expect(result).to.be.an('array')
+          expect(result.length).to.equal(2)
+
+          next()
+        })
+      }
+    ], done)
+  })
+
   after(function (done) {
     servers.forEach(function (server) {
       process.kill(-server.app.pid)