]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/video-imports.ts
Refactor video rights checker
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-imports.ts
index ba21ab17acd7d4d009ee819512bed85a3587a1d4..cf9f7d0cbb029ce8d84c876274ca4b01bd565012 100644 (file)
@@ -143,9 +143,11 @@ describe('Test video imports', function () {
             expect(enCaption.language.label).to.equal('English')
             expect(enCaption.captionPath).to.match(new RegExp(`^/lazy-static/video-captions/.+-en.vtt$`))
 
-            const regex = `WEBVTT[ \n]+Kind: captions[ \n]+Language: en[ \n]+00:00:01.600 --> 00:00:04.200[ \n]+English \\(US\\)[ \n]+` +
-              `00:00:05.900 --> 00:00:07.999[ \n]+This is a subtitle in American English[ \n]+` +
-              `00:00:10.000 --> 00:00:14.000[ \n]+Adding subtitles is very easy to do`
+            const regex = `WEBVTT[ \n]+Kind: captions[ \n]+` +
+              `(Language: en[ \n]+)?` +
+              `00:00:01.600 --> 00:00:04.200( position:\\d+% line:\\d+%)?[ \n]+English \\(US\\)[ \n]+` +
+              `00:00:05.900 --> 00:00:07.999( position:\\d+% line:\\d+%)?[ \n]+This is a subtitle in American English[ \n]+` +
+              `00:00:10.000 --> 00:00:14.000( position:\\d+% line:\\d+%)?[ \n]+Adding subtitles is very easy to do`
             await testCaptionFile(servers[0].url, enCaption.captionPath, new RegExp(regex))
           }
 
@@ -155,9 +157,11 @@ describe('Test video imports', function () {
             expect(frCaption.language.label).to.equal('French')
             expect(frCaption.captionPath).to.match(new RegExp(`^/lazy-static/video-captions/.+-fr.vtt`))
 
-            const regex = `WEBVTT[ \n]+Kind: captions[ \n]+Language: fr[ \n]+00:00:01.600 --> 00:00:04.200[ \n]+` +
-              `Français \\(FR\\)[ \n]+00:00:05.900 --> 00:00:07.999[ \n]+C'est un sous-titre français[ \n]+` +
-              `00:00:10.000 --> 00:00:14.000[ \n]+Ajouter un sous-titre est vraiment facile`
+            const regex = `WEBVTT[ \n]+Kind: captions[ \n]+` +
+              `(Language: fr[ \n]+)?` +
+              `00:00:01.600 --> 00:00:04.200( position:\\d+% line:\\d+%)?[ \n]+Français \\(FR\\)[ \n]+` +
+              `00:00:05.900 --> 00:00:07.999( position:\\d+% line:\\d+%)?[ \n]+C'est un sous-titre français[ \n]+` +
+              `00:00:10.000 --> 00:00:14.000( position:\\d+% line:\\d+%)?[ \n]+Ajouter un sous-titre est vraiment facile`
 
             await testCaptionFile(servers[0].url, frCaption.captionPath, new RegExp(regex))
           }
@@ -219,6 +223,14 @@ describe('Test video imports', function () {
         expect(videoImports[0].video.name).to.equal('你好 世界 720p.mp4')
       })
 
+      it('Should filter my imports on target URL', async function () {
+        const { total, data: videoImports } = await servers[0].imports.getMyVideoImports({ targetUrl: FIXTURE_URLS.youtube })
+        expect(total).to.equal(1)
+        expect(videoImports).to.have.lengthOf(1)
+
+        expect(videoImports[0].targetUrl).to.equal(FIXTURE_URLS.youtube)
+      })
+
       it('Should have the video listed on the two instances', async function () {
         this.timeout(120_000)
 
@@ -459,6 +471,10 @@ describe('Test video imports', function () {
       const { data } = await server.imports.getMyVideoImports()
       expect(data).to.have.lengthOf(0)
     })
+
+    after(async function () {
+      await cleanupTests([ server ])
+    })
   })
 
   describe('Auto update', function () {