X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fusers%2Fuser-subscriptions.ts;h=65b80540c858210367c2e93386a3ea18c6a67bd8;hb=24b9417cec5cc785a57b2fe169a1ae88b88801a4;hp=2fbda6828d1ca158e9240d7d00be16e491e4d592;hpb=99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 2fbda6828..65b80540c 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -2,7 +2,7 @@ import * as chai from 'chai' import 'mocha' -import { createUser, doubleFollow, flushAndRunMultipleServers, follow, getVideosList, unfollow, userLogin } from '../../utils' +import { createUser, doubleFollow, flushAndRunMultipleServers, follow, getVideosList, unfollow, updateVideo, userLogin } from '../../utils' import { killallServers, ServerInfo, uploadVideo } from '../../utils/index' import { setAccessTokensToServers } from '../../utils/users/login' import { Video, VideoChannel } from '../../../../shared/models/videos' @@ -12,7 +12,7 @@ import { listUserSubscriptions, listUserSubscriptionVideos, removeUserSubscription, - getUserSubscription + getUserSubscription, areSubscriptionsExist } from '../../utils/users/user-subscriptions' const expect = chai.expect @@ -20,6 +20,7 @@ const expect = chai.expect describe('Test users subscriptions', function () { let servers: ServerInfo[] = [] const users: { accessToken: string }[] = [] + let video3UUID: string before(async function () { this.timeout(120000) @@ -65,7 +66,8 @@ describe('Test users subscriptions', function () { await waitJobs(servers) - await uploadVideo(servers[2].url, users[2].accessToken, { name: 'video server 3 added after follow' }) + const res = await uploadVideo(servers[2].url, users[2].accessToken, { name: 'video server 3 added after follow' }) + video3UUID = res.body.video.uuid await waitJobs(servers) }) @@ -126,6 +128,23 @@ describe('Test users subscriptions', function () { } }) + it('Should return the existing subscriptions', async function () { + const uris = [ + 'user3_channel@localhost:9003', + 'root2_channel@localhost:9001', + 'root_channel@localhost:9001', + 'user3_channel@localhost:9001' + ] + + const res = await areSubscriptionsExist(servers[ 0 ].url, users[ 0 ].accessToken, uris) + const body = res.body + + expect(body['user3_channel@localhost:9003']).to.be.true + expect(body['root2_channel@localhost:9001']).to.be.false + expect(body['root_channel@localhost:9001']).to.be.true + expect(body['user3_channel@localhost:9001']).to.be.false + }) + it('Should list subscription videos', async function () { { const res = await listUserSubscriptionVideos(servers[0].url, servers[0].accessToken) @@ -247,7 +266,21 @@ describe('Test users subscriptions', function () { } }) + it('Should update a video of server 3 and see the updated video on server 1', async function () { + this.timeout(30000) + + await updateVideo(servers[2].url, users[2].accessToken, video3UUID, { name: 'video server 3 added after follow updated' }) + + await waitJobs(servers) + + const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') + const videos: Video[] = res.body.data + expect(videos[2].name).to.equal('video server 3 added after follow updated') + }) + it('Should remove user of server 3 subscription', async function () { + this.timeout(30000) + await removeUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003') await waitJobs(servers) @@ -267,6 +300,8 @@ describe('Test users subscriptions', function () { }) it('Should remove the root subscription and not display the videos anymore', async function () { + this.timeout(30000) + await removeUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001') await waitJobs(servers) @@ -288,7 +323,7 @@ describe('Test users subscriptions', function () { for (const video of res.body.data) { expect(video.name).to.not.contain('1-3') expect(video.name).to.not.contain('2-3') - expect(video.name).to.not.contain('video server 3 added after follow') + expect(video.name).to.not.contain('video server 3 added after follow updated') } }) @@ -309,7 +344,7 @@ describe('Test users subscriptions', function () { expect(videos[0].name).to.equal('video 1-3') expect(videos[1].name).to.equal('video 2-3') - expect(videos[2].name).to.equal('video server 3 added after follow') + expect(videos[2].name).to.equal('video server 3 added after follow updated') } { @@ -319,7 +354,7 @@ describe('Test users subscriptions', function () { for (const video of res.body.data) { expect(video.name).to.not.contain('1-3') expect(video.name).to.not.contain('2-3') - expect(video.name).to.not.contain('video server 3 added after follow') + expect(video.name).to.not.contain('video server 3 added after follow updated') } } })