X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fserver%2Ffollows.ts;h=010b488d8baf572f739a57559d93e92ad99e7b0e;hb=09becad8e85cc4007ff862b26fa4195f3d0e7c8d;hp=fc9c5c3b680fa430245a3fa4267f19e726757b79;hpb=8b0d42ee372de6589796be26b83e5bffb1b69cdf;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index fc9c5c3b6..010b488d8 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts @@ -12,6 +12,7 @@ import { } from '../../utils/index' import { dateIsValid } from '../../utils/miscs/miscs' import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../../utils/server/follows' +import { expectAccountFollows } from '../../utils/users/accounts' import { userLogin } from '../../utils/users/login' import { createUser } from '../../utils/users/users' import { @@ -26,7 +27,7 @@ describe('Test follows', function () { let servers: ServerInfo[] = [] before(async function () { - this.timeout(20000) + this.timeout(30000) servers = await flushAndRunMultipleServers(3) @@ -116,6 +117,19 @@ describe('Test follows', function () { expect(follows.length).to.equal(0) }) + it('Should have the correct follows counts', async function () { + await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2) + await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) + await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0) + + // Server 2 and 3 does not know server 1 follow another server (there was not a refresh) + await expectAccountFollows(servers[1].url, 'peertube@localhost:9001', 0, 1) + await expectAccountFollows(servers[1].url, 'peertube@localhost:9002', 1, 0) + + await expectAccountFollows(servers[2].url, 'peertube@localhost:9001', 0, 1) + await expectAccountFollows(servers[2].url, 'peertube@localhost:9003', 1, 0) + }) + it('Should unfollow server 3 on server 1', async function () { this.timeout(5000) @@ -144,7 +158,18 @@ describe('Test follows', function () { expect(follows.length).to.equal(0) }) - it('Should upload a video on server 2 ans 3 and propagate only the video of server 2', async function () { + it('Should have the correct follows counts 2', async function () { + await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 1) + await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) + + await expectAccountFollows(servers[1].url, 'peertube@localhost:9001', 0, 1) + await expectAccountFollows(servers[1].url, 'peertube@localhost:9002', 1, 0) + + await expectAccountFollows(servers[2].url, 'peertube@localhost:9001', 0, 0) + await expectAccountFollows(servers[2].url, 'peertube@localhost:9003', 0, 0) + }) + + it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { this.timeout(10000) await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'server2' }) @@ -223,6 +248,18 @@ describe('Test follows', function () { await wait(7000) }) + it('Should have the correct follows counts 3', async function () { + await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2) + await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) + await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0) + + await expectAccountFollows(servers[1].url, 'peertube@localhost:9001', 0, 1) + await expectAccountFollows(servers[1].url, 'peertube@localhost:9002', 1, 0) + + await expectAccountFollows(servers[2].url, 'peertube@localhost:9001', 0, 2) + await expectAccountFollows(servers[2].url, 'peertube@localhost:9003', 1, 0) + }) + it('Should propagate videos', async function () { const res = await getVideosList(servers[ 0 ].url) expect(res.body.total).to.equal(7) @@ -243,9 +280,13 @@ describe('Test follows', function () { language: 3, nsfw: true, description: 'my super description', - host: 'localhost:9003', - account: 'root', + support: 'my super support text', + account: { + name: 'root', + host: 'localhost:9003' + }, isLocal, + commentsEnabled: true, duration: 5, tags: [ 'tag1', 'tag2', 'tag3' ], privacy: VideoPrivacy.PUBLIC, @@ -305,6 +346,18 @@ describe('Test follows', function () { expect(secondChild.comment.text).to.equal('my second answer to thread 1') expect(secondChild.children).to.have.lengthOf(0) }) + + it('Should unfollow server 3 on server 1 and does not list server 3 videos', async function () { + this.timeout(5000) + + await unfollow(servers[0].url, servers[0].accessToken, servers[2]) + + await wait(3000) + + let res = await getVideosList(servers[ 0 ].url) + expect(res.body.total).to.equal(1) + }) + }) after(async function () {