]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/video-captions.ts
Move AP request in requests file
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-captions.ts
index 5e13f59490b6db178e516c6f836919213621ebdc..14ecedfa6a6517fd42e9f13ce7750e1e76e9c984 100644 (file)
@@ -1,16 +1,17 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import * as chai from 'chai'
 import 'mocha'
 import {
-  checkVideoFilesWereRemoved, cleanupTests,
+  checkVideoFilesWereRemoved,
+  cleanupTests,
   doubleFollow,
   flushAndRunMultipleServers,
   removeVideo,
   uploadVideo,
   wait
 } from '../../../../shared/extra-utils'
-import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
+import { ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
 import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
 import {
   createVideoCaption,
@@ -23,11 +24,13 @@ import { VideoCaption } from '../../../../shared/models/videos/caption/video-cap
 const expect = chai.expect
 
 describe('Test video captions', function () {
+  const uuidRegex = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
+
   let servers: ServerInfo[]
   let videoUUID: string
 
   before(async function () {
-    this.timeout(30000)
+    this.timeout(60000)
 
     servers = await flushAndRunMultipleServers(2)
 
@@ -36,7 +39,7 @@ describe('Test video captions', function () {
 
     await waitJobs(servers)
 
-    const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'my video name' })
+    const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'my video name' })
     videoUUID = res.body.video.uuid
 
     await waitJobs(servers)
@@ -82,13 +85,13 @@ describe('Test video captions', function () {
       const caption1: VideoCaption = res.body.data[0]
       expect(caption1.language.id).to.equal('ar')
       expect(caption1.language.label).to.equal('Arabic')
-      expect(caption1.captionPath).to.equal('/static/video-captions/' + videoUUID + '-ar.vtt')
+      expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$'))
       await testCaptionFile(server.url, caption1.captionPath, 'Subtitle good 1.')
 
       const caption2: VideoCaption = res.body.data[1]
       expect(caption2.language.id).to.equal('zh')
       expect(caption2.language.label).to.equal('Chinese')
-      expect(caption2.captionPath).to.equal('/static/video-captions/' + videoUUID + '-zh.vtt')
+      expect(caption2.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-zh.vtt$'))
       await testCaptionFile(server.url, caption2.captionPath, 'Subtitle good 2.')
     }
   })
@@ -116,7 +119,7 @@ describe('Test video captions', function () {
       const caption1: VideoCaption = res.body.data[0]
       expect(caption1.language.id).to.equal('ar')
       expect(caption1.language.label).to.equal('Arabic')
-      expect(caption1.captionPath).to.equal('/static/video-captions/' + videoUUID + '-ar.vtt')
+      expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$'))
       await testCaptionFile(server.url, caption1.captionPath, 'Subtitle good 2.')
     }
   })
@@ -147,7 +150,7 @@ describe('Test video captions', function () {
       const caption1: VideoCaption = res.body.data[0]
       expect(caption1.language.id).to.equal('ar')
       expect(caption1.language.label).to.equal('Arabic')
-      expect(caption1.captionPath).to.equal('/static/video-captions/' + videoUUID + '-ar.vtt')
+      expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$'))
 
       const expected = 'WEBVTT FILE\r\n' +
         '\r\n' +
@@ -184,7 +187,7 @@ describe('Test video captions', function () {
 
       expect(caption.language.id).to.equal('zh')
       expect(caption.language.label).to.equal('Chinese')
-      expect(caption.captionPath).to.equal('/static/video-captions/' + videoUUID + '-zh.vtt')
+      expect(caption.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-zh.vtt$'))
       await testCaptionFile(server.url, caption.captionPath, 'Subtitle good 2.')
     }
   })