]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/video-imports.ts
Add peertube import test
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-imports.ts
index 8b6542aa417c9d12370f313efbdf64773480b130..1086886513633b3a1d2f1bb11af2a5471b76fe17 100644 (file)
@@ -5,10 +5,10 @@ import * as chai from 'chai'
 import {
   areHttpImportTestsDisabled,
   cleanupTests,
+  createMultipleServers,
   doubleFollow,
-  flushAndRunMultipleServers,
-  ImportsCommand,
-  ServerInfo,
+  FIXTURE_URLS,
+  PeerTubeServer,
   setAccessTokensToServers,
   testCaptionFile,
   testImage,
@@ -19,13 +19,13 @@ import { VideoPrivacy, VideoResolution } from '@shared/models'
 const expect = chai.expect
 
 describe('Test video imports', function () {
-  let servers: ServerInfo[] = []
+  let servers: PeerTubeServer[] = []
   let channelIdServer1: number
   let channelIdServer2: number
 
   if (areHttpImportTestsDisabled()) return
 
-  async function checkVideosServer1 (server: ServerInfo, idHttp: string, idMagnet: string, idTorrent: string) {
+  async function checkVideosServer1 (server: PeerTubeServer, idHttp: string, idMagnet: string, idTorrent: string) {
     const videoHttp = await server.videos.get({ id: idHttp })
 
     expect(videoHttp.name).to.equal('small video - youtube')
@@ -59,11 +59,11 @@ describe('Test video imports', function () {
     expect(videoTorrent.name).to.contain('你好 世界 720p.mp4')
     expect(videoMagnet.name).to.contain('super peertube2 video')
 
-    const bodyCaptions = await server.captions.listVideoCaptions({ videoId: idHttp })
+    const bodyCaptions = await server.captions.list({ videoId: idHttp })
     expect(bodyCaptions.total).to.equal(2)
   }
 
-  async function checkVideoServer2 (server: ServerInfo, id: number | string) {
+  async function checkVideoServer2 (server: PeerTubeServer, id: number | string) {
     const video = await server.videos.get({ id })
 
     expect(video.name).to.equal('my super name')
@@ -76,7 +76,7 @@ describe('Test video imports', function () {
 
     expect(video.files).to.have.lengthOf(1)
 
-    const bodyCaptions = await server.captions.listVideoCaptions({ videoId: id })
+    const bodyCaptions = await server.captions.list({ videoId: id })
     expect(bodyCaptions.total).to.equal(2)
   }
 
@@ -84,7 +84,7 @@ describe('Test video imports', function () {
     this.timeout(30_000)
 
     // Run servers
-    servers = await flushAndRunMultipleServers(2)
+    servers = await createMultipleServers(2)
 
     await setAccessTokensToServers(servers)
 
@@ -110,7 +110,7 @@ describe('Test video imports', function () {
     }
 
     {
-      const attributes = { ...baseAttributes, targetUrl: ImportsCommand.getYoutubeVideoUrl() }
+      const attributes = { ...baseAttributes, targetUrl: FIXTURE_URLS.youtube }
       const { video } = await servers[0].imports.importVideo({ attributes })
       expect(video.name).to.equal('small video - youtube')
 
@@ -120,7 +120,7 @@ describe('Test video imports', function () {
       await testImage(servers[0].url, 'video_import_thumbnail', video.thumbnailPath)
       await testImage(servers[0].url, 'video_import_preview', video.previewPath)
 
-      const bodyCaptions = await servers[0].captions.listVideoCaptions({ videoId: video.id })
+      const bodyCaptions = await servers[0].captions.list({ videoId: video.id })
       const videoCaptions = bodyCaptions.data
       expect(videoCaptions).to.have.lengthOf(2)
 
@@ -162,7 +162,7 @@ Ajouter un sous-titre est vraiment facile`)
     {
       const attributes = {
         ...baseAttributes,
-        magnetUri: ImportsCommand.getMagnetURI(),
+        magnetUri: FIXTURE_URLS.magnet,
         description: 'this is a super torrent description',
         tags: [ 'tag_torrent1', 'tag_torrent2' ]
       }
@@ -199,13 +199,13 @@ Ajouter un sous-titre est vraiment facile`)
 
     expect(videoImports).to.have.lengthOf(3)
 
-    expect(videoImports[2].targetUrl).to.equal(ImportsCommand.getYoutubeVideoUrl())
+    expect(videoImports[2].targetUrl).to.equal(FIXTURE_URLS.youtube)
     expect(videoImports[2].magnetUri).to.be.null
     expect(videoImports[2].torrentName).to.be.null
     expect(videoImports[2].video.name).to.equal('small video - youtube')
 
     expect(videoImports[1].targetUrl).to.be.null
-    expect(videoImports[1].magnetUri).to.equal(ImportsCommand.getMagnetURI())
+    expect(videoImports[1].magnetUri).to.equal(FIXTURE_URLS.magnet)
     expect(videoImports[1].torrentName).to.be.null
     expect(videoImports[1].video.name).to.equal('super peertube2 video')
 
@@ -234,7 +234,7 @@ Ajouter un sous-titre est vraiment facile`)
     this.timeout(60_000)
 
     const attributes = {
-      targetUrl: ImportsCommand.getYoutubeVideoUrl(),
+      targetUrl: FIXTURE_URLS.youtube,
       channelId: channelIdServer2,
       privacy: VideoPrivacy.PUBLIC,
       category: 10,
@@ -270,7 +270,7 @@ Ajouter un sous-titre est vraiment facile`)
 
     const attributes = {
       name: 'transcoded video',
-      magnetUri: ImportsCommand.getMagnetURI(),
+      magnetUri: FIXTURE_URLS.magnet,
       channelId: channelIdServer2,
       privacy: VideoPrivacy.PUBLIC
     }
@@ -320,7 +320,7 @@ Ajouter un sous-titre est vraiment facile`)
 
     const attributes = {
       name: 'hdr video',
-      targetUrl: ImportsCommand.getYoutubeHDRVideoUrl(),
+      targetUrl: FIXTURE_URLS.youtubeHDR,
       channelId: channelIdServer1,
       privacy: VideoPrivacy.PUBLIC
     }
@@ -336,6 +336,32 @@ Ajouter un sous-titre est vraiment facile`)
     expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_1080P)
   })
 
+  it('Should import a peertube video', async function () {
+    this.timeout(120_000)
+
+    // TODO: include peertube_short when https://github.com/ytdl-org/youtube-dl/pull/29475 is merged
+    for (const targetUrl of [ FIXTURE_URLS.peertube_long ]) {
+    // for (const targetUrl of [ FIXTURE_URLS.peertube_long, FIXTURE_URLS.peertube_short ]) {
+      await servers[0].config.disableTranscoding()
+
+      const attributes = {
+        targetUrl,
+        channelId: channelIdServer1,
+        privacy: VideoPrivacy.PUBLIC
+      }
+      const { video } = await servers[0].imports.importVideo({ attributes })
+      const videoUUID = video.uuid
+
+      await waitJobs(servers)
+
+      for (const server of servers) {
+        const video = await server.videos.get({ id: videoUUID })
+
+        expect(video.name).to.equal('E2E tests')
+      }
+    }
+  })
+
   after(async function () {
     await cleanupTests(servers)
   })