]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/video-captions.ts
Merge branch 'release/2.1.0' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / video-captions.ts
index e4d36fd4fe7e84c20cc87cbc454167c7ab323075..a5f5c332284469b256e359fa4e4751e04f343956 100644 (file)
@@ -1,21 +1,20 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
 import {
+  cleanupTests,
   createUser,
-  flushTests,
-  killallServers,
+  flushAndRunServer,
   makeDeleteRequest,
   makeGetRequest,
   makeUploadRequest,
-  runServer,
   ServerInfo,
   setAccessTokensToServers,
   uploadVideo,
   userLogin
-} from '../../../../shared/utils'
+} from '../../../../shared/extra-utils'
 import { join } from 'path'
-import { createVideoCaption } from '../../../../shared/utils/videos/video-captions'
+import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions'
 
 describe('Test video captions API validator', function () {
   const path = '/api/v1/videos/'
@@ -29,9 +28,7 @@ describe('Test video captions API validator', function () {
   before(async function () {
     this.timeout(30000)
 
-    await flushTests()
-
-    server = await runServer(1)
+    server = await flushAndRunServer(1)
 
     await setAccessTokensToServers([ server ])
 
@@ -45,7 +42,7 @@ describe('Test video captions API validator', function () {
         username: 'user1',
         password: 'my super password'
       }
-      await createUser(server.url, server.accessToken, user.username, user.password)
+      await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
       userAccessToken = await userLogin(server, user)
     }
   })
@@ -53,7 +50,7 @@ describe('Test video captions API validator', function () {
   describe('When adding video caption', function () {
     const fields = { }
     const attaches = {
-      'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-good1.vtt')
+      captionfile: join(__dirname, '..', '..', 'fixtures', 'subtitle-good1.vtt')
     }
 
     it('Should fail without a valid uuid', async function () {
@@ -127,22 +124,23 @@ describe('Test video captions API validator', function () {
       })
     })
 
-    it('Should fail with an invalid captionfile extension', async function () {
-      const attaches = {
-        'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-bad.txt')
-      }
-
-      const captionPath = path + videoUUID + '/captions/fr'
-      await makeUploadRequest({
-        method: 'PUT',
-        url: server.url,
-        path: captionPath,
-        token: server.accessToken,
-        fields,
-        attaches,
-        statusCodeExpected: 400
-      })
-    })
+    // We accept any file now
+    // it('Should fail with an invalid captionfile extension', async function () {
+    //   const attaches = {
+    //     'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-bad.txt')
+    //   }
+    //
+    //   const captionPath = path + videoUUID + '/captions/fr'
+    //   await makeUploadRequest({
+    //     method: 'PUT',
+    //     url: server.url,
+    //     path: captionPath,
+    //     token: server.accessToken,
+    //     fields,
+    //     attaches,
+    //     statusCodeExpected: 400
+    //   })
+    // })
 
     // We don't check the extension yet
     // it('Should fail with an invalid captionfile extension and octet-stream mime type', async function () {
@@ -272,11 +270,6 @@ describe('Test video captions API validator', function () {
   })
 
   after(async function () {
-    killallServers([ server ])
-
-    // Keep the logs if the test failed
-    if (this['ok']) {
-      await flushTests()
-    }
+    await cleanupTests([ server ])
   })
 })