]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/users/user-subscriptions.ts
Add ability to search a video with an URL
[github/Chocobozzz/PeerTube.git] / server / tests / api / users / user-subscriptions.ts
index ba59a9a608bd41906098af2c7ce5ec39202f354a..cb7d94b0b9aff80a983cc93f83626c672945802e 100644 (file)
@@ -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'
@@ -11,7 +11,8 @@ import {
   addUserSubscription,
   listUserSubscriptions,
   listUserSubscriptionVideos,
-  removeUserSubscription
+  removeUserSubscription,
+  getUserSubscription
 } from '../../utils/users/user-subscriptions'
 
 const expect = chai.expect
@@ -19,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)
@@ -64,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)
   })
@@ -101,6 +104,30 @@ describe('Test users subscriptions', function () {
     }
   })
 
+  it('Should get subscription', async function () {
+    {
+      const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'user3_channel@localhost:9003')
+      const videoChannel: VideoChannel = res.body
+
+      expect(videoChannel.name).to.equal('user3_channel')
+      expect(videoChannel.host).to.equal('localhost:9003')
+      expect(videoChannel.displayName).to.equal('Main user3 channel')
+      expect(videoChannel.followingCount).to.equal(0)
+      expect(videoChannel.followersCount).to.equal(1)
+    }
+
+    {
+      const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'root_channel@localhost:9001')
+      const videoChannel: VideoChannel = res.body
+
+      expect(videoChannel.name).to.equal('root_channel')
+      expect(videoChannel.host).to.equal('localhost:9001')
+      expect(videoChannel.displayName).to.equal('Main root channel')
+      expect(videoChannel.followingCount).to.equal(0)
+      expect(videoChannel.followersCount).to.equal(1)
+    }
+  })
+
   it('Should list subscription videos', async function () {
     {
       const res = await listUserSubscriptionVideos(servers[0].url, servers[0].accessToken)
@@ -222,7 +249,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)
@@ -242,6 +283,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)
@@ -263,7 +306,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')
     }
   })
 
@@ -284,7 +327,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')
     }
 
     {
@@ -294,7 +337,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')
       }
     }
   })