]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/search/search-activitypub-video-channels.ts
Delete invalid or deleted remote videos
[github/Chocobozzz/PeerTube.git] / server / tests / api / search / search-activitypub-video-channels.ts
index 512cb32fd655f5d54deba7ce0eebebc42c36caf7..a287c5bdf64354e9fb940fdf1de7db62345ab093 100644 (file)
@@ -8,11 +8,11 @@ import {
   deleteVideoChannel,
   flushAndRunMultipleServers,
   flushTests,
-  getVideoChannelsList,
+  getVideoChannelsList, getVideoChannelVideos,
   killallServers,
   ServerInfo,
   setAccessTokensToServers,
-  updateMyUser,
+  updateMyUser, updateVideo,
   updateVideoChannel,
   uploadVideo,
   userLogin,
@@ -27,6 +27,8 @@ const expect = chai.expect
 describe('Test a ActivityPub video channels search', function () {
   let servers: ServerInfo[]
   let userServer2Token: string
+  let videoServer2UUID: string
+  let channelIdServer2: number
 
   before(async function () {
     this.timeout(120000)
@@ -56,10 +58,10 @@ describe('Test a ActivityPub video channels search', function () {
         displayName: 'Channel 1 server 2'
       }
       const resChannel = await addVideoChannel(servers[1].url, userServer2Token, channel)
-      const channelId = resChannel.body.videoChannel.id
+      channelIdServer2 = resChannel.body.videoChannel.id
 
-      await uploadVideo(servers[1].url, userServer2Token, { name: 'video 1 server 2', channelId })
-      await uploadVideo(servers[1].url, userServer2Token, { name: 'video 2 server 2', channelId })
+      const res = await uploadVideo(servers[1].url, userServer2Token, { name: 'video 1 server 2', channelId: channelIdServer2 })
+      videoServer2UUID = res.body.video.uuid
     }
 
     await waitJobs(servers)
@@ -129,6 +131,23 @@ describe('Test a ActivityPub video channels search', function () {
     expect(res.body.data[2].name).to.equal('root_channel')
   })
 
+  it('Should list video channel videos of server 2 without token', async function () {
+    this.timeout(30000)
+
+    await waitJobs(servers)
+
+    const res = await getVideoChannelVideos(servers[0].url, null, 'channel1_server2@localhost:9002', 0, 5)
+    expect(res.body.total).to.equal(0)
+    expect(res.body.data).to.have.lengthOf(0)
+  })
+
+  it('Should list video channel videos of server 2 with token', async function () {
+    const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, 'channel1_server2@localhost:9002', 0, 5)
+
+    expect(res.body.total).to.equal(1)
+    expect(res.body.data[0].name).to.equal('video 1 server 2')
+  })
+
   it('Should update video channel of server 2, and refresh it on server 1', async function () {
     this.timeout(60000)
 
@@ -151,6 +170,29 @@ describe('Test a ActivityPub video channels search', function () {
     // expect(videoChannel.ownerAccount.displayName).to.equal('user updated')
   })
 
+  it('Should update and add a video on server 2, and update it on server 1 after a search', async function () {
+    this.timeout(60000)
+
+    await updateVideo(servers[1].url, userServer2Token, videoServer2UUID, { name: 'video 1 updated' })
+    await uploadVideo(servers[1].url, userServer2Token, { name: 'video 2 server 2', channelId: channelIdServer2 })
+
+    await waitJobs(servers)
+
+    // Expire video channel
+    await wait(10000)
+
+    const search = 'http://localhost:9002/video-channels/channel1_server2'
+    await searchVideoChannel(servers[0].url, search, servers[0].accessToken)
+
+    await waitJobs(servers)
+
+    const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, 'channel1_server2@localhost:9002', 0, 5, '-createdAt')
+
+    expect(res.body.total).to.equal(2)
+    expect(res.body.data[0].name).to.equal('video 2 server 2')
+    expect(res.body.data[1].name).to.equal('video 1 updated')
+  })
+
   it('Should delete video channel of server 2, and delete it on server 1', async function () {
     this.timeout(60000)