X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Ffriends-basic.js;h=5f1fdd255d728104db58d2fa433886baf20d2662;hb=d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f;hp=658e54829b62cf75ec92763637bede4847396873;hpb=72329aaa28bcbb678443900233cc47cff7ba1509;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/friends-basic.js b/server/tests/api/friends-basic.js index 658e54829..5f1fdd255 100644 --- a/server/tests/api/friends-basic.js +++ b/server/tests/api/friends-basic.js @@ -47,7 +47,7 @@ describe('Test basic friends', function () { // --------------------------------------------------------------- before(function (done) { - this.timeout(20000) + this.timeout(120000) serversUtils.flushAndRunMultipleServers(3, function (serversRun, urlsRun) { servers = serversRun @@ -76,7 +76,7 @@ describe('Test basic friends', function () { }) it('Should make friends', function (done) { - this.timeout(40000) + this.timeout(120000) series([ // The second pod make friend with the third @@ -142,11 +142,14 @@ describe('Test basic friends', function () { }) it('Should not be allowed to make friend again', function (done) { + this.timeout(10000) const server = servers[1] podsUtils.makeFriends(server.url, server.accessToken, 409, done) }) it('Should quit friends of pod 2', function (done) { + this.timeout(10000) + series([ // Pod 1 quit friends function (next) { @@ -183,7 +186,7 @@ describe('Test basic friends', function () { }) it('Should allow pod 2 to make friend again', function (done) { - this.timeout(20000) + this.timeout(120000) const server = servers[1] podsUtils.makeFriends(server.url, server.accessToken, function () { @@ -195,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)