]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/video-captions.ts
Fix my-account{videos,video-playlists} loading mecanism
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / video-captions.ts
index 12f890db8114dceca0ce252123cf74fec9751e91..6ddc20d691cd4685afff59a3e04eca0c86e57e67 100644 (file)
@@ -1,21 +1,20 @@
 /* tslint:disable:no-unused-expression */
 
-import * as chai from 'chai'
 import 'mocha'
 import {
+  cleanupTests,
   createUser,
-  flushTests,
-  killallServers,
+  flushAndRunServer,
   makeDeleteRequest,
   makeGetRequest,
   makeUploadRequest,
-  runServer,
   ServerInfo,
   setAccessTokensToServers,
   uploadVideo,
   userLogin
-} from '../../utils'
+} from '../../../../shared/extra-utils'
 import { join } from 'path'
+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)
     }
   })
@@ -127,6 +124,66 @@ describe('Test video captions API validator', function () {
       })
     })
 
+    // 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 () {
+    //   await createVideoCaption({
+    //     url: server.url,
+    //     accessToken: server.accessToken,
+    //     language: 'zh',
+    //     videoId: videoUUID,
+    //     fixture: 'subtitle-bad.txt',
+    //     mimeType: 'application/octet-stream',
+    //     statusCodeExpected: 400
+    //   })
+    // })
+
+    it('Should succeed with a valid captionfile extension and octet-stream mime type', async function () {
+      await createVideoCaption({
+        url: server.url,
+        accessToken: server.accessToken,
+        language: 'zh',
+        videoId: videoUUID,
+        fixture: 'subtitle-good.srt',
+        mimeType: 'application/octet-stream'
+      })
+    })
+
+    // We don't check the file validity yet
+    // it('Should fail with an invalid captionfile srt', async function () {
+    //   const attaches = {
+    //     'captionfile': join(__dirname, '..', '..', 'fixtures', 'subtitle-bad.srt')
+    //   }
+    //
+    //   const captionPath = path + videoUUID + '/captions/fr'
+    //   await makeUploadRequest({
+    //     method: 'PUT',
+    //     url: server.url,
+    //     path: captionPath,
+    //     token: server.accessToken,
+    //     fields,
+    //     attaches,
+    //     statusCodeExpected: 500
+    //   })
+    // })
+
     it('Should success with the correct parameters', async function () {
       const captionPath = path + videoUUID + '/captions/fr'
       await makeUploadRequest({
@@ -213,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 ])
   })
 })